Building MicrobiomeStat from Matrix and Data.frame
Discover how to craft the MicrobiomeStat data object using matrices and data frames from your R environment or by importing data from external CSV files.
The basic MicrobiomeStat data object consists of the following components:
feature.tab (matrix): A matrix recording the measurements of detected features (like OTUs, ASVs, genes) with features as rows and samples as columns. Ensure row names are the names of the features, and column names match the samples.
meta.dat (data.frame): A data frame of the sample meta data, where rows correspond to samples, and columns denote annotations. Ensure the row names match the feature.tab columns. Tibbles are not permitted; use a standard R data frame.
feature.ann (matrix): An annotation matrix with features as rows and annotations as columns. Annotations are usually hierarchical such as the taxonomic annotations. Ensure row names match those in feature.tab.
tree (phylo, optional): Captures the evolutionary relationships among feautres. It's essential for specific beta-diversity calculations but isn't required for the majority of MicrobiomeStat analyses.
feature.agg.list (list, optional): Generated using the
mStat_aggregate_by_taxonomy
function, this list contains matrices of aggregated data based on the annotations specified in ”feature.ann", with each matrix's columns representing samples and rows representing the annotation level (e.g., Phylum, Genus).
Here is how to construct the MicrobiomeStat data object directly from matrix and data.frame:
1. Using Existing Data in R Environment
Starting from matrix and data.frame
Assuming we already have the count matrix and sample metadata:
Add Feature Annotation
To enrich the analysis, it's beneficial to add feature annotations. For this example, we add both taxonomic and functional classifications:
Add Phylogenetic Tree (Optional)
If a phylogenetic tree is available, directly assign:
Combine into MicrobiomeStat Object
Now, combine the components into a MicrobiomeStat object:
2. Using External CSV Data
To facilitate your understanding and to ease the process of setting up your data, we have provided sample CSV files that can be used as templates. By analyzing these sample files, you can structure your data similarly and ensure it's compatible with our tool.
For this demonstration, we'll import data from three external CSV files: feature_tab.csv
, meta_dat.csv
, and feature_ann.csv
.
Download Sample Data Files
You can download these files to understand the expected format:
If you want to use your own data, download these example files, examine their structure, and modify your data accordingly to match this format.
Import Data from CSV
Once you have the desired CSV files, you can proceed to import the data:
Combine into MicrobiomeStat Object
With the imported data, combine the components:
Add Phylogenetic Tree
If you have a phylogenetic tree that you would like to use, you can upload it:
With either the provided sample data or your own structured data, you now have a complete MicrobiomeStat data object ready for subsequent analysis and visualization.
Last updated