dispBinTrend {edgeR}R Documentation

Estimate Dispersions with an Abundance-Dependent Trend for Negative Binomial GLMs

Description

Estimate a dispersion parameter for each of many negative binomial generalized linear models by computing the common dispersion for genes sorted into bins based on overall abundance and then using splines or a loess fit to interpolate a dispersion value for each gene, dependent on overall abundance of the gene.

Usage

dispBinTrend(y, design, offset=NULL, df = 5, span=2/3, min.n=500, method.bin="CoxReid", method.trend="spline", trace=0, ...)

Arguments

y

numeric matrix of counts

design

numeric matrix giving the design matrix for the GLM that is to be fit.

offset

numeric scalar, vector or matrix giving the offset (in addition to the log of the effective library size) that is to be included in the NB GLM for the transcripts. If a scalar, then this value will be used as an offset for all transcripts and libraries. If a vector, it should be have length equal to the number of libraries, and the same vector of offsets will be used for each transcript. If a matrix, then each library for each transcript can have a unique offset, if desired. In adjustedProfileLik the offset must be a matrix with the same dimension as the table of counts.

df

scalar, the degrees of freedom for the natural cubic splines fit, used to determine the placement of the knots (number of knots is df - 1. Default is 5.

span

scalar, passed to loess to determine the amount of smoothing for the loess fit. Default is 2/3.

min.n

scalar, minimim number of genes in each of the bins into which genes are sorted to form the basis for interpolating the dispersions. Setting a minimum value ensures that there will be sufficient genes in each bin to allow reliable estimation of the common dispersion for each bin.

method.bin

character, passed to binGLMDispersion, to specify the method used to compute the common dispersion within each bin of genes. Default is "CoxReid", other options are "Pearson" and "deviance".

method.trend

character, specifies method to produce a smooth fit through the binned common dispersions in order to interpolate the trended dispersions. Default is "spline" to use natural cubic splines, other option is "loess" to use a loess fit.

trace

logical, should iteration information be output?

...

option arguments to be passed to lower-level function binGLMDispersion.

Details

This function takes the binned common dispersion and abundance from binGLMDispersion and fits a smooth curve through these binned values using either natural cubic splines or loess. From this smooth curve it predicts the dispersion value for each gene based on the gene's overall abundance. This results in estimates for the NB dispersion parameter which have a dependence on the overall expression level of the gene, and thus have an abundance-dependent trend. This function is called by estimateGLMTrendedDisp.

Value

list with the following components:

abundance

numeric vector containing the overall abundance for each gene

dispersion

numeric vector giving the trended dispersion estimate for each gene

bin.abundance

numeric vector of length equal to nbins giving the average (mean) abundance for each bin

bin.dispersion

numeric vector of length equal to nbins giving the estimated common dispersion for each bin

Author(s)

Davis McCarthy and Gordon Smyth

References

Cox, DR, and Reid, N (1987). Parameter orthogonality and approximate conditional inference. Journal of the Royal Statistical Society Series B 49, 1-39.

See Also

binGLMDispersion, estimateGLMTrendedDisp

Examples

ntags <- 1000
nlibs <- 4
means <- seq(5,10000,length.out=ntags)
y <- matrix(rnbinom(ntags*nlibs,mu=rep(means,nlibs),size=0.1*means),nrow=ntags,ncol=nlibs)
keep <- rowSums(y) > 0
y <- y[keep,]
group <- factor(c(1,1,2,2))
lib.size <- colSums(y)
design <- model.matrix(~group) # Define the design matrix for the full model
disp <- dispBinTrend(y, design, offset=log(lib.size), min.n=100, span=0.3)
plot(disp$abundance, disp$dispersion)

[Package edgeR version 2.4.3 Index]