cpm {edgeR}R Documentation

Calculate Counts per Million from DGEList or Matrix Object

Description

Returns counts per million from a DGEList or matrix object by dividing raw counts by library size (which can be normalized) and multiplying by one million.

Usage

cpm(x, normalized.lib.sizes=FALSE)

Arguments

x

either a matrix of counts or a DGEList object with (at least) elements counts (table of unadjusted counts) and samples (data frame containing information about experimental group, library size and normalization factor for the library size)

normalized.lib.sizes

logical, should the library sizes (total sum of counts for each library) be normalized using the norm.factors component of the DGEList object? Ignored (with a warning) if x is a count matrix.

Details

A convenience function to compute the counts per million for plotting and comparing libraries on a convenient scale. Essentially just does the calculation 1e06*t(t(x)/lib.size) to produce counts per million, where x is a matrix of counts and the lib.size can be the total sum of counts in each library or a normalized version of this using TMM normalization or equivalent method.

Value

getPriorN returns a numeric scalar

Author(s)

Davis McCarthy, Gordon Smyth

See Also

DGEList for more information about the DGEList class.

Examples

# generate raw counts from NB, create list object
y<-matrix(rnbinom(20,size=1,mu=10),nrow=5)
cpm(y)
d<-DGEList(counts=y,group=rep(1:2,each=2),lib.size=rep(c(1000:1001),2))
# When applied to a DGEList object, x$samples$lib.size is used
cpm(d)
# As x$samples$lib.size here is very different from colSums(y), cpm(y) and cpm(d) give very different results for the counts per million

[Package edgeR version 2.4.3 Index]