Skip to contents

This function aggregates an OTU table by a specified taxonomy level. It checks for consistency between OTU and taxonomy tables before aggregation.

Usage

mStat_aggregate_by_taxonomy2(feature.tab, feature.ann, feature.level = NULL)

Arguments

feature.tab

OTU table as matrix or data.frame

feature.ann

Taxonomy table as matrix or data.frame

feature.level

Taxonomy level to aggregate by as character vector.

Value

Aggregated OTU table matrix.

Details

The function first checks that the row names of OTU and taxonomy tables match. If any mismatches are found, a message is displayed but the function continues. The OTU and taxonomy tables are joined by row names. The OTU table is then aggregated by summing abundance values for each sample at the specified taxonomy level. Rows with all zero values after aggregation are removed.

Examples

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

# Specify the taxonomy level
feature.level <- c("Family")

# Aggregate data object by taxonomy level
mStat_aggregate_by_taxonomy2(peerj32.obj$feature.tab, peerj32.obj$feature.ann, feature.level)
} # }