Skip to content

Repository files navigation

cobrapy-tutorial

A hands-on tutorial on constraint-based modeling of metabolism using cobrapy.

What is constraint-based modeling?

Constraint-based modeling (CBM) predicts what a metabolic network can do without needing to know enzyme kinetics — parameters that are simply not available at genome scale for most organisms. Instead of simulating reaction rates over time, CBM reconstructs a genome-scale network of all known metabolic reactions (a stoichiometric matrix S) and assumes the cell is at metabolic steady state: for every internal metabolite, production must equal consumption (S·v = 0, where v is the vector of reaction fluxes). Each flux is further bounded above and below, reflecting thermodynamics (reaction reversibility), enzyme capacity, or nutrient availability.

These constraints alone leave a whole space of feasible flux distributions, not a single answer. Flux Balance Analysis (FBA) picks one, by solving a linear program: maximize (or minimize) some objective — classically biomass production, as a proxy for growth rate — subject to those constraints. Because it's just a system of linear (in)equalities, FBA scales to genome-scale networks with thousands of reactions, and it is the workhorse this whole tutorial builds on. Its main limitation is also its main strength: many different flux distributions can achieve the same optimal objective value, which is exactly what Part 4 of this tutorial (FVA, pFBA) is about.

What is cobrapy?

cobrapy is the Python package for COBRA (COnstraint-Based Reconstruction and Analysis) — the family of methods described above. It lets you build and inspect metabolic models with plain Python objects (Model, Reaction, Metabolite, Gene), read/write standard genome-scale reconstructions (SBML files like data/iJO1366.xml), and run analyses such as FBA, FVA, pFBA, and gene/ reaction deletions, all backed by a linear programming solver under the hood. See Ebrahim, Lerman, Palsson & Hyduke (2013), COBRApy: COnstraints-Based Reconstruction and Analysis for Python, BMC Systems Biology 7:74 (DOI).

Learning goals

By the end of this tutorial you will be able to:

  • Build a small metabolic model from scratch with cobrapy's core objects (metabolites, reactions, genes/GPRs) and understand what a stoichiometric model actually consists of (Part 1).
  • Load a real genome-scale model (E. coli iJO1366), inspect it, and run FBA to predict growth rate and flux distributions under different growth conditions — aerobic/anaerobic, different carbon sources (Part 2).
  • Simulate in silico single-gene knockouts and evaluate essentiality predictions against real experimental data (Part 3).
  • Go beyond a single FBA solution: quantify solution-space flexibility with Flux Variability Analysis, find a more biologically plausible solution with parsimonious FBA, and uncover synthetic lethal gene pairs with double knockouts (Part 4).

Installation instructions for linux

  1. Create virtual environment virtualenv -p python3 venv/

  2. activate the virtual environment source venv/bin/activate

  3. Install requirements pip install -r requirements.txt

  4. Install jupyter kernel pip install ipykernel python -m ipykernel install --user --name=python3

  5. Run jupyter jupyter notebook

Do the tutorial without installations

Run the tutorial notebooks using: Binder

Short cuts for tutorials

Bibliography

See BIBLIOGRAPHY.md for the experimental papers behind the predictions made in each exercise.

About

A tutorial on cobrapy

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages