
Aggregate Feature Table by Taxonomy Level (Low-Level Interface)
Source:R/mStat_aggregate_by_taxonomy2.R
mStat_aggregate_by_taxonomy2.RdA lower-level interface for taxonomy aggregation that works directly with feature and annotation matrices, without requiring a MicrobiomeStat data object.
Arguments
- feature.tab
Feature table (matrix or data.frame) with taxa as rows and samples as columns.
- feature.ann
Taxonomy annotation table (matrix or data.frame) with taxa as rows and taxonomy levels as columns.
- feature.level
Character string specifying the taxonomy level to aggregate by. Must match a column name in feature.ann. Supports only a single level; for multiple levels, call this function multiple times or use
mStat_aggregate_by_taxonomy.
Value
Aggregated feature table as a matrix with taxonomy groups as rows and samples as columns. The original sample order is preserved.
Details
This function provides direct access to the taxonomy aggregation algorithm without the data object wrapper. It is useful when:
You have separate feature and annotation tables
You want to aggregate a single level without modifying a data object
You are building custom analysis pipelines
The function performs an inner join between feature.tab and feature.ann, so only features present in both tables will be included in the output. NA taxonomy values are replaced with "Unclassified".
See also
mStat_aggregate_by_taxonomy for the higher-level interface
that works with MicrobiomeStat data objects and supports multiple levels.
Examples
if (FALSE) { # \dontrun{
data(peerj32.obj)
# Aggregate to Family level
family_table <- mStat_aggregate_by_taxonomy2(
feature.tab = peerj32.obj$feature.tab,
feature.ann = peerj32.obj$feature.ann,
feature.level = "Family"
)
# Aggregate to multiple levels separately
phylum_table <- mStat_aggregate_by_taxonomy2(
peerj32.obj$feature.tab, peerj32.obj$feature.ann, "Phylum"
)
genus_table <- mStat_aggregate_by_taxonomy2(
peerj32.obj$feature.tab, peerj32.obj$feature.ann, "Genus"
)
} # }