calculateAverage {scater} | R Documentation

## Calculate per-feature average counts

### Description

Calculate average counts per feature after normalizing observations using size factors.

### Usage

    calculateAverage(x, ...)

    ## S4 method for signature 'ANY'
    calculateAverage(x, size_factors = NULL,
      use_size_factors = NULL, subset_row = NULL,
      BPPARAM = SerialParam())

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

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

    calcAverage(x, ...)

### Arguments

`x` | A numeric matrix of counts where features are rows and 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`.
`use_size_factors` | Deprecated, same as `size_factors`.
`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.
`exprs_values` | A string specifying the assay of `x` containing the count matrix.

### 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 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)

[Package scater version 1.14.0 Index]