Get feature names
Source:R/methods-FactorisedExperiment.R
, R/methods-ModularExperiment.R
, R/methods-ReducedExperiment.R
feature_names.Rd
Gets and sets feature names (i.e., rownames, usually genes).
Usage
# S4 method for class 'FactorisedExperiment'
names(x) <- value
# S4 method for class 'FactorisedExperiment'
featureNames(x) <- value
# S4 method for class 'FactorisedExperiment'
rownames(x) <- value
# S4 method for class 'ModularExperiment'
names(x) <- value
# S4 method for class 'ModularExperiment'
featureNames(x) <- value
# S4 method for class 'ModularExperiment'
rownames(x) <- value
# S4 method for class 'ReducedExperiment'
featureNames(x)
# S4 method for class 'ReducedExperiment'
names(x) <- value
# S4 method for class 'ReducedExperiment'
rownames(x) <- value
# S4 method for class 'ReducedExperiment'
ROWNAMES(x) <- value
# S4 method for class 'ReducedExperiment'
featureNames(x) <- value
Arguments
- x
ReducedExperiment object.
- value
New value to replace existing names.
Examples
# Create randomised data with the following dimensions
i <- 300 # Number of features
j <- 100 # Number of samples
k <- 10 # Number of factors
rand_assay_data <- ReducedExperiment:::.makeRandomData(i, j, "gene", "sample")
rand_reduced_data <- ReducedExperiment:::.makeRandomData(j, k, "sample", "component")
re <- ReducedExperiment(
assays = list("normal" = rand_assay_data),
reduced = rand_reduced_data
)
# Methods return equivalent results
stopifnot(all.equal(featureNames(re), rownames(rand_assay_data)))
stopifnot(all.equal(rownames(re), rownames(rand_assay_data)))
stopifnot(all.equal(names(re), rownames(rand_assay_data)))
# We can change the feature name at a particular position
print(paste0("Feature name at position 55: ", featureNames(re)[55]))
#> [1] "Feature name at position 55: gene_55"
featureNames(re)[55] <- "custom_feature_name"
print(paste0("Reduced data at position 55: ", featureNames(re)[55]))
#> [1] "Reduced data at position 55: custom_feature_name"