Test for differential abundance of entities using functions from
the edgeR
package. This adapts edgerWrp
to
accept input as a
TreeSummarizedExperiment
(TSE) object instead of a matrix
. Features could be
represented in either rows or columns. By default, features are in the rows.
Then, samples are in columns and the sample information is in colData
.
The tree that stores the hierarchical information about features is in
rowTree
. Each row of the assays
can be mapped to a node of
the tree. Data on rows that are mapped to internal nodes is generated from
data on leaf nodes. Normalization for samples is automatically performed by
edgeR
and the library size is calculated using features that
are mapped to leaf nodes.
runDA(
TSE,
feature_on_row = TRUE,
assay = NULL,
option = c("glm", "glmQL"),
design = NULL,
contrast = NULL,
filter_min_count = 10,
filter_min_total_count = 15,
filter_large_n = 10,
filter_min_prop = 0.7,
normalize = TRUE,
normalize_method = "TMM",
group_column = "group",
design_terms = "group",
...
)
A TreeSummarizedExperiment
object.
A logical scalar. If TRUE
(default),
features or entities (e.g. genes, OTUs) are in rows of the assays
tables, and samples are in columns; otherwise, it's the other way around.
A numeric index or assay name to specify which assay from
assays
is used for analysis.
Either "glm"
or "glmQL"
. If "glm"
,
glmFit
and glmLRT
are used;
otherwise, glmQLFit
and
glmQLFTest
are used. Details about the difference
between two options are in the help page of
glmQLFit
.
A numeric design matrix. If NULL
, all columns of
the sample annotation will be used to create the design matrix.
A numeric vector specifying one contrast of
the linear model coefficients to be tested equal to zero. Its length
must equal to the number of columns of design. If NULL
, the last
coefficient will be tested equal to zero.
A numeric value, passed to min.count of
filterByExpr
.
A numeric value, passed to
min.total.count of filterByExpr
.
A numeric value, passed to large.n of
filterByExpr
.
A numeric value, passed to min.prop of
filterByExpr
.
A logical scalar indicating whether to estimate
normalization factors (using calcNormFactors
).
Normalization method to be used. See
calcNormFactors
for more details.
The name of the column in the sample annotation providing group labels for samples (currently not used).
The names of columns from the sample annotation that will be used to generate the design matrix. This is ignored if design is provided.
More arguments to pass to glmFit
(option = "glm"
or glmQLFit
(option = "glmQL"
).
A list with entries edgeR_results, tree, and nodes_drop.
The output of glmQLFTest
or
glmLRT
depending on the specified
option
.
The hierarchical structure of entities that was stored in the
input TSE
.
A vector storing the alias node labels of entities that are filtered before analysis due to low counts.
The experimental design is specified by a design matrix and provided
via the argument design
. More details about the calculation of
normalization factor could be found from
calcNormFactors
.
suppressPackageStartupMessages({
library(TreeSummarizedExperiment)
})
## Load example data set
lse <- readRDS(system.file("extdata", "da_sim_100_30_18de.rds",
package = "treeclimbR"))
## Aggregate counts on internal nodes
nodes <- showNode(tree = tinyTree, only.leaf = FALSE)
tse <- aggTSE(x = lse, rowLevel = nodes)
dd <- model.matrix(~ group, data = colData(tse))
out <- runDA(TSE = tse, feature_on_row = TRUE,
assay = 1, option = "glmQL",
design = dd, contrast = NULL,
normalize = TRUE, filter_min_count = 2)
names(out)
#> [1] "edgeR_results" "nodes_drop" "tree"
out$nodes_drop
#> [1] "alias_1" "alias_8" "alias_12" "alias_18"
edgeR::topTags(out$edgeR_results, sort.by = "PValue")
#> Coefficient: groupB
#> logFC logCPM F PValue FDR
#> alias_16 1.0495027 16.09379 25.6373886 1.389157e-06 2.083735e-05
#> alias_5 0.7612075 15.55706 8.6380737 3.891497e-03 2.918623e-02
#> alias_6 0.6590408 15.67131 7.4615895 7.177445e-03 3.588723e-02
#> alias_9 -0.1541389 16.97145 0.7171176 3.986523e-01 6.177916e-01
#> alias_15 -0.1537974 16.64917 0.6980515 4.049794e-01 6.177916e-01
#> alias_7 -0.1538470 16.69156 0.6583226 4.186426e-01 6.177916e-01
#> alias_10 -0.1539048 16.75636 0.6481161 4.222634e-01 6.177916e-01
#> alias_17 -0.1537167 16.60601 0.6174345 4.334392e-01 6.177916e-01
#> alias_4 -0.1534741 16.41854 0.5939829 4.422887e-01 6.177916e-01
#> alias_19 -0.1534741 16.43653 0.5422614 4.628306e-01 6.177916e-01