calculateAverage: Calculate per-feature average counts

calculateAverageR Documentation

Calculate per-feature average counts

Description

Calculate the average count for each feature after normalizing observations using per-cell size factors.

Usage

calculateAverage(x, ...)

## S4 method for signature 'ANY'
calculateAverage(
  x,
  size.factors = NULL,
  subset.row = NULL,
  BPPARAM = SerialParam(),
  size_factors = NULL,
  subset_row = NULL
)

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

## S4 method for signature 'SingleCellExperiment'
calculateAverage(x, size.factors = NULL, ...)

Arguments

x

A numeric matrix of counts where features are rows and columns are cells.

Alternatively, a SummarizedExperiment or a SingleCellExperiment containing such counts.

...

For the generic, arguments to pass to specific methods.

For the SummarizedExperiment method, further arguments to pass to the ANY method.

For the SingleCellExperiment method, further arguments to pass to the SummarizedExperiment method.

size.factors

A numeric vector containing size factors. If NULL, these are calculated or extracted from x.

subset.row

A vector specifying the subset of rows of object for which to return a result.

BPPARAM

A BiocParallelParam object specifying whether the calculations should be parallelized. Only relevant for parallelized rowSums(x), e.g., for DelayedMatrix inputs.

size_factors, subset_row, exprs_values

Soft-deprecated counterparts to the arguments above.

assay.type

A string specifying the assay of x containing the count matrix.

Details

The size factor-adjusted average count is defined by dividing each count by the size factor and taking the average across cells. All size factors are scaled so that the mean is 1 across all cells, to ensure that the averages are interpretable on the same scale of the raw counts.

If no size factors are supplied, they are determined automatically:

  • For count matrices and SummarizedExperiment inputs, the sum of counts for each cell is used to compute a size factor via the librarySizeFactors function.

  • For SingleCellExperiment instances, the function searches for sizeFactors from x. If none are available, it defaults to library size-derived size factors.

If size_factors are supplied, they will override any size factors present in x.

Value

A numeric vector of average count values with same length as number of features (or the number of features in subset_row if supplied).

Author(s)

Aaron Lun

See Also

librarySizeFactors, for the default calculation of size factors.

logNormCounts, for the calculation of normalized expression values.

Examples

example_sce <- mockSCE()
ave_counts <- calculateAverage(example_sce)
summary(ave_counts)

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