Control parameters

This tutorial demonstrates how to implement a discontinous switch in the value of a parameter during simulation of a DFBA model, corresponding to a switch (at \(t=7.7\) hours) from aerobic to anaerobic growth of Saccharomyces cerevisiae (based on the iND750 genome-scale model) with glucose as a limiting carbon substrate.

This example can be generalised to any number of discontinuous change points involving any number of parameters, implemented through use of the ControlParameter class.

[1]:
from os.path import dirname, join, pardir

from cobra.io import read_sbml_model

from dfba import ControlParameter, DfbaModel, ExchangeFlux, KineticVariable

1. Dfba model

[2]:
# DfbaModel instance initialized with cobra model
path_to_model = join(pardir, "sbml-models", "iND750.xml.gz")
fba_model = read_sbml_model(path_to_model)
fba_model.solver = "glpk"
dfba_model = DfbaModel(fba_model)

As in the previous tutorial, instantiate and add kinetic variables and exchange fluxes to model together with rhs expressions for the former.

[3]:
# instances of KineticVariable
V = KineticVariable("Volume")
X = KineticVariable("Biomass")
Gluc = KineticVariable("Glucose")
Eth = KineticVariable("Ethanol")
Glyc = KineticVariable("Glycerol")

# add kinetic variables to dfba_model
dfba_model.add_kinetic_variables([V, X, Gluc, Eth, Glyc])

# instances of ExchangeFlux
mu = ExchangeFlux("BIOMASS_SC4_bal")
v_G = ExchangeFlux("EX_glc__D_e")
v_E = ExchangeFlux("EX_etoh_e")
v_H = ExchangeFlux("EX_glyc_e")
v_O = ExchangeFlux("EX_o2_e")

# add exchange fluxes to dfba_model
dfba_model.add_exchange_fluxes([mu, v_G, v_E, v_H, v_O])

# add rhs expressions for kinetic variables in dfba_model

Vgmax = 8.5
Kg = 0.5
D = 0.044
Gin = 100.0
Vomax = 8.0

dfba_model.add_rhs_expression("Volume", D)
dfba_model.add_rhs_expression("Biomass", mu * X - D * X / V)
dfba_model.add_rhs_expression("Glucose", v_G * X + D * (Gin - Gluc) / V)
dfba_model.add_rhs_expression("Ethanol", v_E * X - D * Eth / V)
dfba_model.add_rhs_expression("Glycerol", v_H * X - D * Glyc / V)

2. The Control Parameter

Instantiate control parameters to appear in model. Here Oxy is defined as an object of the class ControlParameter and instantiated by providing a list of change points (ordered time points at which the control parameter value will change) and the corresponding values for each interval. The last command provides a symbolic expression for calculating the lower bound of an exchange flux in the model, which depends on this control parameter.

In this example, only one control parameter with one change point has been added to one exchange bound expression. In general, any number of control parameters with any number of change points can be added to any number of lower/upper bound expressions or kinetic variable rhs expressions. The only requirement is that a list containing any ControlParameter object that appears in a symbolic expression be supplied when the corresponding expression is added to the model.

[4]:
# add lower/upper bound expressions for exchange fluxes in dfba_model together
# with expression that must be non-negative for correct evaluation of bounds

Oxy = ControlParameter("Oxygen", [7.7], [Vomax, 0.0])
dfba_model.add_exchange_flux_lb(
    "EX_glc__D_e", Vgmax * (Gluc / (Kg + Gluc)), Gluc
)
dfba_model.add_exchange_flux_lb("EX_o2_e", Oxy, control_parameters=Oxy)

3. Add initial conditions to the model and launch the simulation.

[5]:
# add initial conditions for kinetic variables in dfba_model biomass (gDW/L),
# metabolites (g/L)
dfba_model.add_initial_conditions(
    {
        "Volume": 0.5,
        "Biomass": 0.05,
        "Glucose": 10.0,
        "Ethanol": 0.0,
        "Glycerol": 0.0,
    }
)

# simulate model across interval t = [0.0,16.0](hours) with outputs for plotting
# every 0.1h
concentrations, trajectories = dfba_model.simulate(0.0, 16.0, 0.1)

4. Plotting the results

Note: In order to plot the results, one of plotly or matplotlib should be used. See Visualization to install them along with dfba.

We will use plotly for this examples, but matplotlib could be as well used as in the previous example.

[6]:
from dfba.plot.plotly import *

import plotly.io as pio

# in plotly version 4, default version is different than in 3
pio.templates.default = "plotly_white"
[7]:
fig = plot_concentrations(concentrations)
fig.show()

Warning: As we have not specified any exchange fluxes to be annotated in the simulation, we won’t be able to plot any trajectories.