Get and set cell-level meta data

# S3 method for Seurat
$(x, i)

# S3 method for Seurat
$(x, i, ...) <- value

# S4 method for Seurat,character,missing,data.frame
[[(x, i, j, ...) <- value

# S4 method for Seurat,missing,missing,data.frame
[[(x, i, j, ...) <- value

# S4 method for Seurat,character,missing,factor
[[(x, i, j, ...) <- value

# S4 method for Seurat,character,missing,list
[[(x, i, j, ...) <- value

# S4 method for Seurat,missing,missing,list
[[(x, i, j, ...) <- value

# S4 method for Seurat,character,missing,vector
[[(x, i, j, ...) <- value

Arguments

x

A Seurat object

i

Name of cell-level meta data

...

Ignored

value

A vector to add as cell-level meta data

j

Ignored

Value

$: Metadata column i for object x; note: unlike [[, $ drops the shape of the metadata to return a vector instead of a data frame

$<-: x with metadata value saved as i

See also

Seurat object, validity, and interaction methods Seurat-class, Seurat-validity, [[.Seurat(), [[<-,Seurat, [[<-,Seurat,NULL, dim.Seurat(), dimnames.Seurat(), merge.Seurat(), names.Seurat(), subset.Seurat()

Examples

# Get metadata using `$'
head(pbmc_small$groups)
#> ATGCCAGAACGACT CATGGCCTGTGCAT GAACCTGATGAACC TGACTGGATTCTCA AGTCAGACTGCACA 
#>           "g2"           "g1"           "g2"           "g2"           "g2" 
#> TCTGATACACGTGT 
#>           "g1" 

# Add metadata using the `$' operator
set.seed(42)
pbmc_small$value <- sample(1:3, size = ncol(pbmc_small), replace = TRUE)
head(pbmc_small[["value"]])
#>                value
#> ATGCCAGAACGACT     1
#> CATGGCCTGTGCAT     1
#> GAACCTGATGAACC     1
#> TGACTGGATTCTCA     1
#> AGTCAGACTGCACA     2
#> TCTGATACACGTGT     2