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:
- Loading and simulating models from BioModels website
- Running simulations in parallel for a batch of initial conditions
- 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()
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
Built Distribution
File details
Details for the file sbmltoodejax-0.3.1.tar.gz
.
File metadata
- Download URL: sbmltoodejax-0.3.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78007539b7de9e0283b00d2a72ae95f84d1ad5f2c6bf33aa268b2ec03edc00af |
|
MD5 | 332f92de7a82250a1891da10ae715cb9 |
|
BLAKE2b-256 | 3e7d20c814cdb3195fd3b88bb8cd27c9f6e2b90df2761015ac73c7149747b9c2 |
File details
Details for the file sbmltoodejax-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: sbmltoodejax-0.3.1-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f2d3639316244ae0c742215d09397e4c7c62793c8a0e7753620f7a3a18d62f |
|
MD5 | 88f871b0ef94ce101967a9c13bbffd78 |
|
BLAKE2b-256 | 1ae5b9310c2a229d9d2bd760dbf1acb96726d4f75a47c2b8a55f466703e08085 |