calcAverage {scater} | R Documentation |
Calculate average counts per feature, adjusting them as appropriate to take into account for size factors for normalization or library sizes (total counts).
calcAverage(object, exprs_values = "counts", use_size_factors = TRUE, size_factor_grouping = NULL, subset_row = NULL)
object |
A SingleCellExperiment object or count matrix. |
exprs_values |
A string specifying the assay of |
use_size_factors |
a logical scalar specifying whetherthe size factors in |
size_factor_grouping |
A factor to be passed to |
subset_row |
A vector specifying whether the rows of |
The size-adjusted average count is defined by dividing each count by the size factor and taking the average across cells. All sizes factors are scaled so that the mean is 1 across all cells, to ensure that the averages are interpretable on the scale of the raw counts.
Assuming that object
is a SingleCellExperiment:
If use_size_factors=TRUE
, size factors are automatically extracted from the object.
Note that different size factors may be used for features marked as spike-in controls.
This is due to the presence of control-specific size factors in object
, see normalizeSCE
for more details.
If use_size_factors=FALSE
, all size factors in object
are ignored.
Size factors are instead computed from the library sizes, using librarySizeFactors
.
If use_size_factors
is a numeric vector, it will override the any size factors for non-spike-in features in object
.
The spike-in size factors will still be used for the spike-in transcripts.
If no size factors are available, they will be computed from the library sizes using librarySizeFactors
.
If object
is a matrix or matrix-like object, size factors can be supplied by setting use_size_factors
to a numeric vector.
Otherwise, the sum of counts for each cell is used as the size factor through librarySizeFactors
.
Vector of average count values with same length as number of features, or the number of features in subset_row
if supplied.
data("sc_example_counts") data("sc_example_cell_info") example_sce <- SingleCellExperiment( list(counts = sc_example_counts), colData = sc_example_cell_info) ## calculate average counts ave_counts <- calcAverage(example_sce)