Basic usage of CoreModel
and CoreModelCoupled
In this tutorial we will introduce COBREXA
's CoreModel
and CoreModelCoupled
. We will use E. coli's toy model to start with.
!isfile("e_coli_core.xml") &&
download("http://bigg.ucsd.edu/static/models/e_coli_core.xml", "e_coli_core.xml")
using COBREXA
Loading a CoreModel
model = load_model(CoreModel, "e_coli_core.xml") # we specifically want to load a CoreModel from the model file
Metabolic model of type CoreModel sparse([41, 23, 51, 67, 61, 65, 1, 7, 19, 28 … 72, 3, 8, 33, 57, 66, 31, 45, 46, 57], [1, 2, 2, 2, 3, 3, 4, 4, 4, 4 … 93, 94, 94, 94, 94, 94, 95, 95, 95, 95], [-1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0 … 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0], 72, 95) Number of reactions: 95 Number of metabolites: 72
Basic analysis on CoreModel
As before, for optimization based analysis we need to load an optimizer. Here we will use Tulip.jl
to optimize the linear programs of this tutorial. Refer to the constraint-based analysis basics tutorial if you are confused by any functions in this section.
All the normal analysis functions work on CoreModel
, due to it also having the same generic accessor interface as all the other model types.
using Tulip
dict_sol = flux_balance_analysis_dict(
model,
Tulip.Optimizer;
modifications = [
change_objective("R_BIOMASS_Ecoli_core_w_GAM"),
change_constraint("R_EX_glc__D_e"; lb = -12, ub = -12),
change_constraint("R_EX_o2_e"; lb = 0, ub = 0),
],
)
Dict{String, Float64} with 95 entries: "R_EX_fum_e" => -0.0 "R_ACONTb" => 0.294088 "R_TPI" => 11.7289 "R_SUCOAS" => -5.31298e-11 "R_GLNS" => 0.069699 "R_EX_pi_e" => -1.00274 "R_PPC" => 0.781108 "R_O2t" => -2.65279e-17 "R_G6PDH2r" => 4.23161e-9 "R_TALA" => -0.0487648 "R_PPCK" => 5.66094e-11 "R_EX_lac__D_e" => 1.86329e-10 "R_PGL" => 4.23161e-9 "R_H2Ot" => 8.2857 "R_GLNabc" => -0.0 "R_EX_co2_e" => -0.487021 "R_EX_gln__L_e" => -0.0 "R_EX_nh4_e" => -1.48633 "R_MALt2_2" => -0.0 ⋮ => ⋮
Structure of CoreModel
CoreModel
is a special COBREXA
type that is optimized for large scale analysis of large models. It stores data in a sparse format where possible.
fieldnames(CoreModel)
(:S, :b, :c, :xl, :xu, :rxns, :mets, :grrs)
model.S
72×95 SparseArrays.SparseMatrixCSC{Float64, Int64} with 360 stored entries: ⠀⠈⢀⠀⡀⠀⠀⠀⠀⡠⠂⠀⠀⠀⠀⠈⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⢀⠐⡀⠀⠀⠀⠀⠄ ⠀⠐⠀⠀⠀⠀⠀⠀⡠⠂⠀⠀⠀⠀⢰⠱⣀⠀⡄⢐⠀⠀⢀⠀⠀⠀⡂⠄⠔⠁⠰⠀⠠⠀⣆⠀⠄⢠⢀⠄ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠠⠀⠀⠐⠀⠀⠀⠀⠀⠀⢀⠀⠀⠐⠀⠂⠀⠀⠀⠄⠀⠐⠀⢁⠄⠀⠀⠀⠀⠀ ⠀⢀⠀⠐⡈⠀⡀⠀⠂⠀⣀⠀⠑⡈⢀⠀⠀⠀⠀⠀⡀⡠⠀⡀⠰⠁⠈⠂⠁⠀⠠⠀⠀⠂⡂⠀⠂⠂⠀⠀ ⠠⠀⠐⠀⠂⠀⠀⢀⠀⠀⠀⠀⠊⠀⡐⠊⠐⠀⠀⠀⠀⠀⠐⠀⠂⠀⠀⠐⠀⠀⠀⠀⠀⠁⠃⠠⠀⠁⠐⠀ ⠀⠠⠀⡀⠄⠀⠀⠂⠀⠀⠀⠠⠀⠠⠀⠀⠄⠀⠨⠀⠀⠀⠐⠀⠀⠄⢀⠀⠀⠀⠈⠀⠀⠀⠁⠄⠀⠀⠀⠀ ⠀⢐⠐⠀⠄⠀⡂⠀⢐⠀⠀⠀⠀⠂⢀⢀⠐⠂⡀⠈⠀⠀⠀⠂⠀⠈⠀⡀⡐⠀⢄⠀⢀⠀⡆⠀⡀⣀⡀⡐ ⠀⠈⠀⠀⠀⠀⠀⠐⢂⠀⢀⠀⠈⠀⠀⠀⠀⠀⠠⠀⠀⠠⠀⠀⠀⠈⠂⠀⠀⠀⠄⠐⠐⠀⠁⠀⠀⠑⠁⠀ ⠂⠠⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠠⠈⠀⠀⠀⠀⠀⠁⠀⠀⠠⠐⠀⠁⠈⠀⠁⢀⠀⠀⠀⠀⠀⠀⠀⠀⠌⠀ ⠀⠀⠂⢨⠀⡀⠀⠐⠁⠐⠀⠐⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠢⠒⠈⠐⠐⠁⠂⠀⠀⠀⠄⠓⠕⠂⠃⠁⠀⠐ ⠠⠀⠨⠀⠁⠤⠄⠀⠁⡄⠀⠂⠠⠄⢈⠌⠠⠄⠀⢀⠀⠀⠀⠄⠨⠀⡤⠀⢀⠀⢀⠠⠀⠁⡔⠨⠀⠈⠄⠀ ⠀⢀⢀⣀⠀⡠⡒⢀⢀⣀⠀⢀⣀⡀⢀⠀⢀⠀⡀⠀⡀⠀⠈⣀⠀⢀⣀⠀⡀⠀⢀⠁⢀⣀⣀⡀⡠⡀⡀⣀ ⠀⠄⠀⠀⠀⠀⠀⠀⠀⠂⠁⠀⠀⠀⠀⠀⠀⣠⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀ ⢀⠂⠀⠀⠂⠀⠈⠀⠐⠀⠀⠀⠁⠀⠀⠀⡀⠔⠑⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠢⠀⠀⡀⠂⠈⠀⠀⠀⠄ ⠀⠐⠀⠀⡂⠀⠂⠀⠀⠀⠒⠐⠄⠂⠐⠀⠘⡀⠀⠠⡂⠃⠀⠂⠄⠂⠀⠀⠀⠀⡀⠀⡀⠀⡂⠂⠀⠀⢀⠀
CoreModelCoupled
adds coupling constraints to CoreModel
CoreModelCoupled
extends CoreModel
by adding coupling constraints.
fieldnames(CoreModelCoupled)
(:lm, :C, :cl, :cu)
In short, coupling constraints can be used to ensure that fluxes scale with the growth rate (μ) of a model. This reduces the impact of biologically infeasible cycles from occurring. Here we will model coupling constraints by assuming that they have the form: -γ ≤ vᵢ/μ ≤ γ
, where γ
is the ratio between each individual flux (vᵢ) in the model and the growth rate.
gamma = 40 # arbitrary
nr = n_reactions(model) # number of reactions
biomass_index = first(indexin(["R_BIOMASS_Ecoli_core_w_GAM"], reactions(model)))
using LinearAlgebra, SparseArrays
Cf = sparse(1.0I, nr, nr)
Cf[:, biomass_index] .= -gamma
Cb = sparse(1.0I, nr, nr)
Cb[:, biomass_index] .= gamma
C = [Cf; Cb] # coupling constraint matrix
clb = spzeros(2 * nr)
clb[1:nr] .= -1000.0
cub = spzeros(2 * nr)
cub[nr+1:end] .= 1000
cmodel = CoreModelCoupled(model, C, clb, cub)
Metabolic model of type CoreModelCoupled sparse([41, 23, 51, 67, 61, 65, 1, 7, 19, 28 … 72, 3, 8, 33, 57, 66, 31, 45, 46, 57], [1, 2, 2, 2, 3, 3, 4, 4, 4, 4 … 93, 94, 94, 94, 94, 94, 95, 95, 95, 95], [-1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0 … 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0], 72, 95) Number of reactions: 95 Number of metabolites: 72
d = flux_balance_analysis_dict(model, Tulip.Optimizer)
d["R_BIOMASS_Ecoli_core_w_GAM"]
0.8739215022661532
dc = flux_balance_analysis_dict(cmodel, Tulip.Optimizer)
dc["R_BIOMASS_Ecoli_core_w_GAM"]
0.6655856992982556
This page was generated using Literate.jl.