The [[ operator pulls either subobjects (eg. v3 or v5 assays, dimensional reduction information, or nearest-neighbor graphs) or cell-level meta data from a Seurat object

# S3 method for Seurat
[[(x, i = missing_arg(), ..., drop = FALSE, na.rm = FALSE)

# S3 method for Seurat
head(x, n = 10L, ...)

# S3 method for Seurat
tail(x, n = 10L, ...)

Arguments

x

A Seurat object

i

Name of cell-level meta data

...

Ignored

drop

See drop

na.rm

Remove cells where meta data is all NA

n

Number of meta data rows to show

Value

Varies based on the value of i:

  • If i is missing, a data frame with cell-level meta data

  • If i is a vector with cell-level meta data names, a data frame (or vector of drop = TRUE) with cell-level meta data requested

  • If i is a one-length character with the name of a subobject, the subobject specified by i

head: The first n rows of cell-level metadata

tail: The last n rows of cell-level metadata

See also

See here for adding meta data with [[<-, here for adding subobjects with [[<-, and here for removing subobjects and cell-level meta data with [[<-

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

Examples

# Get the cell-level metadata data frame
head(pbmc_small[[]])
#>                   orig.ident nCount_RNA nFeature_RNA RNA_snn_res.0.8
#> ATGCCAGAACGACT SeuratProject         70           47               0
#> CATGGCCTGTGCAT SeuratProject         85           52               0
#> GAACCTGATGAACC SeuratProject         87           50               1
#> TGACTGGATTCTCA SeuratProject        127           56               0
#> AGTCAGACTGCACA SeuratProject        173           53               0
#> TCTGATACACGTGT SeuratProject         70           48               0
#>                letter.idents groups RNA_snn_res.1
#> ATGCCAGAACGACT             A     g2             0
#> CATGGCCTGTGCAT             A     g1             0
#> GAACCTGATGAACC             B     g2             0
#> TGACTGGATTCTCA             A     g2             0
#> AGTCAGACTGCACA             A     g2             0
#> TCTGATACACGTGT             A     g1             0

# Pull specific metadata information
head(pbmc_small[[c("letter.idents", "groups")]])
#>                letter.idents groups
#> ATGCCAGAACGACT             A     g2
#> CATGGCCTGTGCAT             A     g1
#> GAACCTGATGAACC             B     g2
#> TGACTGGATTCTCA             A     g2
#> AGTCAGACTGCACA             A     g2
#> TCTGATACACGTGT             A     g1
head(pbmc_small[["groups", drop = TRUE]])
#> ATGCCAGAACGACT CATGGCCTGTGCAT GAACCTGATGAACC TGACTGGATTCTCA AGTCAGACTGCACA 
#>           "g2"           "g1"           "g2"           "g2"           "g2" 
#> TCTGATACACGTGT 
#>           "g1" 

# Get a sub-object (eg. an `Assay` or `DimReduc`)
pbmc_small[["RNA"]]
#> Assay data with 230 features for 80 cells
#> Top 10 variable features:
#>  PPBP, IGLL5, VDAC3, CD1C, AKR1C3, PF4, MYL9, GNLY, TREML1, CA2 
pbmc_small[["pca"]]
#> Warning: Requested number is larger than the number of available items (20). Setting to 20.
#> PC_ 1 
#> Positive:  SDPR, PF4, PPBP, TUBB1, CA2, TREML1, MYL9, PGRMC1, RUFY1, PARVB 
#> Negative:  HLA-DPB1, HLA-DQA1, S100A9, S100A8, GNLY, RP11-290F20.3, CD1C, AKR1C3, IGLL5, VDAC3 
#> Warning: Requested number is larger than the number of available items (20). Setting to 20.
#> PC_ 2 
#> Positive:  HLA-DPB1, HLA-DQA1, S100A8, S100A9, CD1C, RP11-290F20.3, PARVB, IGLL5, MYL9, SDPR 
#> Negative:  GNLY, AKR1C3, VDAC3, PGRMC1, TUBB1, PF4, TREML1, RUFY1, CA2, PPBP 
#> Warning: Requested number is larger than the number of available items (20). Setting to 20.
#> PC_ 3 
#> Positive:  S100A9, S100A8, RP11-290F20.3, AKR1C3, PARVB, GNLY, PPBP, PGRMC1, MYL9, TUBB1 
#> Negative:  HLA-DQA1, CD1C, IGLL5, HLA-DPB1, RUFY1, PF4, VDAC3, SDPR, TREML1, CA2 
#> Warning: Requested number is larger than the number of available items (20). Setting to 20.
#> PC_ 4 
#> Positive:  IGLL5, RP11-290F20.3, VDAC3, PPBP, TUBB1, TREML1, PF4, CA2, PARVB, MYL9 
#> Negative:  CD1C, AKR1C3, S100A8, GNLY, HLA-DPB1, HLA-DQA1, S100A9, PGRMC1, RUFY1, SDPR 
#> Warning: Requested number is larger than the number of available items (20). Setting to 20.
#> PC_ 5 
#> Positive:  MYL9, PARVB, IGLL5, TREML1, AKR1C3, PGRMC1, HLA-DPB1, S100A9, TUBB1, PF4 
#> Negative:  VDAC3, RP11-290F20.3, RUFY1, CD1C, HLA-DQA1, CA2, S100A8, PPBP, GNLY, SDPR 

# Get the first 10 rows of cell-level metadata
head(pbmc_small)
#>                   orig.ident nCount_RNA nFeature_RNA RNA_snn_res.0.8
#> ATGCCAGAACGACT SeuratProject         70           47               0
#> CATGGCCTGTGCAT SeuratProject         85           52               0
#> GAACCTGATGAACC SeuratProject         87           50               1
#> TGACTGGATTCTCA SeuratProject        127           56               0
#> AGTCAGACTGCACA SeuratProject        173           53               0
#> TCTGATACACGTGT SeuratProject         70           48               0
#> TGGTATCTAAACAG SeuratProject         64           36               0
#> GCAGCTCTGTTTCT SeuratProject         72           45               0
#> GATATAACACGCAT SeuratProject         52           36               0
#> AATGTTGACAGTCA SeuratProject        100           41               0
#>                letter.idents groups RNA_snn_res.1
#> ATGCCAGAACGACT             A     g2             0
#> CATGGCCTGTGCAT             A     g1             0
#> GAACCTGATGAACC             B     g2             0
#> TGACTGGATTCTCA             A     g2             0
#> AGTCAGACTGCACA             A     g2             0
#> TCTGATACACGTGT             A     g1             0
#> TGGTATCTAAACAG             A     g1             0
#> GCAGCTCTGTTTCT             A     g1             0
#> GATATAACACGCAT             A     g1             0
#> AATGTTGACAGTCA             A     g1             0

# Get the last 10 rows of cell-level metadata
tail(pbmc_small)
#>                   orig.ident nCount_RNA nFeature_RNA RNA_snn_res.0.8
#> ATTCAGCTCATTGG SeuratProject        212           38               0
#> GGCATATGGGGAGT SeuratProject        172           29               0
#> ATCATCTGACACCA SeuratProject        168           37               0
#> GTCATACTTCGCCT SeuratProject        210           33               0
#> TTACGTACGTTCAG SeuratProject        228           39               0
#> GAGTTGTGGTAGCT SeuratProject        527           47               0
#> GACGCTCTCTCTCG SeuratProject        202           30               0
#> AGTCTTACTTCGGA SeuratProject        157           29               0
#> GGAACACTTCAGAC SeuratProject        150           30               0
#> CTTGATTGATCTTC SeuratProject        233           76               1
#>                letter.idents groups RNA_snn_res.1
#> ATTCAGCTCATTGG             A     g2             0
#> GGCATATGGGGAGT             A     g1             0
#> ATCATCTGACACCA             A     g2             0
#> GTCATACTTCGCCT             A     g2             0
#> TTACGTACGTTCAG             A     g1             0
#> GAGTTGTGGTAGCT             A     g1             0
#> GACGCTCTCTCTCG             A     g2             0
#> AGTCTTACTTCGGA             A     g1             0
#> GGAACACTTCAGAC             A     g2             0
#> CTTGATTGATCTTC             B     g1             1