medianSizeFactors: Compute median-based size factors

medianSizeFactorsR Documentation

Compute median-based size factors

Description

Define per-cell size factors by taking the median of ratios to a reference expression profile (a la DESeq).

Usage

medianSizeFactors(x, ...)

## S4 method for signature 'ANY'
medianSizeFactors(x, subset.row = NULL, reference = NULL, subset_row = NULL)

## S4 method for signature 'SummarizedExperiment'
medianSizeFactors(x, ..., assay.type = "counts", exprs_values = NULL)

computeMedianFactors(x, ...)

Arguments

x

For medianSizeFactors, a numeric matrix of counts with one row per feature and column per cell. Alternatively, a SummarizedExperiment or SingleCellExperiment containing such counts.

For computeMedianFactors, only a SingleCellExperiment is accepted.

...

For the medianSizeFactors generic, arguments to pass to specific methods. For the SummarizedExperiment method, further arguments to pass to the ANY method.

For computeMedianFactors, further arguments to pass to medianSizeFactors.

subset.row

A vector specifying whether the size factors should be computed from a subset of rows of x.

reference

A numeric vector of length equal to nrow(x), containing the reference expression profile. Defaults to rowMeans(x).

subset_row, exprs_values

Soft-deprecated equivalent to the arguments above.

assay.type

String or integer scalar indicating the assay of x containing the counts.

Details

This function implements a modified version of the DESeq2 size factor calculation. For each cell, the size factor is proportional to the median of the ratios of that cell's counts to reference. The assumption is that most genes are not DE between the cell and the reference, such that the median captures any systematic increase due to technical biases.

The modification stems from the fact that we use the arithmetic mean instead of the geometric mean to compute the default reference, as the former is more robust to the many zeros in single-cell RNA sequencing data. We also ignore all genes with values of zero in reference, as this usually results in undefined ratios when reference is itself computed from x.

Value

For medianSizeFactors, a numeric vector of size factors is returned for all methods.

For computeMedianFactors, x is returned containing the size factors in sizeFactors(x).

Caveats

For typical scRNA-seq datasets, the median-based approach tends to perform poorly, for various reasons:

  • The high number of zeroes in the count matrix means that the median ratio for each cell is often zero. If this method must be used, we recommend subsetting to only the highest-abundance genes to avoid problems with zeroes. (Of course, the smaller the subset, the more sensitive the results are to noise or violations of the non-DE majority.)

  • The default reference effectively requires a non-DE majority of genes between any pair of cells in the dataset. This is a strong assumption for heterogeneous populations containing many cell types; most genes are likely to exhibit DE between at least one pair of cell types.

For these reasons, the simpler librarySizeFactors is usually preferred, which is no less inaccurate but is at least guaranteed to return a positive size factor for any cell with non-zero counts.

One valid application of this method lies in the normalization of antibody-derived tag counts for quantifying surface proteins. These counts are usually large enough to avoid zeroes yet are also susceptible to strong composition biases that preclude the use of librarySizeFactors. In such cases, we would also set reference to some estimate of the the ambient profile. This assumes that most proteins are not expressed in each cell; thus, counts for most tags for any given cell can be attributed to background contamination that should not be DE between cells.

Author(s)

Aaron Lun

See Also

normalizeCounts and logNormCounts, where these size factors can be used.

librarySizeFactors and geometricSizeFactors for other simple methods for computing size factors.

Examples

example_sce <- mockSCE()
summary(medianSizeFactors(example_sce))

LTLA/scuttle documentation built on Oct. 28, 2024, 9:45 a.m.