edgeR (version 3.14.0)

aveLogCPM: Average Log Counts Per Million


Compute average log2 counts-per-million for each row of counts.


"aveLogCPM"(y, normalized.lib.sizes=TRUE, prior.count=2, dispersion=NULL, ...) "aveLogCPM"(y, lib.size=NULL, offset=NULL, prior.count=2, dispersion=NULL, weights=NULL, ...)


numeric matrix containing counts. Rows for genes and columns for libraries.
logical, use normalized library sizes?
numeric scalar or vector of length nrow(y), containing the average value(s) to be added to each count to avoid infinite values on the log-scale.
numeric scalar or vector of negative-binomial dispersions. Defaults to 0.05.
numeric vector of library sizes. Defaults to colSums(y). Ignored if offset is not NULL.
numeric matrix of offsets for the log-linear models.
optional numeric matrix of observation weights.
other arguments are not currently used.


Numeric vector giving log2(AveCPM) for each row of y.


This function uses mglmOneGroup to compute average counts-per-million (AveCPM) for each row of counts, and returns log2(AveCPM). An average value of prior.count is added to the counts before running mglmOneGroup. If prior.count is a vector, each entry will be added to all counts in the corresponding row of y.

This function is similar to

log2(rowMeans(cpm(y, ...))),

but with the refinement that larger library sizes are given more weight in the average. The two versions will agree for large values of the dispersion.

See Also

See cpm for individual logCPM values, rather than genewise averages.

The computations for aveLogCPM are done by mglmOneGroup.


Run this code
y <- matrix(c(0,100,30,40),2,2)
lib.size <- c(1000,10000)

# With disp large, the function is equivalent to row-wise averages of individual cpms:
aveLogCPM(y, dispersion=1e4)
cpm(y, log=TRUE, prior.count=2)

# With disp=0, the function is equivalent to pooling the counts before dividing by lib.size:
cpms <- rowSums(y)/sum(lib.size)*1e6

# The function works perfectly with prior.count or dispersion vectors:
aveLogCPM(y, prior.count=runif(nrow(y), 1, 5))
aveLogCPM(y, dispersion=runif(nrow(y), 0, 0.2))

Run the code above in your browser using DataCamp Workspace