Skip to contents

This function, part of the MicrobiomeStat package, aggregates an OTU table by a specified taxonomy level. It checks for the consistency of row names between the OTU table and the taxonomy table and stops execution if any mismatches are found.

Usage

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

Arguments

data.obj

A list object in a format specific to MicrobiomeStat, which can include components such as feature.tab (matrix), feature.ann (matrix), meta.dat (data.frame), tree, and feature.agg.list (list). The data.obj can be converted from other formats using several functions from the MicrobiomeStat package, including: 'mStat_convert_DGEList_to_data_obj', 'mStat_convert_DESeqDataSet_to_data_obj', 'mStat_convert_phyloseq_to_data_obj', 'mStat_convert_SummarizedExperiment_to_data_obj', 'mStat_import_qiime2_as_data_obj', 'mStat_import_mothur_as_data_obj', 'mStat_import_dada2_as_data_obj', and 'mStat_import_biom_as_data_obj'. Alternatively, users can construct their own data.obj. Note that not all components of data.obj may be required for all functions in the MicrobiomeStat package.

feature.level

A character vector that specifies the taxonomy levels to aggregate by.

Value

A list that is the modified version of the input data object. It includes the original data object and an additional element, 'feature.agg.list', which is a list of aggregated OTU tables for each specified taxonomy level.

Details

The function first checks for the consistency of row names between the OTU table and the taxonomy table. If any mismatches are found, it displays a message and stops execution. If the row names are consistent, it merges the OTU table with the taxonomy table and aggregates the OTU table by the specified taxonomy level. The aggregation is done by summing the values for each sample at each taxonomy level. The aggregated OTU tables are added to the data object as a list named 'feature.agg.list'.

Author

Caffery(Chen) YANG

Examples

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

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

# Aggregate data object by taxonomy level
peerj32.obj <- mStat_aggregate_by_taxonomy(peerj32.obj, feature.level)
} # }