Bio Causal Genomics Mendelian Randomization
Estimate causal effects between exposures and outcomes using genetic variants as...
Install
npx skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-causal-genomics-mendelian-randomization -g -a claude-code -y- Repository
- FreedomIntelligence/OpenClaw-Medical-Skills3.1k
- Category
- Testing
- Updated
- 4mo ago
- License
- See repository
- Context cost
- Mediumabout 2,068 tokens
- Runs scripts
- No, instructions only
What it does
Estimate causal effects between exposures and outcomes using genetic variants as instrumental variables with TwoSampleMR. Implements IVW, MR-Egger, weighted median, and MR-PRESSO methods for robust causal inference from GWAS summary statistics. Use when testing whether an exposure causally affects an outcome using genetic instruments.
Version Compatibility
Reference examples tested with: TwoSampleMR 0.5+, MendelianRandomization 0.9+
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion("<pkg>")then?function_nameto verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Mendelian Randomization
"Test whether my exposure causally affects this outcome using GWAS data" → Use genetic variants as instrumental variables to estimate causal effects from GWAS summary statistics, applying IVW, MR-Egger, and weighted median methods for robust inference.
- R:
TwoSampleMR::mr()for multi-method causal estimation - R:
MendelianRandomization::mr_ivw()for individual methods
Core Concepts
Mendelian randomization (MR) uses genetic variants as instrumental variables (IVs) to estimate causal effects of exposures on outcomes. Valid instruments must satisfy three assumptions:
- Relevance - The variant is associated with the exposure (F-statistic > 10)
- Independence - The variant is not associated with confounders
- Exclusion restriction - The variant affects the outcome only through the exposure
TwoSampleMR Workflow
Goal: Estimate the causal effect of an exposure on an outcome using GWAS summary statistics and genetic instruments.
Approach: Extract instruments for the exposure, extract matching outcome data, harmonize allele directions, and run multiple MR methods (IVW, Egger, weighted median, weighted mode).
"Test if an exposure causally affects an outcome" -> Use genetic variants as instrumental variables to estimate causal effects from GWAS data.
- R:
TwoSampleMR(extract_instruments + harmonise_data + mr) - R:
MendelianRandomization(mr_input + mr_ivw/mr_egger)
library(TwoSampleMR)


