> 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/incorporating-deseqdataset-into-microbiomestat.md).

# Converting DESeqDataSet into MicrobiomeStat

A guide on converting DESeqDataSet data format into the MicrobiomeStat format.

This guide provides the recipe for converting the DESeqDataSet format to MicrobiomeStat format.

To begin, let's inspect the initial structure of our DESeqDataSet data:

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2FISXMNrOXaaaU8HklmL61%2FScreenshot%202023-10-10%20at%2014.56.23.png?alt=media&amp;token=05a258ec-e84e-4b90-8787-961a5eae6300" alt=""><figcaption><p>Initial structure of the DESeqDataSet data.</p></figcaption></figure>

Proceed with the steps below to conduct the conversion:

```r
# Example Code (replace with your real dataset!)
# Load necessary packages
 library(airway)
 library(DESeq2)

# Load dataset
 data("airway")
 dds <- DESeqDataSet(airway, design = ~ cell + dex)

# Convert DESeqDataSet to MicrobiomeStat data object
 data.obj <- mStat_convert_DESeqDataSet_to_data_obj(dds)
```

Upon conversion, the data structure will be transformed as follows:

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2F03CpHx1bvsgnoYBzxWMB%2FScreenshot%202023-10-10%20at%2014.57.15.png?alt=media&amp;token=3b931785-6097-4592-9338-988aa5be5958" alt=""><figcaption><p>Structure of the MicrobiomeStat data object after importing DESeqDataSet data.</p></figcaption></figure>

The `mStat_convert_DESeqDataSet_to_data_obj` function facilitates the transition:

* **dds.obj**: The DESeqDataSet object slated for conversion.

After the conversion, the **MicrobiomeStat data object** consists of:

* **feature.tab**: A matrix containing count data.
* **meta.dat**: A data frame detailing the sample information.
* **feature.ann**: A matrix presenting feature annotations.

For data integrity and relevance, the function ensures only features with a sum > 0 from the counts data are retained.
