calcAverage {scater}R Documentation

Calculate average counts, adjusting for size factors or library size

Description

Calculate average counts per feature, adjusting them as appropriate to take into account for size factors for normalization or library sizes (total counts).

Usage

calcAverage(object, exprs_values = "counts", use_size_factors = TRUE,
  size_factor_grouping = NULL, subset_row = NULL)

Arguments

object

A SingleCellExperiment object or count matrix.

exprs_values

A string specifying the assay of object containing the count matrix, if object is a SingleCellExperiment.

use_size_factors

a logical scalar specifying whetherthe size factors in object should be used to construct effective library sizes.

size_factor_grouping

A factor to be passed to grouping= in centreSizeFactors.

subset_row

A vector specifying whether the rows of object should be (effectively) subsetted before calcaulting feature averages.

Details

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 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.

Value

Vector of average count values with same length as number of features, or the number of features in subset_row if supplied.

Examples

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)


[Package scater version 1.8.4 Index]