Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nbinomDeviance

Negative Binomial Deviance


Description

Fit the same log-link negative binomial or Poisson generalized linear model (GLM) to each row of a matrix of counts.

Usage

nbinomDeviance(y, mean, dispersion=0, weights=NULL)

Arguments

y

numeric matrix containing the negative binomial counts, with rows for genes and columns for libraries. A vector will be treated as a matrix with one row.

mean

numeric matrix of expected values, of same dimension as y. A vector will be treated as a matrix with one row.

dispersion

numeric vector or matrix of negative binomial dispersions, as for glmFit. Can be a scalar, a vector of length equal to nrow(y), or a matrix of same dimensions as y.

weights

numeric vector or matrix of non-negative weights, as for glmFit. Can be a scalar, a vector of length equal to ncol(y), or a matrix of same dimensions as y.

Details

Computes the total residual deviance for each row of y, i.e., weighted row sums of the unit deviances.

Care is taken to ensure accurate computation in limiting cases when the dispersion is near zero or mean*dispersion is very large.

Value

nbinomDeviance returns a numeric vector of length equal to the number of rows of y.

Author(s)

Gordon Smyth, Yunshun Chen, Aaron Lun. C++ code by Aaron Lun.

References

Jorgensen, B. (2013). Generalized linear models. Encyclopedia of Environmetrics 3, Wiley. http://onlinelibrary.wiley.com/doi/10.1002/9780470057339.vag010.pub2/abstract.

McCarthy, DJ, Chen, Y, Smyth, GK (2012). Differential expression analysis of multifactor RNA-Seq experiments with respect to biological variation. Nucleic Acids Research 40, 4288-4297. https://doi.org/10.1093/nar/gks042

See Also

Examples

y <- matrix(1:6,3,2)
mu <- matrix(3,3,2)
nbinomDeviance(y,mu,dispersion=0.2)

edgeR

Empirical Analysis of Digital Gene Expression Data in R

v3.32.1
GPL (>=2)
Authors
Yunshun Chen, Aaron TL Lun, Davis J McCarthy, Matthew E Ritchie, Belinda Phipson, Yifang Hu, Xiaobei Zhou, Mark D Robinson, Gordon K Smyth
Initial release
2021-01-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.