Skip to content

dFBA Benchmark: Clamped-Biomass Dynamic FBA

Code, data and analysis live in Examples/2_real_models/4_dfba_benchmark/.

This directory aims to compare how giFBA compared to dFBA, as giFBA is a steady state method for emergent metabolic interactions from dynamic FBA - when held at a constant relative abundance. This directory benchmarks several factors for the following purposes:

  • Defining when giFBA is analogous to dynamic FBA
  • Understanding what dFBA hyper-parameters best match giFBA
  • Benchmarking efficiency differences in giFBA vs dFBA

Layout

4_dfba_benchmark
 ┣ 4_*.ipynb                  Analysis notebooks
 ┣ process_results.py         Raw JSON (from HPC runs) -> processed CSVs
 ┣ benchmark_analysis_utils.py # Utils for seamlessly plotting and reviewing results
 ┣ vacc_scripts/              Cluster scripts that ran the simulations
 ┗ data/
   ┣ AH_BI/, N_orgs/          Processed tables (csv, pkl)
   ┗ raw/                     Zipped raw results

Requires plotly, seaborn, tol_colors and matplotlib on top of gifba.

Experiments

This directory was used to simulate multiple configurations:

  • AH BI only communities - This community showed a curious interaction so exploration was done as a baseline for the method before implementation on communities with more models. Models simulated using a glucose-limited media.
  • N_orgs comparing communities with 1-10 models to benchmark efficiency and identify dfba parameters which affect equivalence with giFBA.

Results

The simulations were run on the UVM VACC with the scripts in vacc_scripts/, which write one JSON file per run. Those results are zipped in data/raw/ (Benchmark_AH_BI.zip, Benchmark_N_orgs.zip); unzip them in place to reprocess (unzip data/raw/Benchmark_AH_BI.zip -d data/raw/). The unzipped folders are gitignored. The VACC scripts write to a relative Benchmark_* folder on the cluster, so their paths are not tied to this layout.

Each result stores the following information:

  • Number of organisms
  • List of Model Names of each GEM in the community
  • List of Relative abundances of each GEM in the community
  • y0_factor: Since media is stored as a flux, this defines how much each media component's concentration is scaled up/down from the original magnitude of flux - this only affects metabolites in the media, components not present in the base media remain 0. This hyperparameter was only implemented for the AH BI community.
  • y0_offset: This is a flat value used to offset the concentrations calculated. This amount is added to the media component's concentration only if it is present in the base media. This hyperparameter was only implemented for the AH BI community.
  • Sum_N_rxns: Sum of the length of all the reactions in the community (ignoring duplicates across organisms) as an analogue for the complexity of each community
  • Sum_N_mets: Same as the reactions, but summed across the metabolites
  • vmax and km: michaelis menten kinetics values. Each metabolite is assumed to have exactly these same identical constants.
  • solver_method: the chosen method for solving the dfba simulation, using scipy solve_ivp. May be either "BDF" or "RK45" to understand which solver may be faster.
  • early_stop_window and early_stop_tol: dfba is considered converged once the concentrations are linear over time. This is done by running a linear regression after each time step. The window defines the number of points used for the regressor. The stop tolerance defines the threshold for the sum of squared residuals in order to be considered sufficiently linear. When a model is considered linear, the dfba simulation is halted.
  • model_solver: generally listed as "glpk". This tracks what solver is used to solve each LP in the GEMs. "glpk" is slower, but used since gurobi implements limits on the number of parallel simulations allowed.
  • gifba_solve_time and dfba_solve_time: The wall clock time required to solve the respective simulation types. This is stored only after the simulation converges/completes.
  • gifba_pfba_calls and dfba_pfba_calls: The number of times pfba is solved (each technique simulates each organism at least 1 time per iteration/time step). This is a stronger display of efficiency compared to wall clock time, due to wall clock time's dependence on the computer
  • dfba_status: logs the current number of pfba calls while dfba is simulating. This is kept in case the method times out on the UVM VACC, then the number of calls can still be recorded and used - the wall clock time will simply be replaced with the timeout length in analyses (24 hrs)
  • error: this is in case a simulation fails for development purposes to see why it failed - other lines may be added in this case, but primarily for development only
  • status: this logs the status of the simulation for tracking where the simulations are at each time step. This will match dfba_status during dfba runs, but will state if params are loaded, models are loaded, if gifba was simulated, etc. Generally ignorable
  • gifba_fluxes & dfba_fluxes: a dataframe turned to a dict (for json compatibility) for the flux of each reaction in each microbe for the respective method. This is used to compare accuracy

Benchmark Analysis

process_results.py loads the raw JSON once and writes the processed tables to data/{AH_BI,N_orgs}/ (hyperparams_*.csv, model_names_*.csv, fluxes_*.pkl). Run it from the benchmark directory:

cd Examples/2_real_models/4_dfba_benchmark
python process_results.py                  # every experiment
python process_results.py --config AH_BI   # one experiment

The notebooks read those tables and save figures to Examples/figures/real_model_figs/dfba_benchmark/:

Set ACTIVE_CONFIG_NAME at the top of 4_1 to switch between experiments; the flux notebooks are one per experiment.

The aim of this subdirectory is to be able to use this data to inform how dfba and gifba compare answering a form of the question: "giFBA is a steady state method for estimating a dfba solution, but what kind of dfba simulation is it efficiently solving?"