Skip to contents

The input can be a base R matrix or a sparse matrix from the Matrix package.

Usage

cpm(counts, sf = NULL, denom = 1e+06, cells.as.rows = FALSE)

Arguments

counts

a matrix, dgCMatrix, or dgTMatrix of count values.

sf

vector of numeric values representing the total number of reads. If count matrix includes all genes, value calulated by default (sf=NULL) will be accurate; however, if count matrix represents only a small fraction of genes, we recommend also providing this value.

denom

Denominator that all counts will be scaled to. The default (1 million) is commonly used, but 10000 is also common for sparser droplet-based sequencing methods.

cells.as.rows

Set to FALSE (default) if rows are genes and columns are cells or TRUE if rows are cells and columns are genes.

Value

a matrix, dgCMatrix, or dgTMatrix of CPM values (matching input)

Details

This function expects that columns correspond to samples, and rows to genes, but can also take the transpose if specified by cells.as.rows=TRUE.