caliperx
CALIPER-X — predict and certify cross-cohort replicability of single-cell differential-expression findings, with FDR-controlled certified gene sets.
This package is the software companion of the KPMP re-analysis study (K02_KPMP_ScRNA_Validation). It implements the method chain:
SCISSOR decomposition → donor-level reliability → closed-form P_rep
→ CALIPER feature matrix → tabular model → conformal + BH certification
Install
pip install caliperx # core (numpy/scipy/pandas/scikit-learn)
pip install "caliperx[pfn]" # + TabPFN v3.x backbone
Or install from source:
pip install -e .
pip install -e ".[pfn,dev]"
Quickstart (synthetic data, ~5 s)
import numpy as np
from caliperx import (
scissor_decompose, donor_reliability,
replication_probability, core_features, certify, auprc,
)
from caliperx.simulate import simulate_dataset
from caliperx.models import cross_val_predict
# 1. simulate a discovery cohort (30 case / 30 ctrl, 5 cell types, 600 genes)
d = simulate_dataset(n_genes=600, n_case=30, n_ctrl=30, seed=1)
# 2. SCISSOR decomposition (composition vs state)
dec = scissor_decompose(d["t_std"], d["t_naive"], d["is_case"], d["is_ctrl"])
# 3. reliability layer (EB shrinkage + bootstrap sign stability)
st = donor_reliability(d["t_std"], d["is_case"], d["is_ctrl"], n_boot=200)
sn = donor_reliability(d["t_naive"], d["is_case"], d["is_ctrl"], n_boot=200)
# 4. closed-form replication probability for a future cohort of 20/20
p_rep = replication_probability(
st["dc"].values, st["sw2"].values, st["v_obs"].values, st["lam"].values,
n1_new=20, n0_new=20, tau=0.3,
)
# 5. CALIPER feature matrix (23 features)
n = len(dec)
F = core_features(
dec, st, sn, p_rep,
padj_std=np.full(n, 0.01), padj_naive=np.full(n, 0.01),
muscat_lfc=dec["lfc_naive"].values,
expr_mean=np.ones(n), detect_frac=np.full(n, 0.5),
)
# 6. train a tabular model under the standard 5-fold protocol
oof = cross_val_predict(F.values.astype(np.float32), d["y_true"], kind="gbm", cap=400)
print("AUPRC:", auprc(d["y_true"], oof))
# 7. FDR-controlled certification (conformal p + BH at q=0.10)
out = certify(oof, d["y_true"] == 0, q=0.10)
print("certified:", int(out["certified"].sum()), "genes")
Or entirely from the CLI:
caliperx simulate --out demo.npz --n-genes 600
caliperx features --input demo.npz --out features.csv
caliperx eval --scores features.csv --label-col y_true --out metrics.json
caliperx certify --scores features.csv --score-col p_rep --label-col y_true --q 0.10 --out certified.csv
API overview
| Module | Key functions |
|---|---|
caliperx.decomp |
composition_frozen_pseudobulk, scissor_decompose |
caliperx.reliability |
donor_reliability (EB λ, bootstrap sign stability, AUC) |
caliperx.prior |
replication_probability (closed-form P_rep) |
caliperx.features |
core_features (CALIPER 23f matrix) |
caliperx.models |
make_model, cross_val_predict (5-fold, balanced cap) |
caliperx.certify |
conformal_pvalues, bh, certify |
caliperx.eval |
auroc, auprc, topk_precision, label_efficiency |
caliperx.simulate |
simulate_dataset (synthetic ground truth) |
Method notes (fixed definitions)
- SCISSOR: composition-frozen pseudobulk
T_std = Σ_c w_c·m_cwith control mean fractionsw;comp_part = lfc_naive − lfc_std;phi = comp_part / lfc_naive. - Reliability: limma-style EB prior
τ² = max(Var(δ) − mean(v_obs), 1e-4),λ = τ²/(τ²+v_obs); bootstrap sign stability over donor resamples. - P_rep:
μ = λ·δ,s² = λ·v_obs + sw2·(1/n1_new + 1/n0_new); direction-aware Gaussian tail probability at thresholdτ(or sign-only). - Certification: conformal p-values against a negative reference set +
Benjamini–Hochberg at level
q. Simulation-verified FDR control (conservative under heterogeneous noise) in the companion study.
Reproducibility & scope
The companion study applies this pipeline to KPMP + 3 external kidney cohorts
(see ../final_numbers.md, ../methods_rigor_summary.md for the full
evidence ledger and non-claims). The package focuses on the portable method
core; cohort-specific data ingestion lives in the study scripts.
License: MIT (the package). Note that TabPFN model weights carry their own (non-commercial) license — the core package has no dependency on them.
Metadata
Release files for caliperx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| caliperx-0.1.0.tar.gz | 16.7 kB | Without provenance | Details for caliperx-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| caliperx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for caliperx-0.1.0-py3-none-any.whl |
Total release size: 33.4 kB
Release files / caliperx-0.1.0.tar.gz
| Download URL | caliperx-0.1.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad2b3e4404ddae7c108da3365ac890d7eb526a686e6e180dd5c2c53e67f6f338
|
|
BLAKE2b-256 checksum How to use checksums |
23956858d10594b226bfdc7411ea1640e4f7d0e2dc6072356e265adec7894955
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / caliperx-0.1.0-py3-none-any.whl
| Download URL | caliperx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15f39f38f31c795822aa130c828d2f9961d4a8796ff6f0fc9347c9336185d960
|
|
BLAKE2b-256 checksum How to use checksums |
59591536c0deeacf4e1c7f382d2a2509e91705f83753325584174afd69154768
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for caliperx 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.