Metadata-Version: 2.5
Name: symphony-dt
Version: 2.0.1
Summary: Bayesian hierarchical state-space digital twins for longitudinal clinical cohorts, with the SYMPHONY v2 Parkinson's disease model.
Project-URL: Homepage, https://a7med7emedan.github.io/symphony-dt/
Project-URL: Documentation, https://a7med7emedan.github.io/symphony-dt/
Project-URL: Repository, https://github.com/a7med7emedan/symphony-dt
Project-URL: Issues, https://github.com/a7med7emedan/symphony-dt/issues
Project-URL: Changelog, https://github.com/a7med7emedan/symphony-dt/blob/main/CHANGELOG.md
Author: Ahmed Hemedan
Maintainer: Ahmed Hemedan
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: bayesian,clinical-prediction,digital-twin,parkinsons-disease,reproducibility,stan,state-space-model,uncertainty-quantification
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: arviz>=0.18
Requires-Dist: cmdstanpy>=1.2
Requires-Dist: matplotlib>=3.8
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.1
Requires-Dist: pydantic>=2.5
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0
Requires-Dist: scipy>=1.11
Requires-Dist: typer>=0.12
Requires-Dist: xarray>=2023.10
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: h5netcdf>=1.3; extra == 'dev'
Requires-Dist: h5py>=3.10; extra == 'dev'
Requires-Dist: hypothesis>=6.100; extra == 'dev'
Requires-Dist: ipykernel>=6; extra == 'dev'
Requires-Dist: mkdocs-jupyter>=0.24; extra == 'dev'
Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: nbconvert>=7; extra == 'dev'
Requires-Dist: openpyxl>=3.1; extra == 'dev'
Requires-Dist: pandas-stubs; extra == 'dev'
Requires-Dist: polars>=0.20; extra == 'dev'
Requires-Dist: pre-commit>=3.7; extra == 'dev'
Requires-Dist: properscoring>=0.1; extra == 'dev'
Requires-Dist: pyarrow>=14; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: twine>=5; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Provides-Extra: docs
Requires-Dist: ipykernel>=6; extra == 'docs'
Requires-Dist: mkdocs-jupyter>=0.24; extra == 'docs'
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
Requires-Dist: nbconvert>=7; extra == 'docs'
Provides-Extra: io
Requires-Dist: h5netcdf>=1.3; extra == 'io'
Requires-Dist: h5py>=3.10; extra == 'io'
Requires-Dist: openpyxl>=3.1; extra == 'io'
Requires-Dist: polars>=0.20; extra == 'io'
Requires-Dist: pyarrow>=14; extra == 'io'
Provides-Extra: test
Requires-Dist: h5netcdf>=1.3; extra == 'test'
Requires-Dist: h5py>=3.10; extra == 'test'
Requires-Dist: hypothesis>=6.100; extra == 'test'
Requires-Dist: openpyxl>=3.1; extra == 'test'
Requires-Dist: polars>=0.20; extra == 'test'
Requires-Dist: properscoring>=0.1; extra == 'test'
Requires-Dist: pyarrow>=14; extra == 'test'
Requires-Dist: pytest-cov>=5; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/a7med7emedan/symphony-dt/v2.0.1/docs/assets/brand/symphony-dt-wordmark-dark.png">
    <img src="https://raw.githubusercontent.com/a7med7emedan/symphony-dt/v2.0.1/docs/assets/brand/symphony-dt-wordmark-light.png" alt="symphony-dt" width="620">
  </picture>
</p>

<p align="center">Bayesian hierarchical state-space digital twins for longitudinal clinical cohorts.</p>

<p align="center">
  <a href="https://pypi.org/project/symphony-dt/"><img src="https://img.shields.io/pypi/v/symphony-dt.svg" alt="PyPI"></a>
  <a href="https://pypi.org/project/symphony-dt/"><img src="https://img.shields.io/pypi/pyversions/symphony-dt.svg" alt="Python versions"></a>
  <a href="https://github.com/a7med7emedan/symphony-dt/actions/workflows/ci.yml"><img src="https://github.com/a7med7emedan/symphony-dt/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  <a href="https://a7med7emedan.github.io/symphony-dt/"><img src="https://img.shields.io/endpoint?url=https://a7med7emedan.github.io/symphony-dt/coverage-badge.json" alt="Coverage"></a>
  <a href="https://a7med7emedan.github.io/symphony-dt/"><img src="https://github.com/a7med7emedan/symphony-dt/actions/workflows/docs.yml/badge.svg" alt="Docs"></a>
  <a href="https://github.com/a7med7emedan/symphony-dt/blob/main/LICENSE"><img src="https://img.shields.io/badge/licence-BSD--3--Clause-blue.svg" alt="Licence"></a>
</p>

symphony-dt builds, checks, calibrates, forecasts with and audits Bayesian digital twins of longitudinal clinical
cohorts. It ships **pd_v2**, the frozen model of the SYMPHONY v2 study of Parkinson's disease progression. pd_v2
follows MDS-UPDRS Part III, MoCA and SCOPA-AUT over time, in Stan, driven from Python with cmdstanpy.

**Developed by Ahmed Hemedan.** Validation manuscript in preparation.

<p align="center"><img src="https://raw.githubusercontent.com/a7med7emedan/symphony-dt/v2.0.1/docs/assets/figures/twin-concept.png" alt="The digital twin of Parkinson's disease: from irregular clinic visits to a calibrated forecast that must pass fixed gates" width="100%"></p>

The logo is a red tulip, the symbol of Parkinson's disease. Its solid half is the patient. Its dotted half is the
digital twin, drawn as posterior samples.

## Install

```bash
pip install "symphony-dt[io]"
python -m cmdstanpy.install_cmdstan --version 2.39.0
symphony-dt check --compile
```

## A ten-line example

```python
import numpy as np
from symphony_dt.data import simulate_cohort
from symphony_dt.fit import fit
from symphony_dt.forecast import split_at_anchor, forecast_exact

cohort = simulate_cohort(60, seed=1)                       # synthetic data only
split = split_at_anchor(cohort.stan_data, list(range(0, 60, 4)), anchor_years=2.0)
result = fit(split.fit, chains=4, iter_warmup=1000, iter_sampling=1000, output_dir="run")
print("\n".join(result.gates().summary_lines()))           # the study's convergence gates
forecast = forecast_exact(result, split, total_keep=400)
print(forecast.interval(0.95).head())
```

## How it works

<p align="center"><img src="https://raw.githubusercontent.com/a7med7emedan/symphony-dt/v2.0.1/docs/assets/figures/method-overview.png" alt="symphony-dt method overview: data, model, inference, gates, evaluation and governance" width="100%"></p>

## What it does

- A validated, long-format data model with a design-envelope check. Adapters read wide tables, OMOP CDM, HL7 FHIR
  R4, CDISC SDTM and the PPMI download layout.
- The pd_v2 model of record, byte-identical to the study and checked by sha256 at import.
- Fitting with chain-level resume, and the study's convergence gates fixed in one place.
- Exact forecasts by the study's design, and an experimental fast route for new participants.
- The scoring code of record: interval coverage, CRPS, LOCF and mixed-model baselines, events, bootstrap.
- Simulation-based calibration with explicit multiplicity control, and posterior predictive checks.
- Run manifests, data fingerprints, pre-registration freezes, PROV provenance, model and data cards.

Every public function carries a validation label: VALIDATED, TESTED or EXPERIMENTAL. See the
[documentation](https://a7med7emedan.github.io/symphony-dt/).

## Governance

> **No participant data ship with this package, and none may be added.** Tests, examples and tutorials use the
> package's own simulator. A privacy gate runs before every commit and in CI. The model was developed on PPMI data
> under the PPMI data use agreement; obtain PPMI data yourself from PPMI. No PPMI-derived result appears here until
> the validation manuscript is published. The twin's forecasts are associational: no causal, treatment or
> deployment claim is made. See [GOVERNANCE.md](https://github.com/a7med7emedan/symphony-dt/blob/main/GOVERNANCE.md).

## Citation

> Hemedan A. symphony-dt: Bayesian digital twins of Parkinson's disease progression, version 2.0.0.
> https://github.com/a7med7emedan/symphony-dt

See [CITATION.cff](https://github.com/a7med7emedan/symphony-dt/blob/main/CITATION.cff).

## Licence

BSD-3-Clause, copyright Ahmed Hemedan. Version 1 remains on the `v1` branch and the `v1.0-preprint` tag under its
original Apache-2.0 licence.
