mgrowthctrl: Microbiome Growth Control

mGrowthCtrl is a software package for modeling, visualizing, and controlling microbiome growth dynamics. It provides tools to simulate microbial community behavior, fit predictive models to experimental data, and adjust community composition using control and optimization methods.

The package can be connected via an API to mGrowthDB, a curated database that provides microbiome growth data for model calibration, validation, and exploratory analysis.

Example Usage

from mgrowthctrl.models import CRModel, CRModelParams
from mgrowthctrl.models.base import ModelNames
from mgrowthctrl.utils.data import Dataloader

# Load experimental data, detecting names of consumer and resource columns:
data = Dataloader()
data.load_local_data(
    "examples/datasets/BT_WC_export.csv",
    x_selector="BT counts"
)
print(data.names)

# Initialize model parameters
params = CRModelParams.from_shapes(n=len(data.X_names), m=len(data.S_names))

# Create and fit the model
model = CRModel(names=data.names, params=params)
model.fit(df=data.df, time_col=data.time_col)

# Simulate trajectories and print the resulting data:
sim = model.simulate(data.y0, data.t)
print(sim)