Skip to content

Rust/Python/R project implementing a polio within-host disease model using the Bevy game engine for interactive visualization and PyO3/reticulate for Python/R bindings

Notifications You must be signed in to change notification settings

edwenger/pybevy-polio

Repository files navigation

Open in GitHub Codespaces Tests codecov

A demonstration project to experiment with a few different concepts:

  • porting polio within-host logic into Rust for use with Bevy gaming engine (related to previous Python code implementations in StarSim, poliosim, and multiscale models)
  • experimenting with interactive visualizations for debugging and building intuition about model logic behavior (related to similar effort on malaria coinfection)
  • exporting Rust functions and modules to Python package with PyO3 and maturin (for further integration in tutorial notebooks, calibration workflows, etc.)
  • providing R integration via reticulate for epidemiological analysis workflows

Quick Start

Option 1: GitHub Codespaces (Recommended)

Click the "Open in GitHub Codespaces" badge above for pre-configured development environment.

  • see setup.sh for details
  • see demo.ipynb for a demo notebook using the exported python package

Option 2: Local Development

To launch the interactive demo yourself, run the following from the commandline: cd app && cargo run

You'll have to have rustup installed already. Instructions here.

Interactive polio within-host model

Web Application (WASM)

To run the simulation in your web browser:

cd app && trunk serve --open

Visit http://localhost:8080 for the same interactive visualization with real-time parameter controls. Requires trunk for WASM deployment (install with cargo install trunk).

Python Package Development

In Codespaces

Everything is automatically set up! Just run:

python pybevy/test.py

Local Setup

To build the exported Python package, run maturin from within a new venv:

python -m venv .venv
source .venv/bin/activate
maturin develop --release  # Rebuild pybevy

To test if the exported pybevy python library is accessible, you can run: python pybevy/demo.py

Or also by launching and re-running the code in demo notebook: jupyter notebook demo.ipynb

And look at time-series outputs for different longitudinal challenge scenarios like below:

Time series of successive infectious challenge dosing Heat maps of successive infectious challenge dosing

R Integration

To run the R integration example:

# Install R dependencies (first time)
Rscript -e "install.packages(c('reticulate', 'ggplot2', 'dplyr', 'tidyr'))"

# Run comprehensive R example  
Rscript R/demo.R

See R/README.md for complete setup guide and troubleshooting.

Scatter of pre- and post-challenge antibody titers analyzed in RStudio

Debug Logging

To enable info-level logging, one can set environment variable like this:

RUST_LOG=info cargo run

or

RUST_LOG=info python demo.py

About

Rust/Python/R project implementing a polio within-host disease model using the Bevy game engine for interactive visualization and PyO3/reticulate for Python/R bindings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •