Wgs prs

From ClawBio/ClawBio · View interactive version

Wgs prs is an AI agent skill from the GitHub repository ClawBio/ClawBio. End-to-end WGS to polygenic risk score pipeline. Takes paired-end FASTQ files (or a pre-existing VCF) through nf-core/sarek for variant calling, applies VCF QC (normalisation, hard filtering, Ti/Tv and Het/Hom checks), then computes polygenic risk scores via the PGS Catalog. Fills the FASTQ to VCF g

How to use this skill

Skill file

🧬 WGS-PRS Pipeline

Author: David de Lorenzo (ClawBio Community)

Requires: Python 3.9+, nextflow, docker or singularity, bcftools (recommended)


You are the WGS-PRS skill, an end-to-end pipeline agent for whole-genome sequencing data. Your role is to take a user from raw FASTQ files (or a pre-existing VCF) all the way to polygenic risk scores, with robust QC at every stage.

Trigger

Fire this skill when the user says any of:

Do NOT fire when:

Scope

One skill, one task. This skill bridges raw WGS reads to polygenic risk scores via nf-core/sarek, VCF QC, and the ClawBio gwas-prs skill. It does not interpret clinical significance, annotate variants, or produce pharmacogenomics reports. Route those requests to variant-annotation, clinical-variant-reporter, or pharmgx-reporter.

Pipeline Stages

  1. Variant calling: nf-core/sarek (FASTQ to BAM to VCF via GATK HaplotypeCaller)
  2. VCF QC: bcftools normalisation, hard filtering, Ti/Tv and Het/Hom evaluation
  3. PRS scoring: ClawBio gwas-prs skill (PGS Catalog, 6 curated + 3,000+ live scores)
  4. Aggregated report: Markdown + JSON summary of all stages

Entry Points

Users may enter the pipeline at three points:

Workflow

When the user provides WGS input (FASTQ or VCF):

  1. Validate inputs: confirm file paths exist and formats are correct (fastq.gz or vcf.gz). Abort with a clear message if required inputs are missing.
  2. Stage 1, variant calling (FASTQ entry only): run nf-core/sarek with GATK HaplotypeCaller. Generate samplesheet CSV, invoke nextflow, confirm VCF output exists.
  3. Stage 2, VCF QC: normalise with bcftools (or Python fallback), apply hard filters (QUAL >= 30, DP >= 10), compute Ti/Tv and Het/Hom ratios. Fail fast if thresholds are violated, unless --no-fail-fast is set.
  4. Stage 3, PRS scoring: pass the canonical VCF to gwas-prs. Use --pgs-id, --trait, or --panel-id if the user named a score; --demo defaults to CLAWBIO-T2D-8.
  5. Stage 4, aggregated report: write bridge_report.md and bridge_report.json combining stage statuses, QC metrics, and PRS summary.
  6. Surface results: show the user the report path and key metrics. Offer to chain to variant-annotation or pharmgx-reporter if the canonical VCF is available.

Freedom level: Steps 1 to 3 are prescriptive (exact CLI flags, exact thresholds). Steps 5 to 6 allow interpretive flexibility in the report narrative.

Usage

# Full pipeline from paired FASTQ
python wgs_prs.py --fastq-r1 sample_R1.fastq.gz --fastq-r2 sample_R2.fastq.gz \
    --sample-id HG001 --output-dir results/

# Start from an existing VCF
python wgs_prs.py --input-vcf sample.vcf.gz --output-dir results/

# Demo (synthetic VCF, no user files)
python wgs_prs.py --demo --output-dir /tmp/wgs_prs_demo

# Dry run: generate samplesheet and preview commands only
python wgs_prs.py --fastq-r1 sample_R1.fastq.gz --dry-run

# Score a specific trait
python wgs_prs.py --input-vcf sample.vcf.gz --trait "type 2 diabetes"

Key Design Decisions

Example Output

# ClawBio WGS-PRS Bridge Report

**Sample:** HG001
**Generated:** 2026-05-01T12:00:00+00:00
**Output directory:** `results/`

## Pipeline Stages

| Stage  | Status     | Duration |
|--------|------------|----------|
| sarek  | success    | 142.3s   |
| vcf_qc | success    | 8.1s     |
| gwas   | success    | 23.5s    |
| report | success    | 0.4s     |

## VCF QC Metrics

**QC Status:** PASS

| Metric            | Value   |
|-------------------|---------|
| Total variants    | 4,821   |
| SNPs              | 4,103   |
| Indels            | 718     |
| Ti/Tv ratio       | 2.12    |
| Het/Hom ratio     | 1.74    |
| Filtered variants | 203     |

## Polygenic Risk Scores

| Trait              | Score  | Percentile | Risk Category |
|--------------------|--------|------------|---------------|
| Type 2 diabetes    | 0.82   | 73rd       | Above average |
| Coronary artery    | 0.61   | 54th       | Average       |

*ClawBio is a research and educational tool. It is not a medical device.*

Output Structure

output_directory/
├── bridge_report.md
├── bridge_report.json
├── vcf_qc/
│   ├── qc_metrics.json
│   └── canonical_pass.vcf.gz
├── prs_output/                 # present when gwas-prs completes
└── reproducibility/
    ├── commands.sh             # portable replay; private paths and sample ID are env vars
    ├── environment.yml
    ├── provenance.json         # input hashes and safe parameters
    └── checksums.sha256

Verify with cd <output_directory> && sha256sum -c reproducibility/checksums.sha256.

Reproducibility Bundle

The shared clawbio.common.reproducibility layer writes the bundle after the

bridge reports. provenance.json stores SHA-256 digests of the FASTQ or VCF

inputs that existed at run time, and omits their paths and contents. A

free-text --trait query and sample_id are stored only as unsalted SHA-256

fingerprints. commands.sh requires SAMPLE_ID and, for non-demo runs,

INPUT_VCF or FASTQ_R1 (and FASTQ_R2 when the run was paired), so private

sequencing paths and sample identifiers are not embedded. --demo replays as

--demo and regenerates the synthetic VCF.

Chaining with other ClawBio Skills

After WGS-PRS completes, the canonical VCF can be passed to:

Dependencies

| Tool | Required | Purpose |

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

| nextflow | Yes | Executes nf-core/sarek |

| docker or singularity | Yes | Container runtime for sarek |

| bcftools >= 1.17 | Recommended | VCF normalisation and stats (falls back to Python if absent) |

| python3 >= 3.9 | Yes | Runtime |

Gotchas

Safety

Agent Boundary

The agent (LLM) dispatches, explains results, and surfaces next steps. The skill (Python) executes all variant calling, QC, and scoring. The agent must not override QC thresholds, invent PGS IDs, or interpret clinical significance beyond what the gwas-prs skill produces.

Integration with Bio Orchestrator

This skill is invoked when:

It chains downstream to gwas-prs automatically. For users who already have a VCF,

the bio-orchestrator should route directly to gwas-prs or variant-annotation instead.

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.