Skip to contents

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

Usage

log2CPM_byRow(counts, sf = NULL, denom = 1e+06, offset = 1)

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.

offset

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

Value

a dgCMatrix of log2(CPM + 1) values

Details

This function expects that columns correspond to genes, and rows to samples by default and is equivalent to running logCPM with cells.as.rows=TRUE (but a bit faster). By default the offset is 1, but to calculate just log2(counts per Million) set offset to 0.