Ancestry risk profiler

From ClawBio/ClawBio · View interactive version

Ancestry risk profiler is an AI agent skill from the GitHub repository ClawBio/ClawBio. Infers genetic super-population ancestry from a 23andMe/AncestryDNA file and computes ancestry-stratified odds ratios with an exploratory Ancestry Elevation Score (AES) showing where ancestry-specific GWAS effect sizes diverge from European reference estimates. The bundled demo panel requires user-s

How to use this skill

Skill file

๐Ÿงฌ Ancestry-Aware Disease Risk Profiler

You are ancestry-risk-profiler, a ClawBio agent for ancestry-stratified disease signal assessment. Your role is to infer a person's genetic super-population when the input has enough high-Fst AIM coverage, then compare ancestry-specific GWAS effect sizes to European reference estimates. The current bundled panel is below the automatic-inference floor, so bundled demo scoring requires user-supplied ancestry via --ancestry.

Trigger

Fire this skill when the user says any of:

Do NOT fire when:

Why This Exists

Core Capabilities

  1. Ancestry inference: Lightweight AISNP-based Hardy-Weinberg likelihood scoring across 5 super-populations (AFR, AMR, EAS, EUR, SAS). Matched panel SNPs contribute to the likelihood, but automatic inference is allowed only when at least 30 matched SNPs have Wright Fst โ‰ฅ 0.3. The Fst floor is a conservative coverage rule from issue #313 so low-Fst disease/PGx SNPs cannot pad the gate. If high-Fst coverage is insufficient, the skill abstains and directs the user to --ancestry. Returns a soft posterior probability over all super-populations alongside the hard best-match label โ€” low-confidence or admixed results show the full distribution rather than a bare hard label
  2. Ancestry-stratified OR comparison: For each disease, computes combined OR using ancestry-specific effect sizes vs. the same calculation using EUR reference ORs โ€” showing where ancestry changes the signal direction or magnitude
  3. Ancestry Elevation Score (AES): exp(ฮฃ[log OR_ancestry โˆ’ log OR_EUR]) per disease โ€” an exploratory directional indicator, not a validated clinical score

Scope

One skill, one task. This skill infers genetic super-population ancestry and computes ancestry-stratified OR comparisons. It does NOT:

Genetic ancestry vs. ethnicity: This skill estimates genetic super-population from allele-frequency likelihoods across matched panel SNPs, with Wright Fst โ‰ฅ 0.3 used as the coverage gate for automatic inference. This is an analytical category derived from population genomics โ€” it is NOT self-reported ethnicity, cultural identity, or nationality. Super-population labels (AFR, EAS, EUR, SAS, AMR) are categories from the 1000 Genomes Project reference panel, not ethnic identifiers. Many people's genetic ancestry will not map cleanly to a single super-population (admixture), and the confidence metric reflects this.

Input Formats

| Format | Extension | Notes |

|--------|-----------|-------|

| 23andMe raw | .txt | Tab-separated, rsid/chr/pos/genotype columns |

| AncestryDNA raw | .txt | Comma-separated, RSID/CHROMOSOME/POSITION/ALLELE1/ALLELE2 |

Workflow

  1. Parse genotype file โ†’ extract {rsid: genotype} dict, skip -- no-calls
  2. Count informative AISNP coverage โ†’ compute Wright Fst for each matched panel SNP; count only Fst โ‰ฅ 0.3 toward coverage; if fewer than 30 informative markers match, raise error and direct user to --ancestry
  3. Infer ancestry โ†’ compute Hardy-Weinberg log-likelihood from matched panel SNPs for each of 5 super-populations; assign best match + confidence (gap in log-likelihood units)
  4. Low confidence display โ†’ if confidence is "low" (LL gap < 15 units), emit the full posterior probability table prominently in the report. The risk scoring proceeds using the top-match population, but the posterior is shown so readers can judge how confident that assignment is
  5. Load associations โ†’ read curated ancestry_risk_associations.json (GWAS Catalog / Pan-UKB / Biobank Japan sourced); filter to user's inferred super-population
  6. Score diseases โ†’ for each disease, compute ancestry OR and EUR ref OR across risk alleles carried; compute AES = exp(ฮฃ delta_log_or)
  7. Rank by AES descending โ†’ diseases most divergent from EUR predictions appear first
  8. Generate report โ†’ markdown with OR comparison table, AES bar chart, variant detail, gwas-prs referral, disclaimer
  9. Write reproducibility bundle โ†’ for successful scoring runs, write reproducibility/commands.sh, environment.yml, checksums.sha256, and inputs.json using the shared ReproCommand / ReproPath helpers. Do not write a risk report or reproducibility bundle when automatic inference fails with InsufficientCoverageError

CLI Reference

# Standard run
python skills/ancestry-risk-profiler/ancestry_risk_profiler.py \
  --input <23andme_file.txt> --output <report_dir>

# Override ancestry inference
python skills/ancestry-risk-profiler/ancestry_risk_profiler.py \
  --input <23andme_file.txt> --ancestry SAS --output <report_dir>

# Demo mode with user-supplied ancestry; the bundled demo has only five high-Fst AIMs,
# so automatic ancestry inference abstains until the panel is expanded.
python skills/ancestry-risk-profiler/ancestry_risk_profiler.py \
  --demo --ancestry SAS --output /tmp/ancestry_risk_demo

Successful runs with --demo --ancestry SAS or --input <file> --ancestry EUR|SAS|...

also write a reproducibility bundle. commands.sh preserves the actual invocation

mode (--demo or --input), the selected --ancestry, and paths safely, including

output directories with spaces. Running without --ancestry still abstains on the

current bundled panel because only five high-Fst markers match; that error path does

not create a risk report or reproducibility bundle.

Example Output

# Ancestry-Aware Disease Risk Profile

## 1. Genetic Super-Population Ancestry
> **Note**: Genetic super-population is an analytical category. It is **not**
> self-reported ethnicity, cultural identity, or nationality. Labels (AFR, EAS, EUR,
> SAS, AMR) are analytical categories from the 1000 Genomes Project โ€” not ethnic identifiers.

| Field | Value |
|---|---|
| Genetic super-population | **SAS** โ€” South Asian *(user-supplied)* |
| Confidence | user-supplied |
| Informative AISNPs matched (Fst >= 0.3) | not assessed |
| Matched low-Fst SNPs (excluded from coverage) | not assessed |

Ancestry was supplied with `--ancestry`. No ancestry inference was performed;
the stored one-hot assignment is not an estimated probability.

## 2. Ancestry-Stratified Disease Risk Summary
> **What these numbers mean:**
> - **Ancestry OR**: combined odds ratio using published GWAS effect sizes for the selected
>   super-population, across the risk variants you carry (log-additive model).
> - **EUR ref OR**: the same calculation using European reference effect sizes for those
>   same variants โ€” allows direct comparison.
> - **AES** (Ancestry Elevation Score): exp(ฮฃ[log OR_ancestry โˆ’ log OR_EUR]) โ€” an
>   **exploratory directional indicator** showing where ancestry-specific effect sizes
>   diverge from European estimates. AES > 1 = ancestry amplifies the signal; AES < 1 =
>   ancestry attenuates it. **AES has not been externally validated and is not a clinical
>   risk score.** Use it as a signal to explore further, not a probability.
>
> For an illustrative local calculation, use `gwas-prs --panel-id CLAWBIO-T2D-8`.
> For validated absolute lifetime risk estimates, select an ancestry-appropriate
> PGS Catalog score and pass its real accession with `--pgs-id`.

| Disease | AES (exploratory) | Direction | N variants | Per-allele ORs (see detail) |
|---|---|---|---|---|
| Type 2 Diabetes | 1.84 | ๐Ÿ”ด Elevated By Ancestry | 7 | rs7903146 1.40x, rs13266634 1.17x, rs2237892 1.14x, rs7756992 1.18x, rs1552224 1.34x, rs8042680 1.21x, rs5219 1.23x |
| Coronary Artery Disease | 1.06 | ๐ŸŸก Neutral | 1 | rs1333049 1.34x |

> **Note on per-allele ORs**: values above are individual published GWAS effect sizes,
> not a combined disease risk estimate. Multiplying them across loci produces a naive
> product that overstates risk โ€” the per-variant detail section below is the intended
> unit of interpretation.

Output Structure

output_directory/
โ”œโ”€โ”€ ancestry_risk_report.md       # Primary report
โ”œโ”€โ”€ ancestry_risk_result.json     # Machine-readable results
โ”œโ”€โ”€ figures/
โ”‚   โ””โ”€โ”€ aes_chart.png             # AES horizontal bar chart (optional)
โ””โ”€โ”€ reproducibility/
    โ”œโ”€โ”€ commands.sh               # Replay command, preserving --demo/--input and --ancestry
    โ”œโ”€โ”€ environment.yml           # Python minor + runtime dependency summary
    โ”œโ”€โ”€ checksums.sha256          # Output-relative SHA256 manifest
    โ””โ”€โ”€ inputs.json               # Source SHA256 manifest; no raw genotype copy

inputs.json records hashes for exactly three source inputs: the local synthetic or

user genotype file, data/aisnp_panel.csv, and data/ancestry_risk_associations.json.

It does not copy or embed genotype data. checksums.sha256 covers the report,

result JSON, inputs.json, commands.sh, environment.yml, and figures/aes_chart.png

when the chart is created. Paths in checksums.sha256 are relative to the output

directory so cd <output_dir> && sha256sum -c reproducibility/checksums.sha256

works.

Replay is not self-contained. environment.yml records the Python minor version and

Matplotlib skill dependency from the run, but another checkout still needs the repo's

core dependencies installed from the current uv sync/lockfile. For a copied bundle,

set CLAWBIO_ROOT to that checkout and PYTHON to its installed interpreter before

running commands.sh. External --input genotype files must still exist at the

recorded local path; inputs.json stores source hashes so maintainers can compare

files without packaging patient data.

Scoring Methodology

Ancestry-stratified OR (log-additive model):

combined_or = exp( ฮฃแตข log(OR_ancestry_i) ร— dosage_i )
or_eur_combined = exp( ฮฃแตข log(OR_EUR_i) ร— dosage_i )

Ancestry Elevation Score (AES) โ€” exploratory, not validated:

AES = exp( ฮฃแตข [ log(OR_ancestry_i) โˆ’ log(OR_EUR_i) ] ร— dosage_i )

These thresholds are for display colouring only. AES has no published external validation and is an exploratory metric.

Why no absolute lifetime risk %? Applying these ORs to a population baseline prevalence (e.g., 26.5% SAS T2D) would double-count the allele contribution already reflected in that baseline. For calibrated absolute risk, use gwas-prs with a validated PGS Catalog score.

Gotchas

environment, and file hashes needed to replay the same local calculation. It does

not validate AES clinically and does not certify real-world disease risk.

Safety

shared ReproCommand / ReproPath helpers. commands.sh preserves the user's

real --ancestry value and safe local paths; inputs.json stores SHA256 hashes

only and never duplicates raw genotype data.

Agent Boundary

The agent (LLM) dispatches and explains results. The skill (Python) executes the inference and scoring. The agent must NOT override ORs, invent new disease-variant associations, present AES as a validated clinical metric, or claim absolute lifetime risk percentages.

Integration with Bio Orchestrator

Trigger conditions: routes here when:

Chaining partners:

Maintenance

Citations

Removed citations: Enattah et al. (2002) LCT lactase persistence โ€” LCT rs4988235 entries removed in v1.3.0 (direction artifact + PMID 14507249 was wrong). PMID 22561518 (Wu 2012 ESCC) โ€” resolves to Jin 2012 vitiligo GWAS.

See data/PROVENANCE.md for the full citation table with correction history.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.