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 ofcount
are used.- option
Either
"glm"
or"glmQL"
. If"glm"
,glmFit
andglmLRT
are used; otherwise,glmQLFit
andglmQLFTest
are 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 todesign
inglmQLFit
andglmFit
for 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 tocontrast
inglmQLFTest
andglmLRT
for 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
method
incalcNormFactors
for 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
DGEList
object. Iflib_size
is given, set the library sizes to these values, otherwise use the column sums of the count matrix.If
normalize
isTRUE
, 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
+glmLRT
orglmQLFit
+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"