# Parsimonious flux balance analysis (pFBA)

Parsimonious flux balance analysis attempts to find a realistic flux of a model, by trying to minimize squared sum of all fluxes while maintaining the reached optimum. COBREXA.jl implements it in function parsimonious_flux_balance_analysis (accompanied by vector- and dictionary-returning variants parsimonious_flux_balance_analysis_vec and parsimonious_flux_balance_analysis_dict).

As usual, we demonstrate the functionality on the E. coli model:

!isfile("e_coli_core.xml") &&

using COBREXA, Tulip, Clarabel

model = load_model("e_coli_core.xml")
Metabolic model of type SBMLModel
sparse([8, 10, 21, 43, 50, 51, 8, 9, 6, 12  …  33, 66, 68, 72, 23, 26, 33, 72, 22, 33], [1, 1, 1, 1, 1, 1, 2, 2, 3, 3  …  93, 93, 93, 93, 94, 94, 94, 94, 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


Because the parsimonious objective is quadratic, we need a an optimizer capable of solving quadratic programs.

As the simplest choice, we can use Clarabel.jl, but any any JuMP.jl-supported optimizer that supports quadratic programming will work.

Note: Clarabel can be sensitive

We recommend reading the documentation of Clarabel before using it, since it may give inconsistent results depending on what settings you use. Commercial solvers like Gurobi, Mosek, CPLEX, etc. require less user engagement.

Running of basic pFBA is perfectly analogous to running of FBA and other analyses. We add several modifications that improve the solution (using functions silence, and change_optimizer_attribute), and fix the glucose exchange (using change_constraint) in order to get a more reasonable result:

fluxes = parsimonious_flux_balance_analysis_dict(
model,
Clarabel.Optimizer;
modifications = [
silence, # optionally silence the optimizer (Clarabel is very verbose by default)
change_constraint("R_EX_glc__D_e"; lb = -12, ub = -12), # fix glucose consumption rate
],
)
Dict{String, Float64} with 95 entries:
"R_EX_fum_e"    => -2.53704e-12
"R_ACONTb"      => 7.03277
"R_GLNS"        => 0.270339
"R_SUCOAS"      => -5.8921
"R_TPI"         => 8.90908
"R_EX_pi_e"     => -3.88931
"R_PPC"         => 3.02966
"R_O2t"         => 25.7859
"R_G6PDH2r"     => 6.11782
"R_TALA"        => 1.85013
"R_PPCK"        => 1.96794e-11
"R_EX_lac__D_e" => 4.69841e-12
"R_PGL"         => 6.11782
"R_H2Ot"        => -34.7096
"R_GLNabc"      => -1.56452e-12
"R_EX_co2_e"    => 27.0082
"R_EX_gln__L_e" => 3.11103e-13
"R_EX_nh4_e"    => -5.76498
"R_MALt2_2"     => 3.40177e-12
⋮               => ⋮

## Using different optimizers for linear and quadratic problems

It is quite useful to use specialized optimizers for specialized tasks in pFBA. In particular, one would usually require to get a precise solution from the linear programming part (where the precision is achievable), and trade off a little precision for vast improvements in computation time in the quadratic programming part.

In pFBA, we can use the modifications and qp_modifications parameters to switch and parametrize the solvers in the middle of the process, which allows us to implement precisely that improvement. We demonstrate the switching on a vector-returning variant of pFBA:

flux_vector = parsimonious_flux_balance_analysis_vec(
model,
modifications = [
change_constraint("R_EX_glc__D_e"; lb = -12, ub = -12),
change_optimizer_attribute("IPM_IterationsLimit", 500), # we may change Tulip-specific attributes here
],
qp_modifications = [
change_optimizer(Clarabel.Optimizer), # now switch to Clarabel (Tulip wouldn't be able to finish the computation)
silence, # and make it quiet.
],
)
95-element Vector{Float64}:
-2.0557470886659165e-11
-7.704845255172008e-12
-8.654298405918678e-12
7.032766647215865
7.032766647210638
-6.9204256886485275e-12
1.3106697575654615e-11
5.892098543464375
-3.473746859750386e-12
-1.0447431989907318e-11
⋮
2.7999413824311654e-11
4.6165102515054546e-11
5.892098550773122
-5.892098543462337
1.8501299332207397
4.22819437766466e-11
1.8501299332292878
1.4684623223235675
8.909080293442944