I am writing this article as a guide for anyone who wants to start working on modeling and analysis of biological systems. The topics include but are not limited to creating mathematical models for biological systems, running simulations, accessing public repositories of biological models, and some advanced mathematical modeling discussions.
If you are a mathematician, control theorist, engineer interested in applying your skills to biological systems that inspire you - this is definitely an article for you.
If you are a bioengineer/biologist working on experiments but want to use mathematical models to improve analysis and understanding of your systems - this article could be helpful to you as well.
The article is right here - you are reading it, but this guide is supposed to be an interactive guide. So, you can download a Jupyter notebook here and play around with it (right click the link and save it).
More information is available on a course webpage that I helped teach at Caltech in Spring 2020 - BE240
Before jumping right ahead with creating and analyzing models, it is important to get a grasp of a "language" in which biological models are written. This standardized language is called Systems Biology Markup Language (SBML).
As shown in the Figure above, SBML is a language which can be used to exchange your biological models in. If a lab or a set of users write models or develop tools compatible with SBML, then all of their tools and models can be easily accessed and used by the community all around the world. A one-line definition of SBML from the SBML official webpage concisely describes this:
Even the simplest SBML model file can contain hundreds of lines, full of various XML tags. The header looks like this:
<sbml xmlns="http://www.sbml.org/sbml/level2/version3" level="2" metaid="_153818" version="3">
<model id="BIOMD0000000012" metaid="_000001" name="Elowitz2000 - Repressilator">
You don't have to write your own SBML files by hand! - That's where various tools help you.
Model header:
Species:
Follow this link for detailed descriptions of various software tools that support SBML.
Models in SBML : A big curated model database : BioModels. An example model from this database at the end of this notebook.
python-libsbml
is the API to write/read SBML models using a script. Unless you are developing your own new software, you wouldn't need to learn about it in detail. Just knowing that the API exists and the software tools that are compatible with SBML use it is enough for a non-developer user. However, in case you are planning to develop your own software or change an existing one, you might need to learn about how this API functions. Here are a couple lines of introduction of this API. Assume that you have an object called model
. This is an instance of the Model class in libsbml, each model has an SBMLDocument
object associated to it as well that functions as a "holder" of the Model
object. For example: To
model.getParameter(6).setValue(1e3)
=> Changes the value of the 6th parameter in the list of parameters to 1e3.model.getSpecies('id').setInitialAmount(50)
=> Changes the initial condition of the species with identifier "id" to 50.and so on...
In my opinion, a good place to start working on your own SBML development project is by looking at the documentation for the Model
class in python-libsbml. Once you get a hang of how the objects work here, you should feel much more comfortable. The Documentation is available on this link. It is also worth mentioning that the SBML and the libsbml community is one of the most helpful and active software development community. So, if you face any issues with SBML or related tools, feel free to jump on their Google groups discussion forums!
COPASI - http://copasi.org/ - A commonly used GUI based simulator and modeling engine for biological models. Plenty of online resources available to learn this tool. Recommended for users who like a graphical user interface to create and analyze their models.
RoadRunner - http://libroadrunner.org/ - A deterministic simulation engine specifically designed for SBML models.
Bioscrape - https://github.com/biocircuits/bioscrape/ - (Personal bias warning) - A fast stochastic and deterministic simulator tool based on Python. I am a developer of this tool so I am biased towards using it ;). Next, I demonstrate how this can be used to simulate SBML models:
# Import bioscrape simulator and import_sbml from sbmlutil to import SBML files into bioscrape.
from bioscrape.sbmlutil import import_sbml
from bioscrape.simulator import py_simulate_model
# Import the SBML file : Usage : import_sbml('sbml_filename.xml'), returns bioscrape Model object
# (Make sure that the file path is correctly specified wherever the SBML file ending in .xml is present in your directory)
M_represillator = import_sbml('repressilator_sbml.xml', sbml_warnings = False)
#Simulate Deterministically and Stochastically
import numpy as np
timepoints = np.linspace(0,700,10000)
result_det = py_simulate_model(timepoints, Model = M_represillator)
result_stoch = py_simulate_model(timepoints, Model = M_represillator, stochastic = True)
# Import relevant settings and packages to create plots
import matplotlib.pyplot as plt
import matplotlib as mpl
color_list = ['r', 'k', 'b','g','y','m','c']
mpl.rc('axes', prop_cycle=(mpl.cycler('color', color_list) ))
mpl.rc('xtick', labelsize=16)
mpl.rc('ytick', labelsize=16)
plt.figure(figsize = (10, 4))
#Plot Results
for i in range(len(M_represillator.get_species_list())):
s = M_represillator.get_species_list()[i]
plt.plot(timepoints, result_det[s], color = color_list[i], label = "Deterministic "+s)
plt.plot(timepoints, result_stoch[s], ":", color = color_list[i], label = "Stochastic "+s)
plt.title('Repressilator Model')
plt.xlabel('Time', FontSize = 16)
plt.ylabel('Amount', FontSize = 16)
plt.legend()
plt.show()
Model
constructor. Usage : M = Model(sbml_filename = "sbml_filename.xml")