| agglomerate-methods {mia} | R Documentation |
agglomerateByRank can be used to sum up data based on the association
to certain taxonomic ranks given as rowData. Only available
taxonomicRanks can be used.
## S4 method for signature 'SummarizedExperiment' agglomerateByRank( x, rank = taxonomyRanks(x)[1], onRankOnly = FALSE, na.rm = FALSE, empty.fields = c(NA, "", " ", "\t", "-", "_"), ... ) ## S4 method for signature 'SingleCellExperiment' agglomerateByRank(x, ..., altexp = NULL, strip_altexp = TRUE) ## S4 method for signature 'TreeSummarizedExperiment' agglomerateByRank(x, ..., agglomerateTree = FALSE)
x |
a
|
rank |
a single character defining a taxonomic rank. Must be a value of
|
onRankOnly |
|
na.rm |
|
empty.fields |
a |
... |
arguments passed to |
altexp |
String or integer scalar specifying an alternative experiment containing the input data. |
strip_altexp |
|
agglomerateTree |
|
Based on the available taxonomic data and its structure setting
onRankOnly = TRUE has certain implications on the interpretability of
your results. If no loops exist (loops meaning two higher ranks containing
the same lower rank), the results should be comparable. you can check for
loops using detectLoop.
A taxonomically-agglomerated, optionally-pruned object of the same
class as x.
mergeRows,
sumCountsAcrossFeatures
data(GlobalPatterns)
# print the available taxonomic ranks
colnames(rowData(GlobalPatterns))
taxonomyRanks(GlobalPatterns)
# agglomerate at the Family taxonomic rank
x1 <- agglomerateByRank(GlobalPatterns, rank="Family")
## How many taxa before/after agglomeration?
nrow(GlobalPatterns)
nrow(x1)
# with agglomeration of the tree
x2 <- agglomerateByRank(GlobalPatterns, rank="Family",
agglomerateTree = TRUE)
nrow(x2) # same number of rows, but
rowTree(x1) # ... different
rowTree(x2) # ... tree
# removing empty labels by setting na.rm = TRUE
sum(is.na(rowData(GlobalPatterns)$Family))
## Look at enterotype dataset...
data(enterotype)
## print the available taxonomic ranks. Shows only 1 rank available
## not useful for agglomerateByRank
taxonomyRanks(enterotype)