sizeFactors: Size factor methods

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Gets or sets the size factors for all cells in a SingleCellExperiment object.

Usage

1
2
3
4
5
## S4 method for signature 'SingleCellExperiment'
sizeFactors(object, onAbsence = "none")

## S4 replacement method for signature 'SingleCellExperiment'
sizeFactors(object, ...) <- value

Arguments

object

A SingleCellExperiment object.

onAbsence

String indicating an additional action to take when size factors are absent: nothing ("none"), a warning ("warn") or an error ("error").

...

Additional arguments, currently ignored.

value

A numeric vector of length equal to ncol(object), containing size factors for all cells.

Details

A size factor is a scaling factor used to divide the raw counts of a particular cell to obtain normalized expression values, thus allowing downstream comparisons between cells that are not affected by differences in library size or total RNA content. The sizeFactors methods can be used to get or set size factors for all cells in a SingleCellExperiment object.

When setting size factors, the values are stored in the colData as the sizeFactors field. This name is chosen for general consistency with other packages (e.g., DESeq2) and to allow the size factors to be easily extracted from the colData for use as covariates.

For developers, onAbsence is provided to make it easier to mandate that object has size factors. This avoids silent NULL values that flow to the rest of the function and make debugging difficult.

Value

For sizeFactors, a numeric vector is returned containing size factors for all cells. If no size factors are available, a NULL is returned (and/or a warning or error, depending on onAbsence).

For sizeFactors<-, a modified object is returned with size factors in its colData.

Author(s)

Aaron Lun

See Also

SingleCellExperiment, for the underlying class definition.

librarySizeFactors from the scater package or computeSumFactors from the scran package, as examples of functions that compute the size factors.

Examples

1
2
3
example(SingleCellExperiment, echo=FALSE) # Using the class example
sizeFactors(sce) <- runif(ncol(sce))
sizeFactors(sce)

LTLA/SingleCellExperiment documentation built on May 25, 2021, 3:42 a.m.