DOI: 10.18419/darus-5539
title: Kinetic modeling of enzymatic cephalexin synthesis with neural ODEs and surrogate-accelerated Bayesian inference

description: &lt;p&gt;α-Amino ester hydrolases (AEHs) offer a promising route to the stereoselective synthesis of β-lactams such as cephalexin. However, published kinetic studies have encountered difficulty when extended beyond fitting of the data, indicating practical non-identifiability of the underlying kinetic models. Here, we address this issue using Bayesian inference combined with a reaction-consistent neural ODE surrogate that substantially accelerates parameter estimation. This framework enables efficient development of complex enzyme kinetic models even on limited hardware while providing rigorous uncertainty quantification of all parameters. To account for batch-dependent differences in active enzyme concentration, it was treated as a free parameter in each time series. Using this approach, the number of kinetic parameters was reduced from 12 to 9, and a useful kinetic model was obtained which is identifiable, mechanistically consistent, and predictive even under high substrate conditions.&lt;/p&gt;
&lt;h2 id="available-models"&gt;Available Models&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;models/model_04.json&lt;/code&gt;: The most comprehensive 12-parameter model including all major reaction pathways, competitive inhibition, substrate inhibition, and detailed enzyme regulation mechanisms. This model provides the most biologically detailed description but requires the most parameters to be estimated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;models/model_06.json&lt;/code&gt;: A streamlined 9-parameter model that simplifies some regulatory interactions while maintaining core kinetic behavior. This represents a good compromise between detail and parameter identifiability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;models/model_07.json&lt;/code&gt;: An intermediate 10-parameter model that includes additional regulatory terms compared to Model 06, capturing more complex enzyme behavior under varying substrate conditions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;models/model_08.json&lt;/code&gt;: An optimized 9-parameter model that balances predictive accuracy with parameter parsimony. This model was developed through systematic model reduction to retain essential kinetic features while minimizing parameter uncertainty.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;models/model_04_no_e0.json&lt;/code&gt;: Identical to Model 04 but with fixed enzyme concentration (E₀) rather than estimating it from data. Use this when enzyme concentration is known or measured separately.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;models/model_08_no_e0.json&lt;/code&gt;: Identical to Model 08 but with fixed enzyme concentration. This provides a direct comparison of modeling approaches with and without enzyme concentration estimation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="model-file-structure-and-components"&gt;Model File Structure and Components&lt;/h3&gt;
&lt;p&gt;Each model file (JSON format) contains a complete mathematical description of the kinetic system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Species definitions&lt;/strong&gt;: Lists all chemical species with their names and symbolic identifiers used in equations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Constants&lt;/strong&gt;: Fixed parameters like enzyme concentration (p0) that may be estimated or held constant&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ODEs&lt;/strong&gt;: The system of ordinary differential equations describing how each species concentration changes over time. These equations encode the reaction kinetics and mass balances.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parameters&lt;/strong&gt;: Adjustable kinetic parameters (rate constants, binding affinities, inhibition constants) with their prior distributions for Bayesian inference&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Algebraic assignments&lt;/strong&gt;: Complex mathematical expressions that define reaction rates, enzyme-substrate complexes, and regulatory terms as functions of the parameters and species concentrations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The models use symbolic mathematics where enzyme-substrate complexes and reaction rates are expressed algebraically, making them both interpretable and computationally efficient.&lt;/p&gt;
&lt;h2 id="system-requirements"&gt;System Requirements&lt;/h2&gt;
&lt;h2 id="software-dependencies"&gt;Software Dependencies&lt;/h2&gt;
&lt;p&gt;The analysis pipeline requires several specialized Python packages for scientific computing, probabilistic programming, and machine learning:&lt;/p&gt;
&lt;div class="sourceCode" id="cb1"&gt;&lt;pre
class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;pip&lt;/span&gt; install catalax&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="hardware-requirements"&gt;Hardware Requirements&lt;/h3&gt;
&lt;p&gt;The computational analysis is moderately demanding due to Bayesian MCMC sampling and neural network training:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CPU&lt;/strong&gt;: Multi-core processor (recommended: 12+ cores) - MCMC chains run in parallel across available cores for efficient sampling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RAM&lt;/strong&gt;: 16GB minimum, 32GB recommended - Memory requirements peak during MCMC sampling when storing large arrays of posterior samples&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="operating-system-and-python-version"&gt;Operating System and Python Version&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Supported OS&lt;/strong&gt;: Linux or macOS (primary testing on macOS)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python version&lt;/strong&gt;: 3.10 or higher required for compatibility with JAX and NumPyro&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shell&lt;/strong&gt;: Bash-compatible shell for running analysis scripts&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="how-to-reproduce"&gt;How to Reproduce&lt;/h2&gt;
&lt;h3 id="quick-start"&gt;Quick Start&lt;/h3&gt;
&lt;ol type="1"&gt;
&lt;li&gt;&lt;strong&gt;Install dependencies&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="sourceCode" id="cb2"&gt;&lt;pre
class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;pip&lt;/span&gt; install catalax&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start="2" type="1"&gt;
&lt;li&gt;&lt;strong&gt;Train the neural ODE surrogate&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="sourceCode" id="cb3"&gt;&lt;pre
class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb3-1"&gt;&lt;a href="#cb3-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;jupyter&lt;/span&gt; notebook TrainNeuralODE.ipynb&lt;/span&gt;
&lt;span id="cb3-2"&gt;&lt;a href="#cb3-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# Run all cells to create trained/rateflowode.eqx&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start="3" type="1"&gt;
&lt;li&gt;&lt;strong&gt;Run the complete analysis&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="sourceCode" id="cb4"&gt;&lt;pre
class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb4-1"&gt;&lt;a href="#cb4-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;export&lt;/span&gt; &lt;span class="va"&gt;XLA_FLAGS&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="st"&gt;&quot;--xla_force_host_platform_device_count=12&quot;&lt;/span&gt; &lt;span class="co"&gt;# Adjust number for your CPU cores&lt;/span&gt;&lt;/span&gt;
&lt;span id="cb4-2"&gt;&lt;a href="#cb4-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="fu"&gt;chmod&lt;/span&gt; +x fit_all.sh&lt;/span&gt;
&lt;span id="cb4-3"&gt;&lt;a href="#cb4-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;./fit_all.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="what-this-does"&gt;What This Does&lt;/h3&gt;
&lt;p&gt;The analysis pipeline:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Uses Bayesian inference (MCMC) to estimate kinetic parameters with uncertainty quantification&lt;/li&gt;
&lt;li&gt;Compares multiple model complexities (Models 04, 06, 07, 08)&lt;/li&gt;
&lt;li&gt;Treats enzyme concentration as a free parameter in each experiment&lt;/li&gt;
&lt;li&gt;Generates diagnostic plots and statistical summaries&lt;/li&gt;
&lt;li&gt;Saves all results to the &lt;code&gt;results/&lt;/code&gt; directory&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="individual-model-analysis"&gt;Individual Model Analysis&lt;/h3&gt;
&lt;p&gt;To analyze just one model:&lt;/p&gt;
&lt;div class="sourceCode" id="cb5"&gt;&lt;pre
class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb5-1"&gt;&lt;a href="#cb5-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;python&lt;/span&gt; run_inference.py models/model_08.json&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For analysis without enzyme concentration estimation:&lt;/p&gt;
&lt;div class="sourceCode" id="cb6"&gt;&lt;pre
class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb6-1"&gt;&lt;a href="#cb6-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;python&lt;/span&gt; run_inference.py models/model_08_no_e0.json &lt;span class="at"&gt;--no-e0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="outputs"&gt;Outputs&lt;/h2&gt;
&lt;h3 id="statistical-results-files"&gt;Statistical Results Files&lt;/h3&gt;
&lt;p&gt;These files contain the quantitative outcomes of the parameter estimation and model evaluation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{model_name}_summary.csv&lt;/code&gt;: Comprehensive MCMC parameter statistics including posterior means, standard deviations, 95% credible intervals, effective sample sizes (ESS), and R-hat convergence diagnostics. This file provides the key numerical results for parameter interpretation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{model_name}_samples.nc&lt;/code&gt;: Complete posterior distribution samples stored in NetCDF format. Contains 10,000 samples × 12 chains for each parameter, enabling detailed uncertainty analysis, prediction intervals, and further statistical computations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{model_name}_metrics.json&lt;/code&gt;: Model performance metrics including various error measures (L1, L2 losses), coefficient of determination (R²), Akaike Information Criterion (AIC), and Bayesian Information Criterion (BIC). These metrics allow comparison of model quality and complexity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{model_name}_mean_e0.npy&lt;/code&gt;: Estimated enzyme concentrations for each experimental measurement (when E₀ estimation is enabled). This file contains the posterior mean enzyme concentrations that can be used for subsequent analyses or experimental validation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="visualization-outputs-plots-subdirectory"&gt;Visualization Outputs
(&lt;code&gt;plots/&lt;/code&gt; subdirectory)&lt;/h3&gt;
&lt;p&gt;Diagnostic and result plots for model assessment and interpretation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Trace plots&lt;/strong&gt;: Time series of MCMC samples for each parameter, allowing visual inspection of mixing and convergence&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Corner plots&lt;/strong&gt;: Two-dimensional projections of parameter correlations and marginal distributions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Posterior distributions&lt;/strong&gt;: Histograms and density plots showing parameter uncertainty&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Model fit plots&lt;/strong&gt;: Comparison of model predictions vs. experimental data over time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MCMC diagnostics&lt;/strong&gt;: Monte Carlo Standard Error (MCSE) and Effective Sample Size (ESS) plots to assess sampling quality&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="fitted-model-files-models-subdirectory"&gt;Fitted Model Files (&lt;code&gt;models/&lt;/code&gt; subdirectory)&lt;/h3&gt;
&lt;p&gt;Updated model definitions with estimated parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{model_name}_bi.json&lt;/code&gt;: Model with parameters set to Bayesian posterior means. This represents the most probable parameter values given the data and priors, suitable for point predictions and further analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{model_name}_fitted.json&lt;/code&gt;: Model with parameters optimized using deterministic methods. These parameters minimize prediction errors and are typically used for the best-fit model predictions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
description: Catalax, 0.5.2
description: Python, 3.11