Spaces:
Running
Running
A newer version of the Gradio SDK is available: 6.20.0
Setup and Usage Guide
Quick Start
MAGI is a variant interpretation app that scores genomic variants using the NTv3 foundation model.
Current runtime configuration:
- Model:
InstaDeepAI/NTv3_650M_post - Sequence window:
32768bp (32 kb) - Batch limit:
10variants - Reference genome: local
data/hg38.fawhen available for human, otherwise UCSC / Ensembl fallback
Hugging Face Spaces
- Create a new Space at Hugging Face Spaces.
- Select the
GradioSDK andzero-a10hardware. - Upload the contents of this directory.
- Important:
data/hg38.fais ~915 MB. Do not commit it to the Space repo without Git LFS — instead rely on the UCSC API fallback (the app does this automatically when the file is absent). data/MANE_processed.csv(235 MB) and24 MB) should be committed; the parquet is auto-generated from the CSV on first run.data/MANE_processed.parquet(
- Important:
- Set the
HF_TOKENSpace secret so the app can access the gatedNTv3_650M_postmodel weights. - Start the Space.
Notes:
- The app downloads model weights from Hugging Face on first launch and caches them.
- If
data/hg38.fais not present, sequence retrieval falls back to the UCSC API automatically — no extra configuration is needed.
Local Installation
Prerequisites
- Python 3.8+
- Enough disk space for the model cache and optional local genome
- Internet access for model download and, if needed, UCSC fallback sequence retrieval
- A Hugging Face account with access to
InstaDeepAI/NTv3_650M_post
Install dependencies
cd ntv3_gradio_app
pip install -r requirements.txt
Optional: download the local genome
Automatic:
python download_hg38.py
Manual:
wget -c https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz
gunzip hg38.fa.gz
mv hg38.fa data/hg38.fa
If the local genome is absent, the app still runs by querying UCSC for sequence windows.
Configure Hugging Face access
The active NTv3 model is gated. If model loading fails with an authentication error:
- Accept the model terms at InstaDeepAI/NTv3_650M_post
- Set
HF_TOKENin your environment
Example:
export HF_TOKEN=your_token_here
Validate installation
python test_installation.py
This checks:
- Python dependencies
- Required annotation and metadata files
- Sequence access through the local genome or UCSC fallback
- Model loading
Run the app
python app.py
Or:
gradio app.py
Input Format
Single variant input
- Human chromosome:
chr1-chr22,chrX,chrY,chrM - Non-human chromosome: bare names such as
1,X,MTorchr-prefixed names - Position: 1-based coordinate for the selected species assembly
ref: reference allelealt: alternate allele
Example:
- Chromosome:
chr17 - Position:
7675088 - Ref:
C - Alt:
T
Batch CSV input
Required columns:
chrom,pos,ref,alt
chr17,7675088,C,T
chr7,117559593,ATCT,A
chr13,32340300,G,A
Batch runs are limited to 10 variants.
Output Overview
The single-variant view includes:
- Variant summary with gene, region class, and core metrics
- Ranked BED and BigWig signals
- Region track plot
- Full BED table
- Sequence-model metrics
- Rule-based interpretation panel
Important notes:
Global_z_sum_logis a MAGI ranking score, not a pathogenicity probability.- The simple high/moderate/low tier shown in the summary card is currently based on
Impact_Score_BED. - The interpretation panel is heuristic and deterministic. It summarizes existing outputs; it does not add a new predictive model.
Troubleshooting
Model download or authentication failed
- Confirm that you accepted the model terms for
InstaDeepAI/NTv3_650M_post - Confirm that
HF_TOKENis set - Retry after verifying network access to Hugging Face
No local genome found
- The app can run without
data/hg38.fa - In that case, sequence windows are requested from the UCSC API
- For faster local runs, download
hg38.faintodata/
Slow inference
- First launch is slower because weights may need to be downloaded
- CPU inference is much slower than GPU inference
- The 650M model requires more memory than smaller NTv3 variants
Batch upload rejected
- Ensure the CSV contains
chrom,pos,ref, andalt - Ensure the file has no more than 10 rows
Coordinates look wrong
- Human predictions expect GRCh38/hg38 coordinates
- Non-human predictions expect coordinates from the selected Ensembl assembly
- Non-human chromosome names can be bare or
chr-prefixed
Development Notes
Source-of-truth files for runtime behavior:
app.py: UI, summaries, and batch handlinginference.py: model loading, context length, and sequence retrievalannotation.py: region classes and annotation flagsanalysis.py: ranking and MAGI score computationinterpretation.py: rule-based summary text
References
- NTv3 model page: InstaDeepAI/NTv3_650M_post
- NTv3 paper: bioRxiv preprint
- Gradio docs: gradio.app/docs
Last updated: March 2026