Skip to main content

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)

Metadata

Release files for cbmos 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cbmos 0.3.0
File Size Uploaded
cbmos-0.3.0.tar.gz 29.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cbmos 0.3.0
File Interpreter ABI Platform
cbmos-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / cbmos-0.3.0.tar.gz

Download URL cbmos-0.3.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b24d13c4b9f4275579c1b4a2670e981f2cde67f0412143849fd414e86bd2bad4
BLAKE2b-256 checksum
How to use checksums
d044f142df6d284d00c5f2ac78661fab3b994ea34182b881589ec926dd77d2bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / cbmos-0.3.0-py3-none-any.whl

Download URL cbmos-0.3.0-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31e220eaec24a36de6033829342f58e3edf1e1f3c6341fa8f9219f37592e1c30
BLAKE2b-256 checksum
How to use checksums
29279488f2017d94abfcd10afccc82ee08fbfd7778f90dafa4c2121eabc22526
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page