{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulate models\n", "\n", "**cameo** uses the model data structures defined by [cobrapy](https://opencobra.github.io/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." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Primer: Constraint-Based Modeling\n", "\n", "Constraint-based modeling is a powerful modeling framework for analyzing metabolism on the genome scale ([McCloskey et al., 2013](http://www.ncbi.nlm.nih.gov/pubmed/23632383)). 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:\n", "\n", "$$\n", "\\begin{align}\n", "\\mathbf{S} \\mathbf{v} = 0\\,,\n", "\\end{align}\n", "$$\n", "\n", "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](https://en.wikipedia.org/wiki/Linear_programming).\n", "\n", "\n", "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):\n", "\n", "$$\n", "\\begin{align}\n", " Max ~ & ~ Z_{obj} = \\mathbf{c}^{T} \\mathbf{v}\\\\\n", " \\text{s.t.}~ & ~ \\mathbf{S} \\mathbf{v} = 0 \\\\\n", " ~ & ~ \\mathbf{v}_{lb} \\leq \\mathbf{v} \\leq \\mathbf{v}_{ub} \\,.\n", "\\end{align}\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Flux Balance Analysis\n", "\n", "Load a model." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from cameo import load_model\n", "model = load_model('iJO1366')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In cameo, flux balance analysis can be performed with the function `fba`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 256 ms, sys: 6.4 ms, total: 262 ms\n", "Wall time: 283 ms\n" ] } ], "source": [ "from cameo import fba\n", "%time fba_result = fba(model)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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`." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | flux | \n", "
---|---|
12DGR120tipp | \n", "0.000000 | \n", "
12DGR140tipp | \n", "0.000000 | \n", "
12DGR141tipp | \n", "0.000000 | \n", "
12DGR160tipp | \n", "0.000000 | \n", "
12DGR161tipp | \n", "0.000000 | \n", "
12DGR180tipp | \n", "0.000000 | \n", "
12DGR181tipp | \n", "0.000000 | \n", "
12PPDRtex | \n", "0.000000 | \n", "
12PPDRtpp | \n", "0.000000 | \n", "
12PPDStex | \n", "0.000000 | \n", "
12PPDStpp | \n", "0.000000 | \n", "
14GLUCANabcpp | \n", "0.000000 | \n", "
14GLUCANtexi | \n", "0.000000 | \n", "
23CAMPtex | \n", "0.000000 | \n", "
23CCMPtex | \n", "0.000000 | \n", "
23CGMPtex | \n", "0.000000 | \n", "
23CUMPtex | \n", "0.000000 | \n", "
23DAPPAt2pp | \n", "0.000000 | \n", "
23DAPPAtex | \n", "0.000000 | \n", "
23PDE2pp | \n", "0.000000 | \n", "
23PDE4pp | \n", "0.000000 | \n", "
23PDE7pp | \n", "0.000000 | \n", "
23PDE9pp | \n", "0.000000 | \n", "
26DAHtex | \n", "0.000000 | \n", "
2AGPA120tipp | \n", "0.000000 | \n", "
2AGPA140tipp | \n", "0.000000 | \n", "
2AGPA141tipp | \n", "0.000000 | \n", "
2AGPA160tipp | \n", "0.000000 | \n", "
2AGPA161tipp | \n", "0.000000 | \n", "
2AGPA180tipp | \n", "0.000000 | \n", "
... | \n", "... | \n", "
VALTRS | \n", "0.000000 | \n", "
VALabcpp | \n", "0.000000 | \n", "
VALt2rpp | \n", "0.000000 | \n", "
VALtex | \n", "0.000000 | \n", "
VPAMTr | \n", "0.000000 | \n", "
WCOS | \n", "0.000000 | \n", "
X5PL3E | \n", "0.000000 | \n", "
XAND | \n", "0.000000 | \n", "
XANt2pp | \n", "0.000000 | \n", "
XANtex | \n", "0.000000 | \n", "
XANtpp | \n", "0.000000 | \n", "
XMPtex | \n", "0.000000 | \n", "
XPPT | \n", "0.000000 | \n", "
XTSNH | \n", "0.000000 | \n", "
XTSNt2rpp | \n", "0.000000 | \n", "
XTSNtex | \n", "0.000000 | \n", "
XYLI1 | \n", "0.000000 | \n", "
XYLI2 | \n", "0.000000 | \n", "
XYLK | \n", "0.000000 | \n", "
XYLK2 | \n", "0.000000 | \n", "
XYLUt2pp | \n", "0.000000 | \n", "
XYLUtex | \n", "0.000000 | \n", "
XYLabcpp | \n", "0.000000 | \n", "
XYLt2pp | \n", "0.000000 | \n", "
XYLtex | \n", "0.000000 | \n", "
ZN2abcpp | \n", "0.000000 | \n", "
ZN2t3pp | \n", "0.000000 | \n", "
ZN2tpp | \n", "0.000335 | \n", "
ZNabcpp | \n", "0.000000 | \n", "
Zn2tex | \n", "0.000335 | \n", "
2583 rows × 1 columns
\n", "Reaction identifier | PGI | \n", "
Name | Glucose-6-phosphate isomerase | \n", "
Memory address | \n", "0x011313e908 | \n", "
Stoichiometry | \n", "\n",
" g6p_c <=> f6p_c \n", "D-Glucose 6-phosphate <=> D-Fructose 6-phosphate \n", " | \n",
"
GPR | b4025 | \n", "
Lower bound | -1000.0 | \n", "
Upper bound | 1000.0 | \n", "
Reaction identifier | PGI | \n", "
Name | Glucose-6-phosphate isomerase | \n", "
Memory address | \n", "0x011313e908 | \n", "
Stoichiometry | \n", "\n",
" g6p_c --> f6p_c \n", "D-Glucose 6-phosphate --> D-Fructose 6-phosphate \n", " | \n",
"
GPR | b4025 | \n", "
Lower bound | 0 | \n", "
Upper bound | 0 | \n", "