Under the hood micom and q2-micom do have support for sample-specific media. In fact, that is micom only knows sample-specific media. If a media is not sample-speciic it is internally copied for each sample in the data set. To get an understanding of how to create a per-sample medium for q2-micom let's first have a look at the actual format. Media/diets in micom are just DataFrames with at least the columns metabolite
, reaction
and flux
.
import qiime2 as q2
import pandas as pd
arti = q2.Artifact.load("western_diet_gut.qza")
medium = arti.view(pd.DataFrame)
medium.head()
As you see you may also add additional columns to annotate your data. This is a global medium:
arti.type
For a per sample medium you will need an additional column called sample_id
. There should be a row for each metabolite that is consumed in each sample. So for instance let's assume we want to convert the current medium into sample-specific media for a normal and a diabetic sample that has higher glucose availability. For this we duplicate the medium, modify the glucose flux bound, add the sample IDs and concatenate the media.
diabetic = medium.copy()
diabetic.loc[diabetic.metabolite == "glc_m", "flux"] = 0.1
diabetic["sample_id"] = "diabetic"
medium["sample_id"] = "normal"
per_sample_medium = pd.concat([medium, diabetic])
per_sample_medium.head()
Not that the sample IDs have to correspond to your sample names used in your OTU table paased to qiime micom build
.
Now we can save the medium as a per=sample q2-micom medium:
new_arti = q2.Artifact.import_data("MicomMedium[PerSample]", per_sample_medium)
new_arti.save("my_media.qza")
And that's it 🎉 If you use this saved media with qiime micom grow
it will automatically apply the correct medium for each sample.