cameo uses the model data structures defined by cobrapy, our favorite COnstraints-Based Reconstruction and Analysis tool for Python. cameo is thus 100% compatible with cobrapy. For efficiency reasons, however, cameo implements its own simulation methods that take advantage of a more advanced solver interface.
Constraint-based modeling is a powerful modeling framework for analyzing metabolism on the genome scale (McCloskey et al., 2013). For a model that encompasses $n$ reactions that involve $m$ metabolites, $\mathbf{S}$ is a matrix of dimension $m \times n$ that encodes the stoichiometry of the metabolic reaction system; it is usually referred to as stoichiometric matrix. Assuming that the system is in a steady state—the concentration of metabolites are constant—the system of flux-balances can be formulated as:
$$ \begin{align} \mathbf{S} \mathbf{v} = 0\,, \end{align} $$where $\mathbf{v}$ is the vector of flux rates. With the addition of a biologically meaningful objective, flux capacity constraints, information about the reversibility of reactions under physiological conditions, an optimization problem can be formulated that can easily be solved using linear programming.
For example, given the maximization of growth rate as one potential biological objective $v_{biomass}$ (i.e., the flux of an artificial reaction that consumes biomass components in empirically determined proportions), assuming that the cell is evolutionary optimized to achieve that objective, incorporating knowledge about reaction reversibility, uptake and secretion rates, and maximum flux capacities in the form of lower and uppers bounds ($\mathbf{v}_{lb}$ and $\mathbf{v}_{ub}$) on the flux variables $\mathbf{v}$, one can formulate and solve an optimization problem to identify an optimal set of flux rates using Flux Balance Analysis (FBA):
$$ \begin{align} Max ~ & ~ Z_{obj} = \mathbf{c}^{T} \mathbf{v}\\ \text{s.t.}~ & ~ \mathbf{S} \mathbf{v} = 0 \\ ~ & ~ \mathbf{v}_{lb} \leq \mathbf{v} \leq \mathbf{v}_{ub} \,. \end{align} $$
In [1]:
from cameo import load_model
model = load_model('iJO1366')
In cameo, flux balance analysis can be performed with the function fba
.
In [2]:
from cameo import fba
%time fba_result = fba(model)
Basically, fba
calls model.optimize()
and wraps the optimization solution in a FluxDistributionResult
object. The maximum objective values (corresponding to a maximum growth rate) can be obtained from result.objective_value
.
In [3]:
fba_result.data_frame
Out[3]:
Flux distributions can be visualized using escher :
In [4]:
fba_result.display_on_map("iJO1366.Central metabolism")
Parsimonious flux balance analysis (Lewis et al., 2010), a variant of FBA, performs FBA in in a first step to determine the maximum objective value $Z_{obj}$, fixes it in form of an additional model constraint ($\mathbf{c}^{T} \mathbf{v} \ge Z_{obj}$), and then minimizes the $L_1$ norm of $\mathbf{v}$. The assumption behind pFBA is that cells try to minimize flux magnitude as well in order to keep protein costs low.
$$ \begin{align} Max ~ & ~ \lvert \mathbf{v} \rvert\\ \text{s.t.}~ & ~ \mathbf{S} \mathbf{v} = 0 \\ & ~ \mathbf{c}^{T} \mathbf{v} \ge Z_{obj} \\ ~ & ~ \mathbf{v}_{lb} \leq \mathbf{v} \leq \mathbf{v}_{ub} \,. \end{align} $$In cameo, pFBA can be performed with the function pfba
.
In [5]:
from cameo import pfba
%time pfba_result = pfba(model)
The objective_function
value is $\lvert \mathbf{v} \rvert$ ...
In [6]:
pfba_result.objective_value
Out[6]:
... which is smaller than flux vector of the original FBA solution.
In [7]:
abs(fba_result.data_frame.flux).sum()
Out[7]:
Although PFBA and FBA can be used to simulate the effect of knockouts, other methods have been proven more valuable for that task: MOMA and ROOM. In cameo we implemented a linear version of MOMA.
Simulating knockouts:
In [8]:
model.reactions.PGI
Out[8]:
In [9]:
model.reactions.PGI.knock_out()
model.reactions.PGI
Out[9]:
In [10]:
%time fba_knockout_result = fba(model)
fba_knockout_result[model.reactions.BIOMASS_Ec_iJO1366_core_53p95M]
Out[10]:
In [11]:
%time pfba_knockout_result = pfba(model)
pfba_knockout_result[model.reactions.BIOMASS_Ec_iJO1366_core_53p95M]
Out[11]:
MOMA and ROOM rely on a reference (wild-type) flux distribution. We can use the one previously computed.
Parsimonious FBA references seem to produce better results using this methods
In [12]:
from cameo.flux_analysis.simulation import room, lmoma
In [13]:
%time lmoma_result = lmoma(model, reference=pfba_result.fluxes)
lmoma_result[model.reactions.BIOMASS_Ec_iJO1366_core_53p95M]
Out[13]:
ROOM is a difficult computational problem. If the bounds of the system are not large enough, it can take many hours to simulate. To improve the speed of the simulation and the chances of finding a solution, we increase the bounds.
In [14]:
for reaction in model.reactions:
if reaction.upper_bound == 1000:
reaction.upper_bound = 99999999
if reaction.lower_bound == -1000:
reaction.lower_bound = -99999999
In [15]:
%time room_result = room(model, reference=pfba_result.fluxes)
room_result[model.reactions.BIOMASS_Ec_iJO1366_core_53p95M]
Out[15]: