mendelian-randomisation
Two-sample Mendelian Randomisation from GWAS summary statistics with IVW, MR-Egger, weighted median/mode, and full sensitivity analysis (Cochran Q, Egger…
Skill by Reza
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/clawbio-mendelian-randomisation
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: data-analysis
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/mendelian-randomisation
What's inside
- Skill name
mendelian-randomisation- Description
- Two-sample Mendelian Randomisation from GWAS summary statistics with IVW, MR-Egger, weighted median/mode, and full sensitivity analysis (Cochran Q, Egger intercept, Steiger, F-statistic, leave-one-out).
- License
- MIT
- Metadata
- author: Reza · domain: genetic-epidemiology · version: 0.1.0
- Instructions
- 223 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (5)
- SKILL.md
- demo_instruments.json · example_data/
- mendelian_randomisation.py
- __init__.py · tests/
- test_mendelian_randomisation.py · tests/
SKILL.md (first lines)
# 🧬 Mendelian Randomisation You are **Mendelian Randomisation**, a specialised ClawBio agent for causal inference from GWAS summary statistics. Your role is to run two-sample MR with multiple estimators and a complete sensitivity analysis panel. ## Trigger **Fire this skill when the user says any of:** - "Run mendelian randomisation on these GWAS results" - "Is there a causal effect of X on Y?" - "Two-sample MR analysis" - "MR-Egger / IVW / weighted median" - "Causal inference from GWAS summary statistics" - "Drug target validation with genetic instruments" - "MR sensitivity analysis" **Do NOT fire when:** - User wants a GWAS association study (route to `gwas-pipeline`) - User wants to look up a single variant (route to `gwas-lookup`) - User wants polygenic risk scores (route to `gwas-prs`) - User wants colocalization analysis (different method, different skill) ## Why This Exists - **Without it**: Running best-practice MR requires hundreds of lines of R code across TwoSampleMR, MendelianRandomization, and MR-PRESSO packages, with manual orchestration of instrument selection, harmonisation, four+ estimators, and six+ sensitivity tests - **With it**: A single command produces all estimators, the full sensitivity battery, four publication-ready plots, and a STROBE-MR aligned report - **Why ClawBio**: Grounded in Burgess et al. (2013), Bowden et al. (2015/2016), Verbanck et al. (2018) — every threshold and method traces to a published paper, not ad hoc parameter choices ## Core Capabilities 1. **Four MR estimators**: IVW (random effects), MR-Egger, weighted median, weighted mode 2. **Full sensitivity battery**: Cochran's Q, Egger intercept, Steiger directionality, F-statistic, I²_GX, leave-one-out 3. **Instrument diagnostics**: F-statistic per SNP (warning when F < 10), palindromic SNP flagging, weak instrument detection 4. **Publication plots**: Scatter, forest, funnel, leave-one-out (four .png files) 5. **STROBE-MR report**: Assumptions stated, all methods and sensitivity results tabulated, caveats explicit ## Scope **One skill, one task.** This skill performs two-sample MR from pre-harmonised or raw GWAS summary statistics and produces causal effect estimates with sensitivity diagnostics. It does not perform GWAS, LD score regression, colocalization, or multi-trait analysis. ## Input Formats | Format | Extension | Required Fields | Example | |--------|-----------|-----------------|---------| | Harmonised instruments JSON | `.json` | SNP, effect_allele, other_allele, eaf, beta_exposure, se_exposure, pval_exposure, beta_outcome, se_outcome, pval_outcome; optional `n_exposure` / `n_outcome` (sample sizes, needed for a Steiger p-value) | `demo_instruments.json` | ## Workflow 1. **Load**: Read harmonised instruments from JSON (or from IEU OpenGWAS in live mode) 2. **Validate**: Check F-statistics, flag weak instruments (F < 10), flag palindromic SNPs with ambiguous EAF 3. **Estimate**: Run IVW, MR-Egger, weighted median, weighted mode 4. **Sensitivity**: Cochran's Q, Egger intercept, Steiger test, I²_GX, leave-one-out 5. **Visualise**: Scatter, forest, funnel, leave-one-out plots 6. **Report**: STROBE-MR aligned markdown with all results, warnings, and disclaimer ## CLI Reference ```bash # Demo mode (cached BMI->T2D, completely offline) python skills/mendelian-randomisation/mendelian_randomisation.py \ --demo --output /tmp/mr_demo # User-provided instruments python skills/mendelian-randomisation/mendelian_randomisation.py \ --instruments instruments.json --output results/ # Via ClawBio runner python clawbio.py run mr --demo ``` ## Demo ```bash python clawbio.py run mr --demo ``` Expected output: A full MR report for 30 synthetic BMI → T2D instruments showing a positive causal effect (IVW beta ≈ 0.60), consistent across all four methods, with no heterogeneity, no pleiotropy, strong instruments, and correct Steiger direction. Four plots generated. ## Algorithm / Methodology 1. **IVW**: beta = sum(w * bx * by) / sum(w * bx²), with multiplicative random-effects variance inflation (Burgess et al., 2013) 2. **MR-Egger**: Weighted linear regression of by on bx with intercept; slope = causal estimate, intercept = pleiotropy (Bowden et al., 2015). Instruments are first oriented so every exposure effect is positive (the outcome effect flipped with it), as TwoSampleMR does: the intercept is the mean outcome effect at zero exposure effect, so without this it would depend on which allele each GWAS reported. An exposure effect of exactly zero counts as positive, so that instrument keeps its outcome effect (TwoSampleMR's `sign0`). Reported as **not applicable**, with a stated reason, when it is undefined on the given instruments: fewer than 3 of them (it fits two parameters, so below 3 there is no residual degree of freedom), or exposure effects too close to identical for the slope to be identified. Never a number in those cases. 3. **Weighted Median**: Median of Wald ratios weighted by inverse-variance; consistent when ≥50% weight from valid instruments (Bowden et al., 2016, doi:10.1002/gepi.21965; PMID 27061298) 4. **Weighted Mode**: Mode of the inverse-variance weighted kernel density of the Wald ratios, bandwidth `phi` x the modified Silverman rule `0.9 min(sd, 1.4826 mad) / L^(1/5)`, standard error from a parametric bootstrap (Hartwig et al., 2017, doi:10.1093/ije/dyx102; PMID 29040600; as implemented in TwoSampleMR `mr_weighted_mode`) **Key thresholds**: - F-statistic > 10 for instrument strength (Staiger & Stock, 1997) - I²_GX > 0.9 for MR-Egger validity; SIMEX recommended below (Bowden et al., 2016) - Cochran's Q P < 0.05 indicates heterogeneity - Egger intercept P < 0.05 indicates directional pleiotropy. The Egger slope and intercept p-values use a t reference on n - 2 degrees of freedom (the standard errors come from the fit's residual variance), as TwoSampleMR does; at n = 3 that is one degree of freedom and the p-value is wide by construction. IVW and the weighted median use a normal reference, the weighted mode a t on n - 1, as in that implementation - Steiger directionality is computed from z-statistics, so it does not depend on the units the traits are reported in; supply `n_exposure` and `n_outcome` per instrument for a p-value, without them only the direction is reported. The variance explained behind that p-value uses the continuous-trait conversion on both sides, so this version assumes the exposure and the outcome are continuous traits. A binary exposure or outcome in log odds is not supported (it needs case and control counts and the prevalence, which the input does not carry), and the note on the Steiger row states the assumption - MR-Egger, weighted median and weighted mode each need >= 3 instruments (MR-Egger also needs at least two distinct exposure effects); below that each is reported as not applicable rather than as a number. IVW is defined at n = 1, where it is the single Wald ratio ## Example Output ```markdown # Mendelian Randomisation Report **Generated**: YYYY-MM-DD HH:MM:SS UTC **Exposure**: Body mass index (BMI) **Outcome**: Type 2 diabetes (T2D) **Instruments**: 30 SNPs **Mode**: Demo (cached data, offline) ## MR Estimates | Method | Estimate | SE | 95% CI | P-value | |--------|----------|----|--------|---------| | IVW | 0.5979 | 0.0369 | [0.5255, 0.6702] | 5.17e-59 | | MR-Egger | 0.6022 | 0.0816 | [0.4423, 0.7621] | 4.87e-08 | | Weighted Median | 0.6001 | 0.0469 | [0.5081, 0.6921] | 2.07e-37 | | Weighted Mode | 0.6031 | 0.0705 | [0.4648, 0.7413] | 2.03e-09 | ## Sensitivity Analysis | Test | Result | P-value | Interpretation | |------|--------|---------|----------------| | Cochran's Q | 0.73 (df=29) | 1.0000 | No significant heterogeneity | | Egger intercept | -0.0002 | 0.9526 | No directional pleiotropy | | Mean F-statistic | 70.6 | — | Strong instruments |
From ClawBio/ClawBio, MIT.
More from ClawBio/ClawBio
- 0.825score
polars-bio
ClawBio (adapted from K-Dense scientific-agent-skills/polars-bio)
Fast genomic interval operations (overlap, nearest, merge, coverage, cluster, complement, subtract, count-overlaps), multi-format bioinformatics I/O…
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
ena-fetch
Nikolai Hecker, UK Dementia Research Institute
Query metadata and download sequencing data from the European Nucleotide Archive (ENA) via the Portal and Browser APIs.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
gi-expression
ClawBio + Genomic Intelligence
Predict tissue / cell-type expression (log TPM + TPM) from 9,198–500,000 bp of DNA around a TSS, at least 4,599 bp each side (anything but exactly 9,198 bp…
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
geo-fetch
Nikolai Hecker, UK Dementia Research Institute
Query metadata and download data from the NCBI Gene Expression Omnibus (GEO).
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
ukb-ppp-region-fetch
ClawBio
Fetch a regional slice of plasma pQTL summary statistics from the UK Biobank Pharma Proteomics Project (UKB-PPP; Sun 2023 Nature) for a specific (protein…
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
eqtl-catalogue-region-fetch
ClawBio
Fetch a region of cis-eQTL summary statistics from EBI eQTL Catalogue v7+ via tabix-on-FTP.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
protocols-io
ClawBio Contributors
Search, browse, and retrieve scientific protocols from protocols.io via REST API.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
gwas-sumstats-harmonize
AlsammanAlsamman
Harmonize GWAS summary statistics from any common format (GWAS-Catalog SSF, PLINK 1.9/2, REGENIE, METAL, BOLT, SAIGE) to one canonical table (SNP CHR BP EA…
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
prs-applicability-gate
Rinat Rizvanov
Deterministic gate for ONE already-computed polygenic score result and ONE person: returns SUPPORTED (raw score, standardised score and reference percentile…
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
pride-fetch
Nikolai Hecker, UK Dementia Research Institute
Query metadata and download data from the PRIDE Archive, EMBL-EBI's proteomics identifications database, via the PRIDE Archive REST API v3.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
wgs-prs
David de Lorenzo
End-to-end WGS to polygenic risk score pipeline.
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.822score
biostudies-fetch
Nikolai Hecker, UK Dementia Research Institute
Query metadata and download data from EMBL-EBI BioStudies, the database that describes biological studies and links their data across collections…
SkillAFreshness: A★ 1.2KClaude Code +9
Signals
- Stars
- 1,166
- Forks
- 288
- Open issues
- 27
- Last commit (this folder)
- Oct 19, 2026 (8 days ago)
- Last release
- Sep 11, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 0.1.0
- License
- MIT
- Repository
- github.com/ClawBio/ClawBio
- Website
- clawbio.github.io/ClawBio/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Reza
- 0.819score
clinical-variant-reporter
Reza
Classify germline variants from VCF/BCF files according to the ACMG/AMP 2015 28-criteria evidence framework and generate clinical-grade interpretation reports…
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.819score
affinity-proteomics
Reza
Unified analysis pipeline for affinity-based proteomics platforms — Olink (PEA, NPX) and SomaLogic SomaScan (SOMAmer, RFU).
SkillAFreshness: A★ 1.2KClaude Code +9 - 0.773score
gwas-pipeline
Reza
End-to-end GWAS automation wrapping PLINK2 for genotype QC and REGENIE for two-step whole-genome regression association testing.
SkillBFreshness: B★ 1.2KClaude Code +9
Cite this page
mendelian-randomisation skill. Agent Mart. https://agentmart.dev/skills/clawbio-mendelian-randomisation (last updated 2026-10-24)