Metadata-Version: 2.4
Name: assay-calibration
Version: 1.2.0
Summary: Add your description here
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fire>=0.7.0
Requires-Dist: joblib>=1.5.1
Requires-Dist: matplotlib>=3.10.3
Requires-Dist: numpy>=2.2.6
Requires-Dist: pandas>=2.3.1
Requires-Dist: plotly>=6.9.0
Requires-Dist: scikit-learn>=1.7.0
Requires-Dist: scipy>=1.15.3
Requires-Dist: tqdm>=4.67.1
Dynamic: license-file

<p align="center">
  <img src="assets/excalibr_logo.png" alt="ExCALIBR logo" width="56">
</p>

# ExCALIBR

[![bioRxiv](https://img.shields.io/badge/bioRxiv-2025.04.29.651326-b31b1b)](https://doi.org/10.1101/2025.04.29.651326)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

A pipeline for calibrating functional assays to clinical variant interpretation scales (ACMG/AMP evidence levels) using bootstrap skew-normal mixture model fitting and Bayesian calibration.

## Web server

No installation needed: upload your data at **[excalibr.org](https://excalibr.org/)**, in any of the [supported input formats](#input-data-formats), and the calibration runs on the web server (up to the `large` [preset](docs/configuration.md#quality-vs-speed-presets)). For bigger jobs, such as many datasets or the `xl` and `finest` presets, [email us](#questions-help-and-collaboration) and we can run them on our HPC cluster.

## Which version should I use?

| To… | Use |
|---|---|
| Calibrate your own data | [Latest release](https://github.com/rosstewart/exCALIBR/releases/latest) |
| Reproduce the revised ExCALIBR manuscript (not yet public) | [v1.1.0](https://github.com/rosstewart/exCALIBR/releases/tag/v1.1.0) |
| Reproduce the bioRxiv preprint ([v2](https://www.biorxiv.org/content/10.1101/2025.04.29.651326v2)) | [v1.0.0](https://github.com/rosstewart/exCALIBR/releases/tag/v1.0.0) |

What changed in each version: [release notes](https://github.com/rosstewart/exCALIBR/releases).

## Installation

```bash
git clone https://github.com/rosstewart/exCALIBR   # latest release; add --branch vX.Y.Z to pin a version
cd exCALIBR

# CPU-only environment (standard runs)
conda env create -f excalibr.yml
conda activate excalibr
pip install -e .

# GPU environment (JAX + CUDA 12, for GPU-accelerated fitting)
conda env create -f excalibr-gpu.yml
conda activate excalibr
pip install -e .
```

## Quick Start

### Interactive (single dataset)

Start with **BasicScoreset**: a `score` column + a `sample_assignments` column marking Pathogenic/Benign/gnomAD/Synonymous rows yourself (see [Input Data Formats](#input-data-formats)).

```bash
python run_pipeline.py \
    --dataset example/brca_findlay_example.csv --name brca_findlay_example \
    --sample-names "Pathogenic/Likely Pathogenic" "Benign/Likely Benign" "gnomAD" "Synonymous"
```

Writes a calibration JSON, score-distribution plot, and per-variant evidence table to `./calibration_output/` (see [Output Files](docs/output-files.md)). Default: `--preset light` — fast; use `--preset medium`/`large`/`xl`/`finest` for higher quality (see [presets](docs/configuration.md#quality-vs-speed-presets)).

### Common options

| Flag | Default | What it does |
|---|---|---|
| `--preset` | `light` | Quality/speed level: `light`/`medium`/`large`/`xl`/`finest` — see [presets](docs/configuration.md#quality-vs-speed-presets) |
| `--n-jobs` | `-1` (all cores) | Parallel workers (`1` = single-threaded, e.g. for debugging) |
| `--device` | `cpu` | `cpu`, `gpu` (JAX-batched, default GPU), or `cuda:N` to pin to GPU N. `run_pipeline.py` runs one dataset at a time so only one GPU is ever used; for multi-dataset GPU runs use the HPC workflow (`hpc/prepare.py`), one process per GPU. |
| `--output-dir` | `./calibration_output` | Output location |
| `--components` | `3` | Mixture-model size(s) to fit; `2 3` fits both and auto-selects |
| `--sample-names` | — | Required for BasicScoreset; labels `sample_assignments` columns in order |
| `--manual-prior` | — | Supply your own prior instead of estimating — see [Prior estimation](docs/configuration.md#prior-estimation) |
| `--benign-method` | `avg` | `avg`/`benign`/`synonymous` — see [Benign sample method](docs/configuration.md#benign-sample-method) |
| `--conservative-monotonicity` | off | Stricter evidence-threshold enforcement |
| `--no-auto-bidirectional` | off (auto-detect on) | For LoF/GoF-style assays — see [Bidirectional detection](docs/configuration.md#bidirectional-assay-auto-detection) |
| `--no-postprocess` | off | Raw, unprocessed LR-threshold intervals (debugging only) — see [Point-range postprocessing](docs/configuration.md#point-range-postprocessing) |
| `--pathomechanism-prior` | off | Mechanism-aware pathogenic-direction prior, for assays that only detect one disease mechanism — see [Pathomechanism prior](docs/configuration.md#pathomechanism-prior-advanced) |
| `--precomputed-fits` | — | Skip fitting, load existing bootstrap fits |
| `--oob` | off | Compute out-of-bag per-variant evidence |

Full flag reference: [docs/script-reference.md](docs/script-reference.md).

### Batch runs (many datasets)

See the [Batch HPC Workflow](docs/batch-hpc-workflow.md).

## Input Data Formats

Three formats are supported — see [docs/input-formats.md](docs/input-formats.md) for full details and example commands:

1. **BasicScoreset** (start here) — just a `score` column and a `sample_assignments` column you fill in yourself, marking which variants are Pathogenic/Benign/gnomAD/Synonymous controls. No ClinVar metadata needed. Example: `example/brca_findlay_example.csv`. PU/NU-mode examples: `example/brca_findlay_PU_example.csv`, `example/brca_findlay_NU_example.csv`.
2. **IGVF / PillarProject format** ([Tejura et al. 2026](https://doi.org/10.64898/2026.02.14.705848)) — a rich per-variant metadata table; sample groups are instead derived automatically from ClinVar/gnomAD/consequence columns already present in the file, so you don't assign them by hand. Example: `example/MSH2_Jia_2021.csv`.
3. **MaveDB format** — the output format of [bbi-lab/variant-annotation](https://github.com/bbi-lab/variant-annotation), which is used to annotate score sets in MaveDB.

**Experimental:** the code also includes multi-assay (multivariate) calibration, consequence-specific calibration (variants calibrated by molecular consequence, such as missense or protein-truncating), and calibration of computational variant-effect predictor scores (REVEL, AlphaMissense, etc.). These are unpublished, may change without notice and are not yet supported. See the note at the bottom of [docs/input-formats.md](docs/input-formats.md#3-mavedb-format).

## Documentation

- [Releases](https://github.com/rosstewart/exCALIBR/releases) — all versions, with release notes
- [Input Data Formats](docs/input-formats.md) — the three supported input formats, in detail
- [Batch HPC Workflow](docs/batch-hpc-workflow.md) — calibrating many datasets across a SLURM cluster
- [Script Reference](docs/script-reference.md) — every script and its key flags
- [Output Files](docs/output-files.md) — what gets written, and what's in `calibration.json`
- [Configuration Options](docs/configuration.md) — bootstrap presets, priors, component selection, postprocessing, bidirectional-assay detection
- [GPU Acceleration](docs/gpu-acceleration.md) — JAX/CUDA setup, JIT compilation details, and benchmark timings
- [Troubleshooting](docs/troubleshooting.md)

## Citation

If you use ExCALIBR, please cite:

```
Gene-based calibration of high-throughput functional assays for clinical variant classification.
Daniel Zeiberg, Ross Stewart, et al.
bioRxiv 2025.04.29.651326; doi: https://doi.org/10.1101/2025.04.29.651326
```

If you use the IGVF variant effect data from Tejura et al., please also cite:

```
A scalable approach to resolving variants of uncertain significance.
Malvika Tejura, Yile Chen, Abbye E. McEwen, Ross Stewart, Yuriy Sverchkov, Florent Laval, et al.
bioRxiv 2026.02.14.705848; doi: https://doi.org/10.64898/2026.02.14.705848
```

## Software

Software developed by Ross Stewart and Daniel Zeiberg.

## License

[MIT License](LICENSE)

## Questions, help and collaboration

Questions about the core pipeline or the experimental features are welcome. Please email [stewart.ro@northeastern.edu](mailto:stewart.ro@northeastern.edu). We're happy to:

- advise on how to set up and run ExCALIBR for your assay;
- look over your calibration results;
- run calibrations for you on our HPC cluster, including jobs beyond what the [web server](https://excalibr.org/) handles, such as many datasets or the `xl` and `finest` presets.

If we run calibrations for your project, an acknowledgement in whatever form you think appropriate is always appreciated.
