cameo reuses and extends model data structures defined by cobrapy (COnstraints-Based Reconstruction and Analysis tool for Python). So, in addition to following this quick start guide and other cameo tutorials, we encourage you to explore cobrapy's documentation as well.
In [1]:
from cameo import load_model
For example, load a genome-scale metabolic reconstruction of Escherichia coli.
In [2]:
model = load_model("iJO1366")
Models, reactions, metabolites, etc., return HTML when evaluated in Jupyter notebooks and can be easily inspected.
In [3]:
model
Out[3]:
In [4]:
solution = model.optimize()
A quick overview of the solution can be obtained in inspecting it.
In [5]:
solution
Out[5]:
A data frame representation of the solution is accessible via solution.to_frame()
.
In [6]:
solution.to_frame()
Out[6]:
Data frames make it very easy to process results. For example, let's take a look at reactions with flux != 0
In [7]:
solution.to_frame().query('fluxes != 0')
Out[7]:
Objects—models, reactions, metabolites, genes—can easily be explored in the Jupyter notebook, taking advantage of tab completion. For example, place your cursor after the period in model.reactions.
and press the TAB key. A dialog will appear that allows you to navigate the list of reactions encoded in the model.
In [8]:
model.reactions.PGK # delete PGK, place your cursor after the period and press the TAB key.
Out[8]:
For example, you can access the E4PD (Erythrose 4-phosphate dehydrogenase) reaction in the model.
In [9]:
model.reactions.E4PD
Out[9]:
Be aware that, due to variable naming restrictions in Python, dot notation access to reactions (and other objects) might not work in some cases.
In [10]:
# model.reactions.12DGR120tipp # uncommenting and running this cell will produce a syntax error
In those cases you need to use the model.reactions.get_by_id
.
In [11]:
model.reactions.get_by_id('12DGR120tipp')
Out[11]:
Metabolites are accessible through model.metabolites
. For example, D-glucose in the cytosol compartment.
In [12]:
model.metabolites.glc__D_c
Out[12]:
And it is easy to find the associated reactions
In [13]:
model.metabolites.glc__D_c.reactions
Out[13]:
A list of the genes encoded in the model can be accessed via model.genes
.
In [14]:
model.genes[0:10]
Out[14]:
Other additional attributes can be accessed to explore the model. For example, exchange reactions that allow certain metabolites to enter or leave the model can be accessed through model.exchanges
.
In [15]:
model.exchanges[0:10]
Out[15]:
Or, the current medium can be accessed through model.medium
.
In [16]:
model.medium
Out[16]:
It is also possible to get a list of essential reactions ...
In [17]:
from cobra.flux_analysis import find_essential_reactions
list(find_essential_reactions(model))[0:10]
Out[17]:
... and essential genes.
In [18]:
from cobra.flux_analysis import find_essential_genes
list(find_essential_genes(model))[0:10]
Out[18]: