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.
edgerWrp(
count,
lib_size = NULL,
option = c("glm", "glmQL"),
design,
contrast = NULL,
normalize = TRUE,
normalize_method = "TMM",
...
)
A matrix with features (e.g., genes or microbes) in rows and samples in columns.
A numeric vector with library sizes for each sample. If
NULL
(default), the column sums of count
are used.
Either "glm"
or "glmQL"
. If "glm"
,
glmFit
and glmLRT
are used;
otherwise, glmQLFit
and
glmQLFTest
are used. Details about the difference
between the two options can be found in the help pages of
glmQLFit
.
A numeric design matrix, e.g. created by
model.matrix
. Please refer to design
in
glmQLFit
and glmFit
for
more details.
A numeric vector specifying one contrast of
the linear model coefficients to be tested. Its length
must equal the number of columns of design
. If NULL
, the
last coefficient will be tested. Please refer to contrast
in glmQLFTest
and glmLRT
for
more details.
A logical scalar, specifying whether normalization factors
should be calculated (using calcNormFactors
).
Normalization method to be used. Please refer to
method
in calcNormFactors
for more details.
More arguments to pass to glmFit
(if option = "glm"
or glmQLFit
(if option = "glmQL"
).
The output of glmQLFTest
or
glmLRT
depending on the specified option
.
The function performs the following steps:
Create a DGEList
object. If lib_size
is
given, set the library sizes to these values, otherwise use the column sums
of the count matrix.
If normalize
is TRUE
, estimate normalization factors
using calcNormFactors
.
Estimate dispersions with estimateDisp
.
Depending on the value of option
, apply either the LRT or
QLF edgeR workflows (i.e., either glmFit
+
glmLRT
or glmQLFit
+
glmQLFTest
), testing for the specified contrast.
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"