Flux balance analysis (FBA)
Here we use flux_balance_analysis
and several related functions to find an optimal flux in the E. coli "core" model. We will need the model, which we can download using download_model
:
using COBREXA
download_model(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
"e_coli_core.json",
"7bedec10576cfe935b19218dc881f3fb14f890a1871448fc19a9b4ee15b448d8",
)
"e_coli_core.json"
Additionally to COBREXA and the model format package, we will need a solver – let's use HiGHS here:
import JSONFBCModels
import HiGHS
model = load_model("e_coli_core.json")
JSONFBCModels.JSONFBCModel(#= 95 reactions, 72 metabolites =#)
Running a FBA
There are many possibilities on how to arrange the metabolic model into the optimization framework and how to actually solve it. The "usual" assumed one is captured in the default behavior of function flux_balance_analysis
:
solution = flux_balance_analysis(model, optimizer = HiGHS.Optimizer)
ConstraintTrees.Tree{Float64} with 4 elements:
:coupling => ConstraintTrees.Tree{Float64}(#= 0 elements =#)
:flux_stoichiometry => ConstraintTrees.Tree{Float64}(#= 72 elements =#)
:fluxes => ConstraintTrees.Tree{Float64}(#= 95 elements =#)
:objective => 0.873922
The result contains a tree of all optimized values in the model, including fluxes, the objective value, and possibly others (given by what the model contains).
We can use the dot notation to explore the solution, extracting e.g. the value of the objective:
solution.objective
0.8739215069684305
...or the value of the flux through the given reaction (note the solution is not unique in FBA):
solution.fluxes.PFK
7.477381962160285
After typing solution.
in the Julia REPL, one can press [tab] to quickly see what is in the next level of the tree. Unfortunately (due to type system limitations) this currently works only for the topmost level of the tree.
...or make a "table" of all fluxes through all reactions:
collect(solution.fluxes)
95-element Vector{Pair{Symbol, Union{Float64, ConstraintTrees.Tree{Float64}}}}:
:ACALD => 0.0
:ACALDt => 0.0
:ACKr => 0.0
:ACONTa => 6.007249575350331
:ACONTb => 6.007249575350331
:ACt2r => 0.0
:ADK1 => 0.0
:AKGDH => 5.064375661482091
:AKGt2r => 0.0
:ALCD2x => 0.0
⋮
:SUCCt2_2 => 0.0
:SUCCt3 => 0.0
:SUCDi => 5.064375661482091
:SUCOAS => -5.064375661482091
:TALA => 1.496983757261565
:THD2 => 0.0
:TKT1 => 1.496983757261565
:TKT2 => 1.1814980932459616
:TPI => 7.477381962160285
This page was generated using Literate.jl.