calculateCPM {scater} | R Documentation

## Calculate counts per million (CPM)

### Description

Calculate count-per-million (CPM) values from the count data.

### Usage

    calculateCPM(x, ...)

    ## S4 method for signature 'ANY'
    calculateCPM(x, size_factors = NULL, subset_row = NULL)

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

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

### Arguments

`x` | A numeric matrix of counts where features are rows and cells are columns. 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 to adjust the library sizes. If `NULL`, the library sizes are used directly.
`subset_row` | A vector specifying the subset of rows of `x` for which to return a result.
`exprs_values` | A string or integer scalar specifying the assay of `x` containing the count matrix.

### Details

If `size_factors` are provided or available in `x`, they are used to define the effective library sizes. This is done by scaling all size factors such that the mean factor is equal to the mean sum of counts across all features. The effective library sizes are then used as the denominator of the CPM calculation.

### Value

A numeric matrix of CPM values.

### Author(s)

Aaron Lun

### See Also

`normalizeCounts`, on which this function is based.

### Examples

    example_sce <- mockSCE()
    cpm(example_sce) <- calculateCPM(example_sce)
    str(cpm(example_sce))

[Package scater version 1.16.2 Index]