Flux Balance Analysis

Load a few packages and functions.


In [29]:
import pandas
pandas.options.display.max_rows = 12
import escher
from cameo import models, fba
from cameo.exceptions import Infeasible

Predict maximum growth rate and metabolic fluxes of wildtype E. coli.

First we load a model from the BiGG database (and make a copy of it).


In [2]:
model = models.bigg.e_coli_core.copy()

In [3]:
print(model.objective)


Maximize
1.0*BIOMASS_Ecoli_core_w_GAM - 1.0*BIOMASS_Ecoli_core_w_GAM_reverse_712e5

Run flux balance analysis.


In [4]:
result = fba(model)

The predicted growth rate is $0.87 \ h^{-1}$.


In [6]:
result.objective_value


Out[6]:
0.8739215069684306

Take a look at the predicted metabolic fluxes.


In [7]:
result.data_frame


Out[7]:
flux
ACALD 0.000000
ACALDt 0.000000
ACKr 0.000000
ACONTa 6.007250
ACONTb 6.007250
ACt2r 0.000000
... ...
SUCOAS -5.064376
TALA 1.496984
THD2 0.000000
TKT1 1.496984
TKT2 1.181498
TPI 7.477382

95 rows × 1 columns


In [8]:
result.data_frame.describe()


Out[8]:
flux
count 95.000000
mean 2.627753
std 10.698095
min -29.175827
25% 0.000000
50% 0.000000
75% 4.959985
max 45.514010

In [19]:
active_fluxes = result.data_frame[result.data_frame.flux != 0].sort_values(by='flux')
active_fluxes


Out[19]:
flux
H2Ot -29.175827
CO2t -22.809833
EX_o2_e -21.799493
PGK -16.023526
PGM -14.716140
EX_glc__D_e -10.000000
... ...
O2t 21.799493
EX_co2_e 22.809833
EX_h2o_e 29.175827
NADH16 38.534610
CYTBD 43.598985
ATPS4r 45.514010

48 rows × 1 columns


In [20]:
model.reactions.ATPS4r


Out[20]:
IdATPS4r
NameATP synthase (four protons for one ATP)
Stoichiometryadp_c + pi_c + 4.0 h_e <=> 3.0 h_c + atp_c + h2o_c
Lower bound-1000.000000
Upper bound1000.000000

In [35]:
import escher
import jupyter

In [32]:
escher.__version__


Out[32]:
'1.4.4'

In [37]:
!pip show jupyter


---
Metadata-Version: 2.0
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
Installer: pip
License: BSD
Location: /opt/conda/lib/python3.5/site-packages
Requires: nbconvert, qtconsole, notebook, ipywidgets, ipykernel, jupyter-console
Classifiers:
  Intended Audience :: Developers
  Intended Audience :: System Administrators
  Intended Audience :: Science/Research
  License :: OSI Approved :: BSD License
  Programming Language :: Python
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.3
  Programming Language :: Python :: 3.4
The directory '/home/jovyan/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

In [24]:
escher.Builder('e_coli_core.Core metabolism', reaction_data=active_fluxes.flux.to_dict()).display_in_notebook()


Out[24]:

In [25]:
result.display_on_map('e_coli_core.Core metabolism')


Exercise

  • Try a few different objectives.
  • Assess the effects of gene deletions.
    • Hint: a gene can be knocked out by running model.genes.get_by_id('<geneID>').knock_out() where needs to be replace with an actual gene identifier.

Solutions


In [31]:
gene_essentiality = {}
for gene in model.genes:
    mutant = model.copy()
    mutant.genes.get_by_id(gene.id).knock_out()
    try:
        print(gene, fba(mutant).objective_value)
        gene_essentiality[gene] = fba(mutant).objective_value
    except Infeasible:
        print(gene, 0)
        gene_essentiality[gene] = 0


b0351 0.8739215069684306
b1241 0.8739215069684306
s0001 0.21114065257211675
b1849 0.8739215069684306
b3115 0.8739215069684306
b2296 0.8739215069684306
b1276 0.8739215069684306
b0118 0.8739215069684306
b0474 0.8739215069684306
b0116 0.7823510529477393
b0726 0.858307408022689
b0727 0.858307408022689
b2587 0.8739215069684306
b0356 0.8739215069684306
b1478 0.8739215069684306
b3731 0.3742298749331099
b3733 0.3742298749331099
b3735 0.3742298749331099
b3739 0.8739215069684306
b3732 0.3742298749331099
b3737 0.3742298749331099
b3736 0.3742298749331099
b3738 0.3742298749331099
b3734 0.3742298749331099
b0720 6.871561491399276e-32
b0979 0.8739215069684306
b0978 0.8739215069684306
b0733 0.8739215069684306
b0734 0.8739215069684306
b2975 0.8739215069684306
b3603 0.8739215069684306
b2779 5.794860387693435e-18
b2925 0.8739215069684306
b1773 0.8739215069684306
b2097 0.8739215069684306
b3925 0.8739215069684306
b4232 0.8739215069684306
b0904 0.8739215069684306
b2492 0.8739215069684306
b4151 0.8739215069684306
b4154 0.8739215069684306
b4152 0.8739215069684306
b4153 0.8739215069684306
b1817 0.8739215069684306
b2415 0
b1818 0.8739215069684306
b1819 0.8739215069684306
b2416 0
b4122 0.8739215069684306
b1612 0.8739215069684306
b1611 0.8739215069684306
b3528 0.8739215069684306
b1852 0.8638133095040006
b1779 2.817340211473703e-30
b1101 0.8739215069684306
b1621 0.8739215069684306
b2417 0.8739215069684306
b3870 0.8739215069684306
b1297 0.8739215069684306
b0810 0.8739215069684306
b0809 0.8739215069684306
b0811 0.8739215069684306
b1761 0.8513885233462087
b1524 0.8739215069684306
b1812 0.8739215069684306
b0485 0.8739215069684306
b3213 0.8739215069684306
b3212 0.8739215069684306
b4077 0.8739215069684306
b2029 0.8638133095040006
b0875 0.8739215069684306
b1136 1.2368810684518696e-30
b4015 0.8739215069684306
b2133 0.8739215069684306
b1380 0.8739215069684306
b4014 0.8739215069684306
b2976 0.8739215069684306
b3236 0.8258192905969889
b1479 0.8739215069684306
b2463 0.8739215069684306
b2279 0.21166294973531039
b2282 0.21166294973531039
b2284 0.21166294973531039
b2287 0.21166294973531039
b2276 0.21166294973531039
b2278 0.21166294973531039
b2288 0.21166294973531039
b2285 0.21166294973531039
b2280 0.21166294973531039
b2281 0.21166294973531039
b2283 0.21166294973531039
b2286 0.21166294973531039
b2277 0.21166294973531039
b1602 0.8739215069684306
b3962 0.8739215069684306
b1603 0.8739215069684306
b0451 0.8739215069684306
b0114 0.7966959254309568
b0115 0.7966959254309568
b3916 0.8739215069684306
b1723 0.8739215069684306
b3114 0.8739215069684306
b3951 0.8739215069684306
b0902 0.8739215069684306
b2579 0.8739215069684306
b0903 0.8739215069684306
b3952 0.8739215069684306
b4025 0.8631595522084183
b2926 3.152630951113317e-18
b0767 0.8638133095040006
b3612 0.8739215069684306
b4395 0.8739215069684306
b0755 0.8739215069684306
b2987 0.8739215069684306
b3493 0.8739215069684306
b3956 0.8707448062160253
b3403 0.8739215069684306
b1702 0.8739215069684306
b2297 0.8739215069684306
b2458 0.8739215069684306
b1676 0.8739215069684306
b1854 0.8739215069684306
b4301 0.8739215069684306
b3386 0.8739215069684306
b2914 0.8739215069684306
b4090 0.8739215069684306
b0722 0.8142975075325306
b0724 0.8142975075325306
b0723 0.8142975075325306
b0721 0.8142975075325306
b0729 0.858307408022689
b0728 0.858307408022689
b0008 0.8739215069684306
b2464 0.8739215069684306
b2935 0.8739215069684306
b2465 0.8739215069684306
b3919 0.7040369478590238

In [ ]: