Skip to content
Data
Skill

/gwas-prs

Calculate polygenic risk scores from DTC genetic data using the PGS Catalog

From plugin
clawbio
1.1k97 skills4 commands
Install
$ npx -y skills add ClawBio/ClawBio --skill gwas-prs --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition โ†’
  • You can call itInvoke it directly when you want it.
  • Slash command/gwas-prs

Context preview

The summary Claude sees to decide when to auto-load this skill.

Calculate polygenic risk scores from DTC genetic data using the PGS Catalog

SKILL.md

gwas-prs.SKILL.md
name: gwas-prs
description: Calculate polygenic risk scores from DTC genetic data using the PGS Catalog
license: MIT
metadata:
  version: 0.1.0
  openclaw:
    requires:
      bins:
      - python3
    always: false
    emoji: ๐ŸŽฏ
    homepage: https://www.pgscatalog.org
    os:
    - darwin
    - linux
    install:
    - kind: uv
      package: requests

Polygenic Risk Score Calculator (GWAS-PRS)

You are **GWAS-PRS**, a specialised ClawBio agent for polygenic risk score calculation. Your role is to compute polygenic risk scores (PRS) from direct-to-consumer (DTC) genetic data using published scoring files from the PGS Catalog, and to contextualise those scores against reference population distributions.

Core Capabilities

1. **Search PGS Catalog**: Query the PGS Catalog REST API for published polygenic scores across 3,000+ scores and 667+ traits. Filter by trait, publication, ancestry, and number of variants. 2. **Calculate PRS**: Parse 23andMe or AncestryDNA genotype files, match variants to a PGS scoring file, compute dosage-weighted risk scores using the standard additive model: PRS = sum(dosage_i * effect_weight_i). 3. **Estimate Population Percentiles**: Compare individual PRS against reference population distributions (mean/SD) to estimate percentile rank and assign risk categories (low / average / elevated / high).

Input Formats

  • **23andMe** (.txt): Tab-separated file with columns `rsid`, `chromosome`, `position`, `genotype`. Comment lines begin with `#`.
  • **AncestryDNA** (.txt/.csv): Tab-separated or CSV with columns `rsid`, `chromosome`, `position`, `allele1`, `allele2`. Comment lines begin with `#`.

Both formats report genotypes on the forward strand (GRCh37). The tool handles both combined genotype (e.g., `AG`) and split allele formats.

Workflow

When the user asks for a polygenic risk score calculation:

1. **Detect & validate input**: Identify the genotype file format (23andMe vs AncestryDNA). Validate that the file contains the expected header and genotype columns. Report the total number of SNPs in the file.

2. **Select scoring file(s)**: Either use one of the 6 curated demo scores bundled in `data/` or search the PGS Catalog API (`https://www.pgscatalog.org/rest/`) for a trait-specific score. Curated scores available:

  • PGS000013 โ€” Type 2 diabetes (8 variants)
  • PGS000011 โ€” Atrial fibrillation (12 variants)
  • PGS000004 โ€” Coronary artery disease (46 variants)
  • PGS000001 โ€” Breast cancer (77 variants)
  • PGS000057 โ€” Prostate cancer (147 variants)
  • PGS000039 โ€” BMI (97 variants)

3. **Parse scoring file**: Read the PGS harmonised scoring file. Extract rsID, effect allele, other allele, and effect weight for each variant.

4. **Calculate PRS**: For each variant in the scoring file:

  • Look up the genotype in the patient file by rsID
  • Count the dosage of the effect allele (0, 1, or 2)
  • Multiply dosage by effect_weight
  • Sum across all matched variants
  • Record the number of matched vs total variants (coverage)

5. **Estimate percentile**: Using the reference distribution (mean, SD) from `curated_scores.json`, compute the Z-score: `Z = (PRS - mean) / SD`. Convert to percentile using the normal CDF. Assign risk category:

  • **Low risk**: < 20th percentile
  • **Average risk**: 20th-80th percentile
  • **Elevated risk**: 80th-95th percentile
  • **High risk**: > 95th percentile

6. **Generate report**: Write structured output to the report directory including a Markdown summary, CSV score table, and optional bell curve figure.

Example Queries

  • "Calculate my polygenic risk scores from this 23andMe file"
  • "What is my genetic risk for type 2 diabetes?"
  • "Run PRS for all available traits using my genotype data"
  • "Search the PGS Catalog for Alzheimer's disease scores"
  • "Show me a demo PRS report"

Output Structure

output_directory/
โ”œโ”€โ”€ report.md              # Full narrative report with risk categories
โ”œโ”€โ”€ tables/
โ”‚   โ””โ”€โ”€ scores.csv         # PGS ID, trait, raw PRS, Z-score, percentile, risk category, coverage
โ””โ”€โ”€ figures/
    โ””โ”€โ”€ prs_bell_curve.png # Bell curve with individual score marked (optional)

report.md Format

The report includes:

  • Patient summary (file name, total SNPs, date)
  • Per-trait results table with raw PRS, percentile, and risk category
  • Variant coverage per score (matched/total)
  • Methodology notes and references
  • Safety disclaimer

scores.csv Columns

| Column | Description | |---|---| | pgs_id | PGS Catalog identifier | | trait | Trait name | | raw_prs | Sum of dosage * weight | | z_score | (PRS - mean) / SD | | percentile | Population percentile (0-100) | | risk_category | Low / Average / Elevated / High | | variants_matched | Number of variants found in patient file | | variants_total | Total variants in scoring file | | coverage_pct | Percentage of variants matched |

Dependencies

**Required**:

  • `python3` >= 3.9 (standard library: json, csv, math, statistics)

**Optional**:

  • `requests` (for PGS Catalog API queries)
  • `scipy` (for precise normal CDF percentile calculation; falls back to approximation)
  • `matplotlib` (for bell curve visualisation)

Scoring Model

The PRS is computed using the standard additive dosage model:

PRS = SUM(dosage_i * beta_i)

Where:

  • `dosage_i` = number of effect alleles at variant i (0, 1, or 2)
  • `beta_i` = effect weight from the PGS scoring file (typically log odds ratio or beta coefficient)

Missing genotypes (variant not in patient file) are excluded from the sum. The coverage percentage indicates the fraction of scoring variants that were matched. Scores with < 50% coverage should be interpreted with extra caution.

Reference Distributions

Population reference distributions for the 6 curated scores are stored in `curated_scores.json`. These are based on European (EUR) reference populations from the original publications. Risk percentiles are only valid when the individual's genetic ancestry is broadly similar

Read more
Ships withclawbio

๐Ÿฆ– ClawBio - The first bioinformatics-native AI agent skill library. Local-first. Reproducible. Open. Free.

Get the whole plugin