pyroNMF
pyroNMF provides probabilistic non-negative matrix factorisation (NMF) built on Pyro. It integrates directly with AnnData for both input and output.
Key features
Unified API — one function,
run_nmf(), handles unsupervised and semi-supervised (fixed genes or fixed samples) runs.Primary model: Exponential NB — per-element Exponential priors on
AandPwith independent variational rate parameters. Gamma (with a shared concentration scale) and ExponentialSingle (shared scalar rates) are available as alternatives.Burn-in / sampling split — a configurable warm-up phase followed by a sampling phase that accumulates posterior means, variances, and marker matrices.
AnnData-native outputs — all results (variational parameters, posterior statistics, marker matrices, run metadata) are written directly into
obsm,varm, anduns.TensorBoard integration — optional per-step logging of loss, chi-squared, parameter histograms, spatial plots, reconstruction diagnostics, and Adam optimizer state.
Automatic device selection — CUDA, MPS (Apple Silicon), and CPU detected and used automatically.
User Guide
- Installation
- Usage
- Quickstart (unsupervised)
- Semi-supervised (fixed patterns)
- Choosing a model family
- Burn-in and sampling phases
- Using a custom data layer
- Providing a custom uncertainty matrix
- Chi-squared tracking and “best” parameters
- Poisson auxiliary loss
- Spatial analysis and plotting
- Custom optimizer
- TensorBoard logging
- Running multiple jobs in one session
- Tutorial (Worked Example)
- 1) Create synthetic counts and AnnData
- 2) Run unsupervised NMF — primary Exponential model
- 3) Inspect the AnnData output
- 4) Chi-squared tracking and “best” parameters
- 5) Comparing all three model families
- 6) Semi-supervised run (fixed patterns)
- 7) Spatial data and visualisation
- 8) Marker matrices
- 9) Custom optimizer and uncertainty
- Notes
- AnnData Integration
API Reference