Skip to main content

lightweight library that allows to automatically parse and convert SBML models into python models written end-to-end in JAX

Project description

SBMLtoODEjax

About

SBMLtoODEjax is a lightweight library that allows to automatically parse and convert SBML models into python models written end-to-end in JAX, a high-performance numerical computing library with automatic differentiation capabilities. SBMLtoODEjax is targeted at researchers that aim to incorporate SBML-specified ordinary differential equation (ODE) models into their python projects and machine learning pipelines, in order to perform efficient numerical simulation and optimization with only a few lines of code (by taking advantage of JAX’s core transformation features).

SBMLtoODEjax extends SBMLtoODEpy, a python library developed in 2019 for converting SBML files into python files written in Numpy/Scipy. The chosen conventions for the generated variables and modules are slightly different from the standard SBML conventions (used in the SBMLtoODEpy library) with the aim here to accommodate for more flexible manipulations while preserving JAX-like functional programming style.

In short, SBMLtoODEjax facilitates the re-use of biological network models and their manipulation in python projects while tailoring them to take advantage of JAX main features for efficient and parallel computations. For more details, check our 👀 Why use SBMLtoODEjax? and 🎨 Design Principles pages.

Documentation

The documentation is available at https://developmentalsystems.org/sbmltoodejax/. It provides details about SBMLtoODEjax’s main design principles, advantages and limitations, and the full API docs.

👉 The documentation includes various hands-on tutorials for:

  1. Loading and simulating models from BioModels website
  2. Running simulations in parallel for a batch of initial conditions
  3. Using gradient descent to optimize model parameters

Installation

The latest stable release of SBMLtoODEjax can be installed via pip:

pip install sbmltoodejax

Requires SBMLtoODEpy, JAX (cpu) and Equinox.

Quick Start

With only a few lines of python code, you can load and simulate existing SBML models. Below is an example code and output snapshot for reproducing simulation results of biomodel #10, from Kholodenko 2000’s paper.

import matplotlib.pyplot as plt
from sbmltoodejax.utils import load_biomodel

# load and simulate model 
model, _, _, _ = load_biomodel(10)
n_secs = 150*60
n_steps = int(n_secs / model.deltaT)
ys, ws, ts = model(n_steps)

# plot time course simulation as in original paper
y_indexes = model.modelstepfunc.y_indexes
plt.figure(figsize=(6, 4))
plt.plot(ts/60, ys[y_indexes["MAPK"]], color="lawngreen", label="MAPK")
plt.plot(ts/60, ys[y_indexes["MAPK_PP"]], color="blue", label="MAPK-PP")
plt.xlim([0,150])
plt.ylim([0,300])
plt.xlabel("Reaction time (mins)")
plt.ylabel("Concentration")
plt.legend()
plt.show()

biomodel #10 default simulation

Contributing

SBMLtoODEjax is in its early stage and any sort of contribution will be highly appreciated. To learn how you can get involved, please read our guide for contributing.

License

The SBMLtoODEjax project is licensed under the MIT license.

Acknowledgements

SBMLtoODEjax builds on:

  • SBMLtoODEpy's parsing and conversion of SBML files, by Steve M. Ruggiero and Ashlee N. Ford
  • JAX's composable transformations, by the Google team
  • Equinox's module abstraction, by Patrick Kidger
  • BasiCO's access the BioModels REST api, by the COPASI team

Our documentation was also inspired by the GPJax documentation, by Thomas Pinder and team.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbmltoodejax-0.3.1.tar.gz (16.8 kB view hashes)

Uploaded Source

Built Distribution

sbmltoodejax-0.3.1-py3-none-any.whl (15.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page