calculateAverage {scater}R Documentation

Calculate average counts, adjusting for size factors or library size

Description

Calculate average counts per feature, adjusting them to account for normalization due to size factors or library sizes.

Usage

calculateAverage(object, exprs_values = "counts",
  use_size_factors = TRUE, subset_row = NULL,
  BPPARAM = SerialParam())

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

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 whether the size factors in object should be used to construct effective library sizes.

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.

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 <- calculateAverage(example_sce)


[Package scater version 1.12.2 Index]