Get and set feature and cell names in v5 Assays

# S3 method for Assay
dimnames(x)

# S3 method for Assay
dimnames(x) <- value

Arguments

x

An Assay object

value

A two-length list where the first entry is the existing feature names for x and the second entry is the updated cell names for x

Value

dimnames: A two-length list with the following values:

  • A character vector will all features in x

  • A character vector will all cells in x

dimnames<-: x with the cell names updated to those in value[[2L]]

See also

v3 Assay object, validity, and interaction methods: $.Assay(), Assay-class, Assay-validity, CreateAssayObject(), [.Assay(), [[.Assay(), dim.Assay(), merge.Assay(), split.Assay(), subset.Assay()

Cells(), dimnames.Assay5(), dimnames.Seurat()

Examples

rna <- pbmc_small[["RNA"]]

# Feature and cell names can be acquired with `rownames` and `colnames`
head(rownames(rna))
#> [1] "MS4A1"    "CD79B"    "CD79A"    "HLA-DRA"  "TCL1A"    "HLA-DQB1"
head(colnames(rna))
#> [1] "ATGCCAGAACGACT" "CATGGCCTGTGCAT" "GAACCTGATGAACC" "TGACTGGATTCTCA"
#> [5] "AGTCAGACTGCACA" "TCTGATACACGTGT"

# Cell names can be updated with `colnames<-`
colnames(rna)[1] <- "newcell"
head(colnames(rna))
#> [1] "newcell"        "CATGGCCTGTGCAT" "GAACCTGATGAACC" "TGACTGGATTCTCA"
#> [5] "AGTCAGACTGCACA" "TCTGATACACGTGT"