Variant PheWAS across three curated biobanks, Pan-UK Biobank, FinnGen R12 and the Million Veteran Program: one variant in, beta / SE / p / allele frequency for every outcome each biobank tested (nulls included), on one effect allele, every untested or unreadable outcome kept as a row with a reason, outcomes harmonized across the biobanks, and a replication verdict per shared outcome for every biobank pair and across all three.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Snp Phewas?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-snp-phewas)
---
name: snp-phewas
description: >-
Variant PheWAS across three curated biobanks, Pan-UK Biobank, FinnGen R12 and the Million
Veteran Program: one variant in, beta / SE / p / allele frequency for every outcome each
biobank tested (nulls included), on one effect allele, every untested or unreadable
outcome kept as a row with a reason, outcomes harmonized across the biobanks, and a
replication verdict per shared outcome for every biobank pair and across all three.
license: MIT
metadata:
version: "0.3.0"
author: Aviv Madar
domain: genomics
tags:
- phewas
- pan-ukbb
- finngen
- million-veteran-program
- replication
- summary-statistics
- tabix
data_license: >-
CC-BY-4.0 (Pan-UK Biobank outcome manifest and demo slices); FinnGen R12 public
results terms, free download with citation and acknowledgment required (FinnGen
outcome catalog, outcome crosswalk, demo slices); Million Veteran Program summary
statistics through the NHGRI-EBI GWAS Catalog, EMBL-EBI terms of use with no
restrictions beyond the data owner's, citation given (MVP outcome catalog and its
source snapshots, demo slices)
inputs:
- name: variant
type: string
format:
- rsid
- chr_pos_ref_alt
description: One variant, an rsID (rs12740374) or chr_pos_ref_alt (1_109274968_G_T, GRCh38 unless --build GRCh37), given as --variant or as the first line of an --input text file.
required: true
outputs:
- name: report
type: file
format:
- md
description: Plain-language report with scope, strongest associations, replication for every biobank pair and all three, what was read, and data citations
- name: result
type: file
format:
- json
description: Summary counts, per-dataset status histogram, replication verdict counts per pair and across three, provenance
- name: rows
type: file
format:
- tsv
description: One row per catalog outcome per dataset with status and plain-language label
dependencies:
python: ">=3.12"
packages:
- requests>=2.28
- matplotlib>=3.7
- numpy>=1.24
- pyyaml>=6.0
demo_data:
- path: demo/
description: Real +/-10 kb slices around rs12740374 of 3 Pan-UK Biobank, 3 FinnGen R12 and 2 Million Veteran Program (GWAS Catalog harmonized) outcome files, re-indexed, plus a trimmed FinnGen API answer
endpoints:
cli: python skills/snp-phewas/snp_phewas.py --variant {variant} --output {output_dir}
openclaw:
requires:
bins:
- python3
always: false
emoji: "🧭"
homepage: https://github.com/ClawBio/ClawBio
os:
- darwin
- linux
install:
- kind: pip
package: requests
trigger_keywords:
- snp phewas
- variant phewas across biobanks
- pan-ukbb phewas
- finngen phewas
- million veteran program phewas
- mvp phewas
- phewas replication
- phenome-wide association for rs
---
# 🧭 SNP PheWAS (Pan-UK Biobank + FinnGen + Million Veteran Program)
You are **SNP PheWAS**, a specialised ClawBio agent for phenome-wide association lookups.
Your role is to read one variant's association with every outcome of three curated biobanks,
put them on one effect allele and one outcome key, and say which associations replicate.
## Trigger
**Fire this skill when the user says any of:**
- "PheWAS for rs12740374 across UK Biobank, FinnGen and the Million Veteran Program"
- "Does rs12740374 replicate in FinnGen?", "Does it replicate in MVP?"
- "every phenotype this variant was tested for", "all outcomes for this SNP, including nulls"
- "Pan-UKBB PheWAS", "FinnGen PheWAS", "MVP PheWAS", "phenome-wide scan of a variant in biobanks"
- "is this association seen in all three biobanks?", "the same PheWAS in African ancestry"
**Do NOT fire when:**
- The user wants reported associations across the GWAS Catalog / Open Targets credible
sets, eQTLs (GTEx), or BioBank Japan / UKB-TOPMed PheWeb: route to `gwas-lookup`.
- The user wants summary statistics for a REGION (many variants) from one study: route to
`gwas-catalog-region-fetch` or `eqtl-catalogue-region-fetch`.
- The user gives a gene, a disease or a trait rather than a variant: this skill takes one
variant; resolve the variant first.
- The user wants colocalization or Mendelian randomization: route to `mr-region-run` /
`locuscompare-region-render`.
## Why This Exists
- **Without it**: a PheWAS lookup is a list of reported associations (significance-selected,
from mixed studies), or one biobank's web page at a time. Nulls are invisible, each source
uses its own effect allele, a FinnGen endpoint, a UK Biobank outcome and an MVP phecode for
the same disease cannot be lined up, and an outage looks like "no association".
- **With it**: every outcome of each biobank is a row (tested or not, with the reason), on
the Open Targets alternative allele, with FinnGen endpoints, Pan-UK Biobank outcomes and MVP
studies on one join key and a verdict per shared outcome for every pair of biobanks and
across all three. The default three-biobank read took 159 s and 613 s in two runs with an
empty index cache, and 57 s and 66 s with the indexes cached (measured 2026-10-19 on a Mac
mini, 16 workers per biobank; the cold spread is the GWAS Catalog's download speed).
- **Why ClawBio**: values are read from the biobanks' own files; nothing is estimated. The
skill `gwas-lookup` calls the same FinnGen web endpoint for its FinnGen leg. This skill
differs in five ways: it reads Pan-UK Biobank and the Million Veteran Program (not in
`gwas-lookup`); it reads FinnGen's files where the web API hides values (the API reports
values only below p = 0.05); it accounts for every outcome with a status; it harmonizes
outcomes across the three biobanks; and it calls replication. Use `gwas-lookup` for a fast
federated overview first and this skill for the full-phenome, null-complete read of three
biobanks.
## Core Capabilities
1. **Every outcome, nulls included**: one row per outcome in each biobank's published
catalog (Pan-UK Biobank 7,160 European-ancestry outcomes, FinnGen R12 2,469 endpoints,
Million Veteran Program 2,070 European-ancestry GWAS Catalog studies), each with a
twelve-value `status`; rows equal the catalog as SETS (asserted).
2. **One effect allele**: the Open Targets alternative allele; swapped records are
re-signed; a strand-ambiguous (A/T, C/G) variant in swapped order has its direction
withheld, never guessed. An rsID that names several alleles at one position reads the one
with the most GWAS credible sets in Open Targets, then the most frequent, and says why.
3. **Both builds**: Pan-UK Biobank is GRCh37, read at the Ensembl-mapped position; FinnGen
and the Million Veteran Program are GRCh38.
4. **Ancestry groups**: Pan-UK Biobank's six groups and MVP's four groups plus its
multi-population meta-analysis; `--ancestry` reads the same group in every biobank that
has it and names the biobank that does not.
5. **Outcome harmonization**: 622 of 2,469 FinnGen endpoints map onto 589 Pan-UK Biobank
outcomes (523 by FinnGen's own published mapping, 99 by a single whole ICD-10 block); MVP
phecode studies join Pan-UK Biobank phecodes on the code, and MVP lab and vital-sign means
join Pan-UK Biobank measurements through a reviewed name table.
6. **Replication verdicts**: per shared outcome for every pair of biobanks, at
p < 0.05 / (outcomes both share), and a three-way class at p < 0.05 / (outcomes all three
share), with "not tested", "not read" and "low confidence" kept apart from a tested null.
Two datasets that share participants (MVP's meta-analysis and a group it pools) are never
compared, and the report says which pair and why.
7. **Three figures**: outcome Manhattan per biobank, replication matrix (one strip per pair
plus all three), paired effects (one row of panels per pair with shared outcomes). The
Manhattan groups the outcomes read into 20 body-system categories taken from each
source's own grouping, colors only the outcomes past the significance line (red raises,
blue lowers, open circle for no direction), log-compresses the y axis above 20 when the
top hit is past 40, and labels every outcome past the line on a background patch; one
that fits nowhere is left off and the panel says how many.
## Scope
**One skill, one task.** This skill looks up one variant across the outcomes of curated
biobanks and nothing else. It does not fine-map, colocalize, run MR, or search literature.
## Input Formats
| Format | Example | Notes |
|--------|---------|-------|
| rsID | `rs12740374` | Resolved through the Open Targets variant search. When the rsID names several alleles at one position, the one with the most GWAS credible sets is read, then the highest gnomAD frequency, then the search's order; the report names the others and what separated the chosen allele from the runner-up |
| GRCh38 variant id | `1_109274968_G_T` | `_`, `:` or `-` separators; `chr` prefix allowed |
| GRCh37 variant id | `1:109817590:G:T` with `--build GRCh37` | Mapped to GRCh38 with the Ensembl assembly mapper |
| Text file | `--input variant.txt` | First non-comment line; one variant per run |
## Workflow
1. **Resolve** (prescriptive): rsID to GRCh38 `chr_pos_ref_alt` with Open Targets; the
effect allele is that id's alternative allele. Several alleles at one position: rank by
GWAS credible sets, then gnomAD frequency, then search order. If the weight query fails,
the search's first id is read and the report says the weights could not be read.
2. **Place** (prescriptive): map to GRCh37 with the Ensembl assembly mapper for Pan-UK
Biobank. Zero or several placements, a length change, or an indel on the opposite
strand is `build_unmappable`; an Ensembl outage is `dataset_unreachable`.
3. **Scope** (prescriptive): with two or more biobanks, each is read over its outcomes with
a readable counterpart in another biobank of the lookup (the same rule in each);
`--all-outcomes` reads everything. The datasets are read at once.
4. **Read Pan-UK Biobank** (prescriptive): for each outcome in scope, download its tabix
index once into the cache and read the one position with the skill's own index walker.
5. **Read FinnGen** (prescriptive): one web-API request for all endpoints, then a file read
for every endpoint the API censored (route `hybrid`).
6. **Read the Million Veteran Program** (prescriptive): a study the GWAS Catalog has not
harmonized (or holds without summary statistics) is a `source_file_not_readable` row
from the catalog, with no network call; every other study is read from its harmonized
file with the same index walker. An X / Y / MT variant is absent by rule (MVP released
autosomal results only).
7. **Orient and account** (prescriptive): re-express each record on the effect allele;
assert that each biobank's rows equal its catalog.
8. **Harmonize and compare**: attach the outcome crosswalk; compute replication verdicts
per pair and across three.
9. **Report**: write `report.md` (scope first), `result.json`, `tables/`, `figures/`,
`reproducibility/`, and print the report. Interpretation of the biology is the agent's
job, not the skill's.
## CLI Reference
```bash
# Default: the outcomes matched across the three biobanks (1,156 Pan-UKBB + 622 FinnGen + 727 MVP)
# (first run downloads 4.53 GB of index files into the cache, summed from Content-Length)
python skills/snp-phewas/snp_phewas.py --variant rs12740374 --output /tmp/snp_phewas
# Every outcome in every biobank (7,160 + 2,469 + the 1,221 readable MVP studies; 20.0 GB of indexes)
python skills/snp-phewas/snp_phewas.py --variant rs12740374 --all-outcomes --output /tmp/x
# One ancestry group in every biobank that has it (AFR, AMR, CSA, EAS, EUR, MID, META)
python skills/snp-phewas/snp_phewas.py --variant rs12740374 --ancestry AFR --output /tmp/x
# Quick look: FinnGen web API only (one request; values only where p < 0.05)
python skills/snp-phewas/snp_phewas.py --variant rs12740374 --quick --output /tmp/x
# Other options
# --dataset pan_ukbb_eur,finngen_r12,mvp_eur | all | pan_ukbb_afr,... (see --list-datasets)
# --build GRCh37 --outcomes pan_ukbb_eur:icd10-E78-both_sexes,mvp_eur:GCST90475929
# --finngen-route hybrid|api|tabix --workers 16 --index-cache DIR
python skills/snp-phewas/snp_phewas.py --list-datasets
# Via the ClawBio runner
python clawbio.py run snp-phewas --variant rs12740374 --output /tmp/x
python clawbio.py run snp-phewas --demo
```
```python
import sys; sys.path.insert(0, "skills/snp-phewas")
from snp_phewas_lookup import lookup_variant
from snp_phewas_replication import build_replication, replication_lines
result = lookup_variant("rs12740374") # rows, uncatalogued, provenance, notes
table = build_replication(result) # verdicts per harmonized outcome per pair, and three-way
print("\n".join(replication_lines(table)))
```
## Demo
```bash
python clawbio.py run snp-phewas --demo
```
Offline, about 2 seconds (1.98 s wall time through the runner, measured 2026-10-19 on a
laptop): rs12740374 over real +/-10 kb slices of 3 Pan-UK Biobank outcome files (LDL
direct, ICD-10 E78, phecode 411), 3 FinnGen endpoints (I9_CHD, E4_LIPOPROT, I9_IHD) and 2
Million Veteran Program studies (GCST90475929 ischemic heart disease, an odds-ratio file;
GCST90475416 LDL cholesterol mean, whose p is 0 in the file). Ischemic heart disease
replicates in all three biobanks; E78 replicates in Pan-UK Biobank and FinnGen, LDL in
Pan-UK Biobank and MVP. Every other catalog outcome is a `not_queried` row (or, for an MVP
study with no readable file, a `source_file_not_readable` row), and the report says so at
the top. The rsID and GRCh37 position use answers recorded from Open Targets and Ensembl
(`snp_phewas_demo.py`). The slices are real source rows, not synthetic (provenance and
acknowledgments in `demo/README.md`).
## Algorithm / Methodology
In brief (detail in `references/`):
- **Datasets**: `pan_ukbb_eur`, `finngen_r12` and `mvp_eur` by default; the other Pan-UK
Biobank and MVP groups and the MVP meta-analysis on request (`--list-datasets`).
- **Status**: every catalog outcome is exactly one row; `ok` and `low_confidence` carry
values, and every other status says why there is none.
- **Effect allele**: allele order decides orientation; a swapped record has its beta negated
and EAF flipped, and a swapped strand-ambiguous record keeps its p and SE with its
direction withheld.
- **Replication**: a pair replicates when both p < 0.05 / (outcomes the pair shares) with
the same sign; two datasets that share participants are never compared. An MVP group and
the MVP meta-analysis that both replicate against a third biobank are one piece of
evidence, not two (the group's participants are in both).
- **Exit status**: when no source answered for any outcome, the run is still written,
`result.json` has status `error`, and the script exits 3. A null FinnGen API answer or a
variant absent from a dataset is an answer and exits 0.
Read `references/methodology.md` before explaining a dataset, a status, an effect allele,
an MVP value (odds-ratio SE, an underflowed p, `hm_code`), the outcome crosswalk, the
default scope, an ancestry group or the index cache. Read `references/replication.md`
before explaining a replication verdict, the three-way class, an excluded pair or a
cross-ancestry pair.
## Example Queries
- "PheWAS for rs12740374 across UK Biobank, FinnGen and the Million Veteran Program"
- "Which diseases is rs7412 associated with in FinnGen, Pan-UKBB and MVP, and do they replicate?"
- "Show every Pan-UKBB outcome rs12740374 was tested for, including nulls"
- "The same PheWAS for rs7903146 in African ancestry"
- "Quick FinnGen PheWAS for 19_44908822_C_T"
## Example Output
From `--demo` (abridged; the full file is `examples/expected_output.md`):
```markdown
## Summary
- **Million Veteran Program, European genetic ancestry**: tested in 2 of 2 outcomes read
(2,070 in the catalog, 849 of them with no readable file); 2 below the threshold 0.05 / 2
(over the 2 outcomes looked up).
- **Replication, all three** (threshold 0.05 / 157 outcomes all three share): 1 replicate
in all three, 0 in two.
## Replication across biobanks
**Pan-UK Biobank (European ancestry) and Million Veteran Program (European genetic ancestry)**:
724 shared outcomes, threshold 0.05 / 724.
- replicates (significant in both, same direction): 2 (LDL direct, Ischemic Heart Disease)
**All three biobanks** (Pan-UKBB EUR, FinnGen and MVP EUR): 157 outcomes with a readable
file are shared by all three; each is compared at 0.05 / 157.
- replicates in all three (significant in each, same direction): 1 (Ischemic Heart Disease)
```
Live, Pan-UK Biobank and FinnGen only (`--dataset pan_ukbb_eur,finngen_r12`), rs12740374
(measured 2026-10-18 on a laptop, 16 workers, empty index cache): 87 s wall time; 589 Pan-UK
Biobank files read in 40 s; 1 FinnGen API request plus 564 FinnGen files read in 42 s; 1.9
GiB (2.08 GB) of indexes downloaded. Every one of the 589 + 622 outcomes was tested.
Replication over the 589 shared outcomes (threshold 0.05 / 589): 4 replicate (E78
lipoprotein disorders, ischemic heart disease, angina pectoris, abdominal aortic aneurysm),
5 are same-direction significant in one only, 580 are null in both. Live, the default three
biobanks (measured 2026-10-19 on a Mac mini, 16 workers each), rs12740374 with an empty
index cache: 159 s in one run and 613 s in another, the second with the MVP leg at 605 s
(Pan-UK Biobank 92 s, FinnGen 50 s), so the first-run time is mostly the GWAS Catalog's
download speed; rs2228145 with the indexes cached: 66 s (57 s in an earlier warm run). Read
one after another instead of at once, the first cold run's legs took 308 s (104 + 47 + 153 s).
## Output Structure
```
output_directory/
├── report.md # Scope, summary, strongest associations, replication, sources
├── result.json # Counts, status histograms, verdict counts, provenance
├── tables/
│ ├── snp_phewas_rows.tsv # One row per catalog outcome per dataset, every status
│ ├── excluded.tsv # Rows with no value, each with its reason
│ ├── replication.tsv # Harmonized outcomes, a verdict per pair, three-way class
│ └── uncataloged.tsv # (optional) source outcomes outside the published catalog
├── figures/
│ ├── manhattan.png # Outcome Manhattan, one panel per dataset
│ ├── replication_matrix.png # Signed z per harmonized outcome x dataset, pair strips
│ └── paired_effects.png # (optional) beta vs beta with 95% intervals, per pair
└── reproducibility/
├── commands.sh # The exact invocation
├── environment.yml # Python and package versions
└── checksums.sha256 # SHA-256 of every output, relative to output_directory
```
`replication.tsv` and `replication_matrix.png` need two datasets; `--quick` (FinnGen only)
writes neither.
## Dependencies
**Required**: `requests` (HTTP and range reads), `matplotlib` and `numpy` (figures), `pyyaml`
(dataset catalog). No `pysam`, no `tabix` binary: the index walker is pure Python (`zlib`).
## Gotchas
- **You will want to use `pysam` / `tabix` for the Pan-UK Biobank reads. Do not.** An
exact-position htslib query on these files misses records: measured 2026-10-17, it
returned nothing for rs12740374 in 32 of 32 randomly sampled European-ancestry outcome
files, and for 16 of 250 sampled positions in the LDL file. The index offsets point into
an empty bgzip block; this skill's reader decompresses the stream as one concatenation,
in which that block contributes nothing. Against a +/-500 kb htslib fetch as truth it
agreed on all 32 files and on every sampled position (250 + 62 in the LDL file).
- **You will want to call a FinnGen API result with no value "not associated". Do not.**
The API fills beta / SE / p only where p < 0.05 (measured 2026-10-17 on four variants:
154 to 249 of 2,470 results carry values, the largest p 0.0499). `--quick` labels the rest
`above_api_reporting_threshold`; the default route reads them from the files.
- **You will want to report a missing value as a null. Do not.** `dataset_unreachable`,
`source_file_missing`, `record_unparsable`, `not_queried` and `source_file_not_readable`
are reads that failed or did not happen; the replication view calls them "not read",
never "both null".
- **You will want to count an MVP study the GWAS Catalog has not harmonized. Do not.** 849
of the 2,070 European-ancestry studies have no readable file on the 2026-10-19 snapshot;
they are rows with their reason and sit outside every significance denominator.
- **You will want to read an MVP odds ratio's SE from its interval. Do not.** The interval
is rounded; the SE that reproduces the file's own p is used (see
`references/methodology.md`).
- **You will want to say "no association" for an outcome outside the default scope. Do
not.** Without `--all-outcomes`, 6,004 Pan-UK Biobank, 1,847 FinnGen and 494 readable MVP
outcomes are not read; say so and offer the full run.
- **You will want to report the first pair alone. Do not.** With three biobanks there are
three pairs and an all-three class; the report and stdout print them all.
- **You will want to equate an ICD-10 or phecode match with the same disease definition.
Do not.** FinnGen endpoints add register sources and control exclusions; phecodes exclude
related codes from controls; MVP phecodes come from VA health records.
`icd10_broad_only` and `measurement_near_equivalent` pairs are deliberately not compared.
- **You will want to flip a palindromic (A/T, C/G) variant whose alleles are swapped.
Do not.** The skill withholds its direction; report the p-value only.
- **You will want to read the first allele the rsID search lists. Do not.** The search
lists rs7903146's rare C>G (no GWAS credible set) before its common C>T (888); reading the
first made every outcome an allele mismatch.
## Data access
FinnGen asks users to fill its online form (https://www.finngen.fi/en/access_results)
before downloading summary statistics; instructions arrive by e-mail. The R12 files this
skill reads sit in a public bucket, so nothing enforces the form, but users should fill it.
FinnGen R13 (DF13) was released on June 2, 2026; this skill reads R12. Million Veteran
Program summary statistics are read from the GWAS Catalog's public FTP
(https://ftp.ebi.ac.uk/pub/databases/gwas/summary_statistics/); the Catalog's terms
(https://www.ebi.ac.uk/about/terms-of-use/) place no restrictions beyond the data owner's,
and MVP deposited no license text.
## Safety
- **Local-first**: no user data is uploaded. The variant you query (an rsID or a position)
is sent to Open Targets, Ensembl and FinnGen; see `docs/data-handling.md`.
- **Disclaimer**: every report ends with the ClawBio medical disclaimer.
- **Audit trail**: `reproducibility/` records the command, the environment and a checksum of
every output; `result.json` records the dataset releases read.
- **No hallucinated science**: every value is read from the source file or API; thresholds
are stated with their basis.
## Agent Boundary
The agent (LLM) dispatches and explains. The skill (Python) executes. The agent must NOT
invent associations, override the replication threshold, call an unread or unreadable
outcome a null, report one biobank pair as the whole replication view, or present the
default matched scope as the whole of a biobank.
## Integration with Bio Orchestrator
**Trigger conditions**: an rsID or `chr_pos_ref_alt` together with "PheWAS across biobanks",
"every outcome", "Pan-UKBB", "FinnGen", "Million Veteran Program", "replicate in FinnGen" or
"replicate in MVP".
## Chaining Partners
- `gwas-lookup`: run first for a fast federated overview (GWAS Catalog, Open Targets, GTEx,
three PheWebs); then this skill for the full, null-complete read of three biobanks.
- `mr-region-run` / `locuscompare-region-render`: the variant usually arrives as a
colocalization lead; this skill shows what else the lead is associated with.
- `ld-1000g-region-compute`: check whether two associations share a signal before reading
them as pleiotropy.
## Maintenance
Review on each Pan-UK Biobank, FinnGen or GWAS Catalog MVP release. FinnGen R13 is out
(June 2, 2026) and this skill reads R12. Read `references/maintenance.md` before changing a
release or running many variants: it has the other staleness signals, what to rebuild, the
deprecation criterion and how to precompute rows.
## Citations
Pan-UK Biobank (Karczewski et al., Nat Genet 2025), FinnGen (Kurki et al., Nature 2023)
and the Million Veteran Program (Verma et al., Science 2024). Full entries with DOI and
PMID, the acknowledgments the data terms ask for, and the phecode, Open Targets, Ensembl
and tabix references are in `references/citations.md`; read it when citing a result.