Skip to contents

Filter cells

Usage

filterCells(object, ...)

# S4 method for SingleCellExperiment
filterCells(
  object,
  assay = 1L,
  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.

assay

vector(1). Assay name or index position.

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 2022-10-24.

Examples

data(SingleCellExperiment_splatter, package = "AcidTest")

## SingleCellExperiment ====
object <- SingleCellExperiment_splatter
x <- filterCells(object)
#> → Filtering cells with `filterCells()`.
#> → Calculating 400 sample metrics.
#>  99 coding features detected.
#>  0 mitochondrial features detected.
#> ! No filtering applied.
print(x)
#> class: SingleCellExperiment 
#> dim: 100 400 
#> metadata(1): date
#> assays(1): counts
#> rownames(100): gene001 gene002 ... gene099 gene100
#> rowData names(10): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(400): cell001 cell002 ... cell399 cell400
#> colData names(7): sampleId nCount ... log10FeaturesPerCount mitoRatio
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):

## Per sample cutoffs.
x <- filterCells(
    object = object,
    minCounts = c("sample1" = 100L)
)
#> → Filtering cells with `filterCells()`.
#> → Calculating 400 sample metrics.
#>  99 coding features detected.
#>  0 mitochondrial features detected.
#> ! No filtering applied.
print(x)
#> class: SingleCellExperiment 
#> dim: 100 400 
#> metadata(1): date
#> assays(1): counts
#> rownames(100): gene001 gene002 ... gene099 gene100
#> rowData names(10): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(400): cell001 cell002 ... cell399 cell400
#> colData names(7): sampleId nCount ... log10FeaturesPerCount mitoRatio
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):