sizeFactors: Size factor methods

sizeFactorsR Documentation

Size factor methods


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


## S4 method for signature 'SingleCellExperiment'
sizeFactors(object, onAbsence = "none")

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



A SingleCellExperiment object.


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.


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


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.


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.


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.


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

LTLA/SingleCellExperiment documentation built on March 24, 2023, 4:07 a.m.