Skip to contents

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

Usage

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

Arguments

counts

A matrix, dgCMatrix, or dgTMatrix of count values

offset

The constant offset to add to each cpm value prior to taking log2 (default = 1)

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 log2(CPM + 1) values (matching input)

Details

This function expects that columns correspond to samples, and rows to genes by default, but can also take the transpose if specified by cells.as.rows=TRUE. By default the offset is 1, but to calculate just log2(counts per Million) set offset to 0.