> For the complete documentation index, see [llms.txt](https://www.microbiomestat.wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.microbiomestat.wiki/setting-up-microbiomestat-installation-and-data-preparation/laying-the-foundation-creating-the-microbiomestat-data-object/importing-data-from-qiime2-into-microbiomestat.md).

# Importing Data from QIIME2 into MicrobiomeStat

This guide provides a step-by-step method for importing QIIME2 data  into the MicrobiomeStat data object.

This guide details the process to import QIIME2 data into MicrobiomeStat's required data object.

The provided files represent essential QIIME2 artifacts and metadata required for microbiome data analysis:

{% file src="/files/kWruDwjYcJHHVq3kUHtC" %}
This artifact contains the feature table, which is a summary of the observed microbial features (e.g., OTUs, ASVs) across different samples. QIIME2 users typically recognize it as their primary count or abundance matrix.
{% endfile %}

{% file src="/files/WWk7dsImPbSK5XToIFv6" %}
This artifact holds taxonomic assignments for each microbial feature, allowing users to determine the classification of observed features at various taxonomic ranks (e.g., kingdom, phylum, class).
{% endfile %}

{% file src="/files/adgOjtz3TebDDzvSWgjX" %}
A tab-separated values (TSV) file detailing the metadata associated with each sample. Metadata might include sample conditions, treatments, or any other annotations pertinent to the study.
{% endfile %}

{% file src="/files/zPDnEziOpS5Xog9hKdiD" %}
A phylogenetic tree artifact representing the evolutionary relationships between microbial features. This tree is crucial for various phylogenetic diversity metrics and analyses within QIIME2.
{% endfile %}

```r
# Define paths to your QIIME2 files
# NOTE: Update these paths to point to the location of the files on your computer.
otuqza_file <- "path_to_your_directory/table.qza"
taxaqza_file <- "path_to_your_directory/taxonomy.qza"
sample_file <- "path_to_your_directory/sample-metadata.tsv"
treeqza_file <- "path_to_your_directory/tree.qza"

# Import QIIME2 data into a MicrobiomeStat data object
data.obj <- mStat_import_qiime2_as_data_obj(
    otu_qza = otuqza_file, 
    taxa_qza = taxaqza_file,
    sam_tab = sample_file, 
    tree_qza = treeqza_file
)
```

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2FfVSBbILUHt5jaffMdgiD%2FScreenshot%202023-10-10%20at%2011.35.49.png?alt=media&amp;token=06eea4c9-90a0-493c-89f1-122ac1030d00" alt=""><figcaption><p>This output showcases the data paths and structure of the converted <code>data_obj</code> from QIIME2 to MicrobiomeStat format. Displayed paths indicate the location of QIIME2 files on a local machine. The <code>str(data_obj)</code> function in R reveals the organized structure of the <code>data_obj</code> list, detailing its various components such as <code>feature.tab</code>, <code>meta.dat</code>, <code>feature.ann</code>, and the phylogenetic <code>tree</code>. Each component houses relevant microbiome data ready for analysis using MicrobiomeStat.</p></figcaption></figure>

The function `mStat_import_qiime2_as_data_obj` efficiently transforms QIIME2 datasets into the data format required by MicrobiomeStat. Here's a breakdown of the input parameters:

* **otu\_qza**: This file represents your feature table, containing the abundance data of microbial features across samples.
* **taxa\_qza** (Optional): This is the taxonomy assignment table which provides taxonomic classifications for the microbial features.
* **sam\_tab** (Optional): The sample metadata table offers details about the samples.
* **tree\_qza** (Optional): A phylogenetic tree depicting the evolutionary relationships of the microbial features.

Ensure that you have the correct file paths and all required dependencies installed before initiating the conversion process.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.microbiomestat.wiki/setting-up-microbiomestat-installation-and-data-preparation/laying-the-foundation-creating-the-microbiomestat-data-object/importing-data-from-qiime2-into-microbiomestat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
