Metadata-Version: 2.4
Name: mgrowthctrl
Version: 0.1.0
Summary: mgrowthctrl is a software package for modeling, visualization, and control of microbiome growth dynamics. It provides tools to simulate microbial community dynamics, fit predictive models to experimental data, and steer community composition using control and optimization methods.
Project-URL: Homepage, https://gitlab.com/ComputationalScience/mgrowthctrl
Project-URL: Documentation, https://mgrowthctrl.readthedocs.io/en/latest/
Project-URL: Issues, https://gitlab.com/ComputationalScience/mgrowthctrl/-/issues
Author-email: Indrah Thelaganathan <indrah2003@gmail.com>, Andrew Radev <andrey.radev@gmail.com>, Jiawei Li <pushup-prong-ashen@duck.com>, Lucas Boettcher <l.boettcher@fs.de>
License: MIT License
        
        Copyright (c) 2021 Jiawei Li, Thomas Asikis, Ioannis Fragkos, and Lucas Boettcher
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: dynamic control,growth dynamics,machine learning,microbiome,neural networks
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.7.1
Requires-Dist: numpy<2.0,>=1.26
Requires-Dist: pandas>=2.0
Requires-Dist: pymcmcstat>=1.9.0
Requires-Dist: requests>=2.31.0
Requires-Dist: scipy>=1.10
Requires-Dist: tensorboard>=2.12
Requires-Dist: torch>=2.5
Requires-Dist: torchdiffeq>=0.2.2
Description-Content-Type: text/markdown

![Latest release](https://gitlab.com/ComputationalScience/mgrowthctrl/-/badges/release.svg)
![Tests](https://gitlab.com/ComputationalScience/mgrowthctrl/badges/main/pipeline.svg?key_text=Tests)

# mgrowthctrl

A Python package for parameter inference, mechanistic microbiome modeling, and control, based on a consumer–resource model (CRM).

Detailed documentation is available at [Documentation](https://mgrowthctrl.readthedocs.io/en/latest/).

Key features of mgrowthctrl include:

- An API for defining and simulating ODE-based microbiome dynamics.
- A data loader that allows users to retrieve data from [mGrowthDB](https://mgrowthdb.gbiomed.kuleuven.be).
- A parameter estimation backend offering both least-squares and Markov Chain Monte Carlo (MCMC) optimization.
- Built-in visualization utilities for evaluating trajectories and analyzing posteriors.
- A controller framework based on neural ODEs.
- A modular architecture designed to facilitate the extension and integration of custom models, controllers, and data processing workflows.

## Features

### Models
- An implementation of a CRM (`CRModel`).
- Scalable design supporting both single-species and multi-species systems.
- A unified engine (`BaseODEModel`) with NumPy and PyTorch backends.
- Extensible base classes enabling straightforward implementation of custom ODE models.

### Controllers
- `BaseController` provides an abstract interface with `simulate` and `fit` methods.
- `OpenLoopNeuralController` implements time-dependent control functions.
- `ClosedLoopNeuralController` implements state-dependent control functions.


### Fitting Backend
- Least-squares parameter optimization (`crm_fit_mechanistic`).
- Bayesian parameter inference through MCMC sampling (`crm_fit_mcmc`).

### Plotting
- Tools for visualizing coupled metabolite and species population dynamics.
- Plots of empirical data, spline interpolations, and simulated trajectories.
- Integration of MCMC outputs to show credible intervals.

## Code Structure

```graphql
src/mgrowthctrl/
│
├── backends/
│   ├── array.py        # Array backend interfaces for NumPy and PyTorch
│   └── __init__.py
│
├── controllers/
│   ├── base.py         # BaseController interface with simulate and fit methods
│   ├── closed_loop.py  # ClosedLoopNeuralController
│   └── open_loop.py    # OpenLoopNeuralController
│
├── models/
│   ├── base.py         # ODE base class (uses dependency injection)
│   └── crm/
│       ├── fit.py      # LSQ + MCMC fitting engine
│       ├── model.py    # Mechanistic CRM using BaseODEModel
│       └── utils.py    # Shared utilities
│
├── utils/
│   ├── data.py         # Data loading functions with a public DataLoader-style API
│   ├── plot.py         # Plotting utilities
│   ├── save.py         # Saving / loading utilities
│   └── __init__.py
│
└── __init__.py
```
