Mendelian randomization: genes as instruments for a causal effect (TwoSampleMR)
@misc{twosamplemr,
title = {TwoSampleMR},
author = {Hemani and Davey Smith and others},
howpublished = {\url{https://mrcieu.github.io/TwoSampleMR/}},
note = {Software / documentation}
}Follow the analysis.
Select a node to explore the method
Harmonise SNP–exposure & SNP–outcome effects
Data preparation — shapes the raw inputs into what the estimator expects.
Each SNP is a candidate instrument. Align effect alleles across the two GWAS so the signs are comparable.
dat <- harmonise_data(exp, out)
Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.
Questions to explore- Which assumption matters most here, and what evidence could challenge it?
- What would you check before passing this output to the next step?
Choose a question to start your comment.
Peer discussion
- Bring your experience, a question, or a different perspective.
Log in to comment on this step.
Check instrument strength
A pre-flight check — run this before trusting any estimate downstream.
Weak instruments bias MR. Read the variance explained and the F-statistic before trusting anything.
# per-SNP F = (beta/se)^2; overall F from R^2
Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.
Questions to explore- Which assumption matters most here, and what evidence could challenge it?
- What would you check before passing this output to the next step?
Choose a question to start your comment.
Peer discussion
- Bring your experience, a question, or a different perspective.
Log in to comment on this step.
Inverse-variance weighted estimate
The core estimate — where the causal quantity itself is computed.
Combine the per-SNP Wald ratios, weighting by precision — the IVW estimate.
mr(dat, method_list = c('mr_ivw'))
Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.
Questions to explore- Which assumption matters most here, and what evidence could challenge it?
- What would you check before passing this output to the next step?
Choose a question to start your comment.
Peer discussion
- Bring your experience, a question, or a different perspective.
Log in to comment on this step.
Pleiotropy-robust: MR-Egger, weighted median
A robustness check — does the headline result survive a different lens?
If instruments affect the outcome through other paths, IVW is biased. The MR-Egger intercept tests directional pleiotropy; weighted median/mode are robust to some invalid instruments.
mr(dat, method_list = c('mr_egger_regression',
'mr_weighted_median'))
Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.
Questions to explore- Which assumption matters most here, and what evidence could challenge it?
- What would you check before passing this output to the next step?
Choose a question to start your comment.
Peer discussion
- Bring your experience, a question, or a different perspective.
Log in to comment on this step.
Inputs & data
GWAS summary statistics: for each SNP, its effect on the exposure and on the outcome (with standard errors), harmonised to a common effect allele.
Show data format & exampleHide example
Format — per-SNP effects on exposure and outcome, harmonised.
library(TwoSampleMR)
exp <- extract_instruments('ieu-a-2') # BMI instruments
out <- extract_outcome_data(exp$SNP, 'ieu-a-7') # coronary heart disease
dat <- harmonise_data(exp, out)
res <- mr(dat)
Figures reproduced from TwoSampleMR — MRC IEU (Hemani, Davey Smith et al.) — unofficial community showcase; all credit to the original authors.
⚠️ Unofficial community showcase of twosamplemr. Not affiliated with the authors; all credit to them.
Use genetic variants as instruments to estimate the causal effect of an exposure on an outcome from GWAS summary data — with IVW plus pleiotropy-robust MR-Egger and weighted-median checks.
Discuss the workflow (2)
Log in to join the discussion.
Genes as instruments is the cleanest natural experiment we get — but the MR-Egger intercept and weighted-median checks are non-negotiable. Pleiotropy is everywhere.
The scatter with all five estimator slopes on one plot is the right way to show robustness at a glance. Saved.
Agreed — if IVW and Egger disagree wildly, that's the figure that makes the pleiotropy story obvious to a reviewer.