Skip to main content

Biological Stochastic Simulation of Single Cell Reactions and Parameter Estimation.

Project description

Bioscrape — Biological Stochastic Simulation of Single Cell Reactions and Parameter Estimation

Python toolbox to simulate, analyze, and learn biological system models

Build Status PyPI version status

  • Getting started with Bioscrape: Bioscrape Core

  • Bioscrape analysis features: Bioscrape Sensitivity Analysis

  • Parameter inference with Bioscrape: Bioscrape Inference

Bioscrape is a Systems Biology Markup Language (SBML) simulator written in Cython for speed and Python compatibility. It can be used for deterministic, stochastic, or single cell simulation and also has parameter inference capabilities.

Example 1: Simulating an SBML

Bioscrape allows for deterministic and stochastic simulation of SBML models:

from bioscrape.types import Model
# Load an SBML file repressilator.xml 
# (you can find this file in `examples/models` directory)
M = Model(sbml_filename = 'repressilator_sbml.xml')
# Simulate the model
from bioscrape.simulator import py_simulate_model
import numpy as np
tp = np.linspace(0,256,100)
result = py_simulate_model(timepoints=tp, Model=M, stochastic=True)
# Plot the simulation result (the result is a Pandas dataframe)
import matplotlib.pyplot as plt
plt.plot(tp, result['X'])

Example 2: Run Bayesian inference with Bioscrape

Bioscrape can be used to identify model parameters using experimental data. In the example below, we show the user-friendly plug-and-play nature of bioscrape inference. We load the data as a Pandas dataframe and the model as an SBML file. The Bayesian inference is implemented as a wrapper for Python emcee that implements Markov Chain Monte Carlo (MCMC) sampler. Bioscrape inference provides various features such as: multiple data conditions, multiple data trajectories, deterministic inference, automatic visualization of posteriors, convergence checking tools, built-in and customizable priors, and lots more!

from bioscrape.types import Model
import pandas as pd
from bioscrape.inference import py_inference

# Load an SBML model 
# (you can get this file in `inference examples/models/` directory)
M = Model(sbml_filename='toy_sbml_model.xml')

# Load experimental data 
# (you can find test data in `inference examples/data/` directory)
df = pd.read_csv('test_data.csv', delimiter = '\t', 
                 names = ['X','time'], skiprows = 1)

# Use built-in priors, 
# For 'd1': a Gaussian distribution of mean 0.2 and standard deviation of 20,
# while ensuring the parameter remains positive
# For 'k1': a Uniform distribution with minimum value 0 and maximum value 100

prior = {'d1' : ['gaussian', 0.2, 20, 'positive'], 'k1' : ['uniform', 0, 100]}

# Run Bayesian inference
sampler, pid = py_inference(Model = M, exp_data = df, measurements = ['X'], 
                            time_column = ['time'], nwalkers = 20, nsteps = 5500,
                            params_to_estimate = ['d1', 'k1'], prior = prior)
# A sampler object containing all samples is returned.
# The pid object consists of various utilities for further analysis.
# This will plot the resulting posterior parameter distributions as well.

All examples can be found in the examples, the inference examples, and the lineage examples folders. If you prefer to run the package without installing the package, please use the Google Colab links above. If you want a local installation for bioscrape (recommended for faster speeds), follow the steps below:

Installation

Install the latest version of Bioscrape::

$ pip install bioscrape

Please note that Bioscrape is a Cython extension module and requires a C++ compiler to be set up on your computer for installation.

Try online without installing, open self-explanatory jupyter notebooks with Google Colab (linked at the top of this README).

Further details about the installation process can be found in the Bioscrape wiki.

Bugs and Contributing to Bioscrape

Please report any bugs that you find here. Or, even better, fork the repository on GitHub, and create a pull request (PR). We welcome all changes, big or small, and we will help you make the PR if you are new to git (just ask on the issue). More details on contributing to bioscrape are available on the Contributing page.

Versions

Bioscrape versions:

  • 1.2.1 (latest stable release): To install run pip install bioscrape
  • 1.2.0 (tagged stable release): To install run pip install bioscrape==1.2.0
  • 1.0.4 (beta release): To install run pip install bioscrape==1.0.4

License

Released under the MIT License (see LICENSE)

Copyright (c) 2022, Biocircuits, California Institute of Technology. All rights reserved.

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

bioscrape-1.2.1.tar.gz (561.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bioscrape-1.2.1-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7mWindows x86-64

File details

Details for the file bioscrape-1.2.1.tar.gz.

File metadata

  • Download URL: bioscrape-1.2.1.tar.gz
  • Upload date:
  • Size: 561.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/67.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for bioscrape-1.2.1.tar.gz
Algorithm Hash digest
SHA256 4835f947e46277e916c99538c05d3b922e84076ba482338468c76611f8fcf656
MD5 0bbb7a5ec12e3fcf7efef4b17db4af57
BLAKE2b-256 38984ba083b3b2e349c2043af33b8de46922572bf8db8cdb16fc70d633701f29

See more details on using hashes here.

File details

Details for the file bioscrape-1.2.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: bioscrape-1.2.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/67.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for bioscrape-1.2.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 98c5bf27d8830faefc68d69f3c3903bbff239e48f90e16996216372134c70c31
MD5 bdf0a31496df7d4aa1e558799962c2f8
BLAKE2b-256 f3d688e220bd59d5c5c2980faada66cb02e4ff82450a9ba6cc00d52e530488a7

See more details on using hashes here.

Supported by

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