edgerWrp is a wrapper using functions from the
edgeR package (Robinson et al. 2010,
Bioinformatics; McCarthy et al. 2012, Nucleic Acids Research)
to fit models and perform a moderated test for each entity.
Usage
edgerWrp(
count,
lib_size = NULL,
option = c("glm", "glmQL"),
design,
contrast = NULL,
normalize = TRUE,
normalize_method = "TMM",
...
)Arguments
- count
A matrix with features (e.g., genes or microbes) in rows and samples in columns.
- lib_size
A numeric vector with library sizes for each sample. If
NULL(default), the column sums ofcountare used.- option
Either
"glm"or"glmQL". If"glm",glmFitandglmLRTare used; otherwise,glmQLFitandglmQLFTestare used. Details about the difference between the two options can be found in the help pages ofglmQLFit.- design
A numeric design matrix, e.g. created by
model.matrix. Please refer todesigninglmQLFitandglmFitfor more details.- contrast
A numeric vector specifying one contrast of the linear model coefficients to be tested. Its length must equal the number of columns of
design. IfNULL, the last coefficient will be tested. Please refer tocontrastinglmQLFTestandglmLRTfor more details.- normalize
A logical scalar, specifying whether normalization factors should be calculated (using
calcNormFactors).- normalize_method
Normalization method to be used. Please refer to
methodincalcNormFactorsfor more details.- ...
More arguments to pass to
glmFit(ifoption = "glm"orglmQLFit(ifoption = "glmQL").
Value
The output of glmQLFTest or
glmLRT depending on the specified option.
Details
The function performs the following steps:
Create a
DGEListobject. Iflib_sizeis given, set the library sizes to these values, otherwise use the column sums of the count matrix.If
normalizeisTRUE, estimate normalization factors usingcalcNormFactors.Estimate dispersions with
estimateDisp.Depending on the value of
option, apply either the LRT or QLF edgeR workflows (i.e., eitherglmFit+glmLRTorglmQLFit+glmQLFTest), testing for the specified contrast.
Examples
suppressPackageStartupMessages({
library(TreeSummarizedExperiment)
})
## Read example data
x <- readRDS(system.file("extdata/da_sim_100_30_18de.rds",
package = "treeclimbR"))
## Run differential abundance analysis
out <- edgerWrp(count = assay(x), option = "glm",
design = model.matrix(~ group, data = colData(x)),
contrast = c(0, 1))
## The output is an edgeR DGELRT object
class(out)
#> [1] "DGELRT"
#> attr(,"package")
#> [1] "edgeR"