micom will construct communities from a specification via a Pandas DataFrame. Here, the DataFrame needs at least two columns: "id" and "file" which specify the ID of the organism/tissue and a file containing the actual individual model.
To make more sense of that we can look at a small example. micom comes with a function that generates a simple example community specification consisting of several copies of a small E. coli model containing only the central carbon metabolism.
In [1]:
from micom.data import test_taxonomy
taxonomy = test_taxonomy()
taxonomy
Out[1]:
As we see this specification contains the required fields and some more information. In fact the specification may contain any number of additional information which will be saved along with the community model. One special example is "abundance" which we will get to know soon :)
In order to convert the specification in a community model we will use the Community class from micom which derives from the cobrapy Model class.
In [2]:
from micom import Community
com = Community(taxonomy)
print("Build a community with a total of {} reactions.".format(len(com.reactions)))
This includes the correctly scaled exchange reactions with the internal medium and initializes the external imports to the maximum found in all models. The original taxonomy is maintained in the com.taxonomy attribute.
Note that micom can figure out how to read a variety of different file types based on the extension. It curently supports:
.pickle for pickled models.xml or .gz for XML models.json for JSON models.mat for COBRAtoolbox models
In [3]:
com.taxonomy
Out[3]:
As you can notice we have gained a new column called abundance. This column quantifies the relative quantity of each individual in the community. Since we did not specify this in the original taxonomy micom assumes that all individuals are present in the same quantity.
The presented community here is pretty simplistic. For microbial communities micom includes a larger taxonomy for 773 microbial species from the AGORA paper. Here the "file" column only contains the base names for the files but you can easily prepend any path as demonstrated in the following:
In [4]:
from micom.data import agora
tax = agora.copy()
tax.file = "models/" + tax.file # assuming you have downloaded the AGORA models to the "models" folder
tax.head()
Out[4]: