Subset Seurat
Objects
# S3 method for Seurat
subset(
x,
subset,
cells = NULL,
features = NULL,
idents = NULL,
return.null = FALSE,
...
)
# S3 method for Seurat
[(x, i, j, ...)
A Seurat
object
Logical expression indicating features/variables to keep
A vector of cell names or indices to keep
A vector of feature names or indices to keep
A vector of identity classes to keep
If no cells are requested, return a NULL
;
by default, throws an error
Arguments passed to WhichCells
subset
: A subsetted Seurat
object
[
: object x
with features i
and cells j
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
# `subset` examples
subset(pbmc_small, subset = MS4A1 > 4)
#> An object of class Seurat
#> 230 features across 10 samples within 1 assay
#> Active assay: RNA (230 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne
subset(pbmc_small, subset = `DLGAP1-AS1` > 2)
#> An object of class Seurat
#> 230 features across 4 samples within 1 assay
#> Active assay: RNA (230 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne
subset(pbmc_small, idents = '0', invert = TRUE)
#> An object of class Seurat
#> 230 features across 44 samples within 1 assay
#> Active assay: RNA (230 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne
subset(pbmc_small, subset = MS4A1 > 3, slot = 'counts')
#> An object of class Seurat
#> 230 features across 3 samples within 1 assay
#> Active assay: RNA (230 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne
subset(pbmc_small, features = VariableFeatures(object = pbmc_small))
#> An object of class Seurat
#> 20 features across 80 samples within 1 assay
#> Active assay: RNA (20 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne
# `[` examples
pbmc_small[VariableFeatures(object = pbmc_small), ]
#> An object of class Seurat
#> 20 features across 80 samples within 1 assay
#> Active assay: RNA (20 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne
pbmc_small[, 1:10]
#> An object of class Seurat
#> 230 features across 10 samples within 1 assay
#> Active assay: RNA (230 features, 20 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, tsne