Skip to main content

A framework for numerical analysis of center-based cell models

Project description

CBMOS

CBMOS is a Python framework for the numerical analysis of center-based models. It focuses on flexibility and ease of use and is capable of simulating up to a few thousand cells within a few seconds, or even up to 10,000 cells if GPU support is available. CBMOS shines best for exploratory tasks and prototyping, for instance when one wants to compare different sets of parameters or solvers. At the moment, it implements most popular force functions, a few first and second-order explicit solvers, and even one implicit solver.

Installation

CBMOS is available on PyPI and can be installed through:

pip install cbmos

Getting Started

Initial condition

Setting up the initial condition of a simulation is very simple, all you need is create a list of cell objects. In this example we set up a Cartesian grid of 25 cells. Each cell will immediately divides after the simulation starts. This behavior is defined by the list of CellDivisionEvent objects. We then plot the current cell configuration using the basic plotting function provided in the utils module.

import numpy as np
import matplotlib.pyplot as plt

import cbmos
import cbmos.force_functions as ff
import cbmos.solvers.euler_forward as ef
import cbmos.cell as cl
import cbmos.utils as utils
import cbmos.events as events

n_x = 5
n_y = 5
coordinates = utils.generate_cartesian_coordinates(n_x, n_y)

sheet = [
    cl.ProliferatingCell(
        i, # Cell ID, must be unique to each cell
        [x,y], # Initial coordinates
        -6.0, # Birthtime, in this case 6 hours before the simulation starts
        True, # Whether or not the cell is proliferating
        lambda t: 6 + t # Function generating the next division time
    )
    for i, (x, y) in enumerate(coordinates)
]

event_list = [
    events.CellDivisionEvent(cell)
    for cell in sheet
]
utils.plot_2d_population(sheet)

png

Simulation

In this simulation, we use the Gls force and the Euler forward solver. The force function's parameters are given to the simulate function as a dictionary. Parameters can also be passed to the solver in the same way. This function returns a tuple containing the time points and a list of cells for each of these time points. If needed a detailed log of the division events can be displayed by setting the log level to debug.

# Initialize model
model = cbmos.CBModel(ff.Gls(), ef.solve_ivp, dimension=2)

dt = 0.01
t_data = np.arange(0, 4, dt)

t_data, history = model.simulate(
    sheet, # Initial cell configuration
    t_data, # Times at which the history is saved
    {"mu": 5.70, "s": 1.0, "rA": 1.5}, # Force parameters
    {'dt': dt}, # Solver parameters
    event_list=event_list
)
utils.plot_2d_population(history[-1])

png

Documentation

The package's documentation, as well as a few examples are available at somathias.github.io/cbmos/

Publications

  • Mathias, S., Coulier, A., Bouchnita, A. et al. Impact of Force Function Formulations on the Numerical Simulation of Centre-Based Models. Bull Math Biol 82, 132 (2020). DOI (tag exp-Mathias2020)
  • Mathias, S., Coulier, A. & Hellander, A. CBMOS: a GPU-enabled Python framework for the numerical study of center-based models. BMC Bioinformatics 23, 55 (2022). DOI (tag exp-Mathias2022)

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

cbmos-0.3.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

cbmos-0.3.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file cbmos-0.3.0.tar.gz.

File metadata

  • Download URL: cbmos-0.3.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for cbmos-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b24d13c4b9f4275579c1b4a2670e981f2cde67f0412143849fd414e86bd2bad4
MD5 4b1e90a2675fce8de57bc680d3af6cc9
BLAKE2b-256 d044f142df6d284d00c5f2ac78661fab3b994ea34182b881589ec926dd77d2bf

See more details on using hashes here.

File details

Details for the file cbmos-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cbmos-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for cbmos-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31e220eaec24a36de6033829342f58e3edf1e1f3c6341fa8f9219f37592e1c30
MD5 e88cd374a76dea81b7543db92ca4b4ed
BLAKE2b-256 29279488f2017d94abfcd10afccc82ee08fbfd7778f90dafa4c2121eabc22526

See more details on using hashes here.

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