Skip to contents

Aggregates a feature table within a MicrobiomeStat data object by one or more specified taxonomy levels. The aggregated tables are stored in the `feature.agg.list` component of the data object.

Usage

mStat_aggregate_by_taxonomy(data.obj, feature.level = NULL)

Arguments

data.obj

A MicrobiomeStat data object (list) containing at minimum:

  • feature.tab: Feature table (matrix) with taxa as rows

  • feature.ann: Taxonomy annotation (matrix/data.frame)

feature.level

Character vector specifying one or more taxonomy levels to aggregate by (e.g., c("Phylum", "Family", "Genus")).

Value

The input data.obj with an added/updated `feature.agg.list` component containing aggregated feature tables for each specified taxonomy level.

Details

This function is the primary interface for taxonomy aggregation in MicrobiomeStat. It supports aggregating to multiple taxonomy levels in a single call, storing results in a named list for easy access.

The aggregation uses an inner join between feature.tab and feature.ann, meaning only features present in both tables will be included in the output. A message is displayed if any features are excluded due to mismatches.

See also

mStat_aggregate_by_taxonomy2 for a lower-level interface that works directly with matrices.

Author

Caffery(Chen) YANG

Examples

if (FALSE) { # \dontrun{
library(vegan)
data(peerj32.obj)

# Aggregate by multiple taxonomy levels
peerj32.obj <- mStat_aggregate_by_taxonomy(
  peerj32.obj,
  feature.level = c("Phylum", "Family", "Genus")
)

# Access aggregated tables
phylum_table <- peerj32.obj$feature.agg.list$Phylum
family_table <- peerj32.obj$feature.agg.list$Family
} # }