Getting started with modeling and analysis of biological systems

sbml_logo.jpg infographic_sbml.jpg



What is this "guide"?

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.

Who?

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.

Where?

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

Background

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).

Introduction to 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:

SBML is a "free and open interchange format for computer models of biological processes"

1. SBML uses the language of XML

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.

A quick peek into the SBML model:

Model header:repressilator1.jpg Species: repressilator2.jpg

2. Software that support SBML : More than 300!

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.

3. For software developers : SBML API for Python : python-libsbml.

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

  • set/change parameter values: model.getParameter(6).setValue(1e3) => Changes the value of the 6th parameter in the list of parameters to 1e3.
  • set initial conditions: 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!



Let's take an example : The famous "repressilator" system:

Here's what we will do

  • Find the SBML model for the "repressilator" as implemented in their paper [1].
  • Choose a simulator to run the SBML model.
  • Run the simulations, study the results.

Simulating a repressilator circuit (using its SBML model)

From biomodels SBML model repository, we can get the SBML model that accompanies the original repressilator paper [1].

Simulator options:

  1. 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.

  2. RoadRunner - http://libroadrunner.org/ - A deterministic simulation engine specifically designed for SBML models.

  3. 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:

Using bioscrape

We import the SBML file obtained into bioscrape to simulate it. For more information on how to simulate a bioscrape model, refer to this notebook.

The ODE model (from [1]):

repressilator_model.jpg In the SBML model: PX: lacI protein, PY: TetR protein, PZ: cI protein.

In [3]:
# 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)
In [7]:
# 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))
Out[7]:
<Figure size 720x288 with 0 Axes>
<Figure size 720x288 with 0 Axes>
In [8]:
#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()

More examples (try these out yourself! I will be happy to chat more about this):

  1. Try your own SBML model!
    • Similar to the repressilator example above, try creating your own SBML model and run a simulation.
    • If you are interested, use Tellurium or COPASI to create a SBML model, then simulate using bioscrape or compare simulations with other libraries.
    • Get a SBML model from one of the repositories online of your favorite paper, then simulate using bioscrape. For example, similar to the repressilator example above, BioModels repository consists SBML models of a
      • Toggle Switch
      • Influenza Viral Dynamics Spread
      • Circadian Oscillator
      • MAPK/ERK pathway
      • Other interesting examples available here.
    • Pro Tip : For bioscrape users, you can directly load an SBML model using the Modelconstructor. Usage : M = Model(sbml_filename = "sbml_filename.xml")