Filter cells

filterCells(object, ...)

# S4 method for SingleCellExperiment
filterCells(
  object,
  minCounts = 1L,
  maxCounts = Inf,
  minFeatures = 1L,
  maxFeatures = Inf,
  minNovelty = 0L,
  maxMitoRatio = 1L,
  minCellsPerFeature = 1L,
  nCells = Inf,
  countsCol = "nCount",
  featuresCol = "nFeature",
  noveltyCol = "log10FeaturesPerCount",
  mitoRatioCol = "mitoRatio"
)

Arguments

object

Object.

minCounts, maxCounts

integer(1). Minimum/maximum number of counts per cell. Applies to UMI disambiguated counts for droplet scRNA-seq. Matches nUMI then nCount column in colData() internally. Previously named minUMIs/maxUMIs in bcbioSingleCell.

minFeatures, maxFeatures

integer(1). Minimum/maximum number of features (i.e. genes) detected. Matches nFeaturein colData() internally. Previously named minGenes/maxGenes in bcbioSingleCell.

minNovelty

integer(1) (0-1). Minimum novelty score (log10 features per UMI). Matches log10FeaturesPerCount then log10FeaturesPerUMI (legacy) colData() internally.

maxMitoRatio

integer(1) (0-1). Maximum relative mitochondrial abundance.

minCellsPerFeature

integer(1). Include genes with non-zero expression in at least this many cells. Previously named minCellsPerGene in bcbioSingleCell.

nCells

integer(1). Expected number of cells per sample. Don't set this by default, unless you're confident of your capture.

countsCol, featuresCol, noveltyCol, mitoRatioCol

character(1). Column mapping name.

...

Additional arguments.

Value

SingleCellExperiment.

Details

Apply feature (i.e. gene/transcript) detection, novelty score, and mitochondrial abundance cutoffs to cellular barcodes. By default we recommend applying the same filtering cutoff to all samples. The filtering parameters now support per-sample cutoffs, defined using a named numeric vector. When matching per sample, be sure to use the sampleNames() return values (i.e. the sampleName column in sampleData()).

Filtering information gets slotted into metadata() as filterCells metadata.

Note

Updated 2020-01-20.

Examples

data(SingleCellExperiment, package = "acidtest") ## SingleCellExperiment ==== object <- SingleCellExperiment x <- filterCells(object)
#> → Filtering cells with `filterCells()`.
#> → Calculating 100 sample metrics.
#> 496 coding features detected.
#> 0 mitochondrial features detected.
#> Pre-filter:
#> ● 100 cells
#> ● 500 features
#> Post-filter:
#> ● 100 cells (100%)
#> ● 483 features (97%)
#> Per argument:
#> minCounts: 100
#> maxCounts: 100
#> minFeatures: 100
#> maxFeatures: 100
#> minNovelty: 100
#> Per sample, per argument:
#> sample1:
#> minCounts: 53
#> maxCounts: 53
#> minFeatures: 53
#> maxFeatures: 53
#> minNovelty: 53
#> sample2:
#> minCounts: 47
#> maxCounts: 47
#> minFeatures: 47
#> maxFeatures: 47
#> minNovelty: 47
#> Cell filtering was successful.
#> class: SingleCellExperiment #> dim: 483 100 #> metadata(3): date filterCells subset #> assays(1): counts #> rownames(483): gene001 gene002 ... gene499 gene500 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(100): cell001 cell002 ... cell099 cell100 #> colData names(7): sampleID nCount ... log10FeaturesPerCount mitoRatio #> reducedDimNames(0): #> spikeNames(0): #> altExpNames(0):
## Per sample cutoffs. sampleNames(object)
#> sample1 sample2 #> "sample1" "sample2"
x <- filterCells( object = object, minCounts = c(sample1 = 100L) )
#> → Filtering cells with `filterCells()`.
#> → Calculating 100 sample metrics.
#> 496 coding features detected.
#> 0 mitochondrial features detected.
#> Pre-filter:
#> ● 100 cells
#> ● 500 features
#> Post-filter:
#> ● 100 cells (100%)
#> ● 483 features (97%)
#> Per argument:
#> minCounts: 100
#> maxCounts: 100
#> minFeatures: 100
#> maxFeatures: 100
#> minNovelty: 100
#> Per sample, per argument:
#> sample1:
#> minCounts: 53
#> maxCounts: 53
#> minFeatures: 53
#> maxFeatures: 53
#> minNovelty: 53
#> sample2:
#> minCounts: 47
#> maxCounts: 47
#> minFeatures: 47
#> maxFeatures: 47
#> minNovelty: 47
#> Cell filtering was successful.
#> class: SingleCellExperiment #> dim: 483 100 #> metadata(3): date filterCells subset #> assays(1): counts #> rownames(483): gene001 gene002 ... gene499 gene500 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(100): cell001 cell002 ... cell099 cell100 #> colData names(7): sampleID nCount ... log10FeaturesPerCount mitoRatio #> reducedDimNames(0): #> spikeNames(0): #> altExpNames(0):