PRISM: Probabilistic Inference of Subject-level Mixture for contextualized differential expression
Project description
PRISM
Phenotype-Resolved Inference in Single-Cell Mixed Models via Latent Disease States and Contextualized Differential Expression
▶ Full model explainer (1080p, ~1 min)
Overview
PRISM extends the NEBULA negative-binomial log-normal mixed model for single-cell differential expression by introducing:
- Latent per-cell disease states $d_{ij} \sim \text{Bernoulli}(\rho_i)$ that separate truly affected cells from unaffected ones within disease subjects.
- Contextualized covariate effects $x^\top \Gamma_g z$ that model how context modulates all covariate effects (a main effect of context on expression).
- Context-dependent disease effects $\Delta_g(z) = \alpha_g + \theta_g^\top z$ that let the DE magnitude vary with continuous cell-level covariates ($\alpha_g$ = constant disease effect, $\theta_g$ = context modulation).
- An EM algorithm that alternates between inferring $q_{ij} = P(d_{ij}=1 \mid Y, \Theta)$ (E-step) and optimizing the NEBULA-LN approximate likelihood weighted by $q_{ij}$ (M-step).
Installation
Option A — conda (recommended)
git clone https://github.com/AndreaRubbi/ContextualizedDifferentialExpression.git && cd ContextualizedDifferentialExpression
conda env create -f environment.yml
conda activate prism
pip install -e .
Option B — pip + venv
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
# If CUDA 12.4 driver, pin a compatible torch build:
pip install torch==2.5.1+cu124 --index-url https://download.pytorch.org/whl/cu124
# Required for HVG selection (seurat_v3 flavor):
pip install scikit-misc
Verify
python -c "
import torch, prism
print(f'PRISM v{prism.__version__}')
print(f'PyTorch {torch.__version__}, CUDA available: {torch.cuda.is_available()}')
"
Quick start
from prism.data.simulation import generate_prism_data
from prism.inference.em_loop import PRISMConfig, PRISMTrainer
# 1. Generate synthetic data: 50 subjects × 200 cells × 60 genes
data, ground_truth = generate_prism_data(
n_subjects=50, n_genes=60, n_cells_per_subject=200,
rho=0.6, seed=42, device="cpu",
)
# 2. Configure and fit
config = PRISMConfig(
n_genes=data.n_genes,
n_covars=data.n_covars,
n_context=data.n_context,
max_em_iter=30,
m_step_optimizer="trust_region",
run_wald=True,
wandb_enabled=False,
device="cpu",
)
trainer = PRISMTrainer(config)
results = trainer.fit(data)
# 3. Inspect results
print(f"EM iterations: {results.em_iterations}")
print(f"Converged: {results.converged}")
sig = results.significant_genes(fdr=0.05)
print(f"Significant genes (FDR<0.05): {sig.sum().item()}")
Project layout
prism/
├── prism/
│ ├── model/ # PrismModel, encoders, NB/HL likelihoods
│ ├── inference/ # EM (e_step, m_step, em_loop), Wald & score tests
│ ├── data/ # PrismData, simulation, ROSMAP preprocessing
│ ├── baselines/ # NEBULA, context-only, latent-only, stratified
│ ├── evaluation/ # Metrics and plotting
│ └── utils/ # Numerical helpers, logging
├── tests/ # Unit and integration tests
└── tutorials/ # Notebook tutorials (API, synthetic, ROSMAP)
Tutorials
- tutorials/getting_started.ipynb — end-to-end API walkthrough on simulated data (fit, test, interpret).
- tutorials/synthetic_data_tutorial.ipynb — generate data, sweep parameters, plot FPR/power.
- tutorials/rosmap_real_data.ipynb — applying PRISM to ROSMAP microglia.
- docs/TUTORIAL.md — installation + CLI reference.
Reproducing the paper
All scripts, pipelines and notebooks that reproduce the paper's results live
in the top-level reproducibility/ folder (Snakemake ablations, NEBULA-style
benchmark, external baselines, ROSMAP and COVID real-data analyses). See
../reproducibility/README.md.
Citation
@article{prism2026,
title={PRISM: Phenotype-Resolved Inference in Single-Cell Mixed Models
via Latent Disease States and Contextualized Differential Expression},
author={Anonymous Authors},
journal={Under review},
year={2026}
}
Regenerating the animations
The animated visuals are built with Manim Community.
pip install manim
cd media
# Standalone logo (1080p MP4)
manim -qh prism_explainer.py PRISMLogo
# Full explainer (1080p MP4)
manim -qh prism_explainer.py PRISMExplainer
# Full explainer (720p GIF — large file)
manim -qm --format=gif prism_explainer.py PRISMExplainer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prism_de-0.1.0.tar.gz.
File metadata
- Download URL: prism_de-0.1.0.tar.gz
- Upload date:
- Size: 84.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91b17d2ad6e39b5192734e8b07e07ab60d3c56a0558ba896e5fdf13b19d49ecd
|
|
| MD5 |
7271e12b4b8b09be21e691ad949b398c
|
|
| BLAKE2b-256 |
87b2c39a1fd5f1da004b1b4377a6d05c7121141fed04a731133f7b7b08c7a90c
|
Provenance
The following attestation bundles were made for prism_de-0.1.0.tar.gz:
Publisher:
pypi.yml on AndreaRubbi/PRISM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prism_de-0.1.0.tar.gz -
Subject digest:
91b17d2ad6e39b5192734e8b07e07ab60d3c56a0558ba896e5fdf13b19d49ecd - Sigstore transparency entry: 1390544190
- Sigstore integration time:
-
Permalink:
AndreaRubbi/PRISM@89a7909ec91421cee1cab3012ce15760da6976fa -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AndreaRubbi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@89a7909ec91421cee1cab3012ce15760da6976fa -
Trigger Event:
release
-
Statement type:
File details
Details for the file prism_de-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prism_de-0.1.0-py3-none-any.whl
- Upload date:
- Size: 83.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e47492f2955e0bccc7f7650c3544a5e5cb3e94e18473e296aca53688ad457030
|
|
| MD5 |
7a1743ec294f4efac431dd3e33927b47
|
|
| BLAKE2b-256 |
ac36487021a55b2d1f283158e461fe465256559464d9cb3c18aca1ba27e2a559
|
Provenance
The following attestation bundles were made for prism_de-0.1.0-py3-none-any.whl:
Publisher:
pypi.yml on AndreaRubbi/PRISM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prism_de-0.1.0-py3-none-any.whl -
Subject digest:
e47492f2955e0bccc7f7650c3544a5e5cb3e94e18473e296aca53688ad457030 - Sigstore transparency entry: 1390544265
- Sigstore integration time:
-
Permalink:
AndreaRubbi/PRISM@89a7909ec91421cee1cab3012ce15760da6976fa -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AndreaRubbi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@89a7909ec91421cee1cab3012ce15760da6976fa -
Trigger Event:
release
-
Statement type: