PYPE

Mendelian randomization methods

How to use this page

Mendelian randomization estimates an exposure-outcome effect under assumptions about instrument relevance, independence, and exclusion restriction. Different estimators respond differently when some instruments violate those assumptions.

Agreement across estimators is supporting evidence, not proof of causality. Review instrument strength, phenotype definitions, sample overlap, population compatibility, horizontal pleiotropy, and harmonization before interpretation.

Method matrix

The counts below are software minimums. Three instruments leave very little information for diagnostics, bootstrapping, or stable density estimation.

Implemented MR methods and software minimum instrument counts.
MethodTokenMinimum SNPsPrimary role
Inverse variance weightedivw2Main pooled estimate.
MR-Eggeregger3Directional pleiotropy sensitivity analysis.
Simple mediansimple_median3Median ratio by instrument count.
Weighted medianweighted_median3Median ratio weighted by precision.
Penalized weighted medianpenalized_weighted_median3Downweight heterogeneous ratio estimates.
Simple modesimple_mode3Largest ratio-estimate cluster.
Weighted modeweighted_mode3Precision-weighted modal cluster.
Penalized modepenalized_mode3Modal estimate with outlier downweighting.
Simple mode NOMEsimple_mode_nome3Simple mode under negligible exposure measurement error.
Weighted mode NOMEweighted_mode_nome3Weighted mode under negligible exposure measurement error.
MR-PRESSOpresso4Global pleiotropy and outlier correction.

Core estimators

Inverse variance weighted

Use when: instruments are independent and valid, or horizontal pleiotropic effects are balanced around zero.

How it works: weighted regression of outcome effects on exposure effects through the origin, using inverse outcome-variance weights.

Strengths: efficient when assumptions hold; familiar primary estimate; supplies Cochran's Q heterogeneity statistics. PYPE uses a multiplicative random-effects standard error.

Caveats: directional pleiotropy and correlated instruments can bias the estimate. Random effects change uncertainty but do not remove pleiotropic bias. Weak instruments and sample overlap can also affect the estimate.

Summary-data IVW: Burgess S, Butterworth A, Thompson SG. Mendelian randomization analysis with multiple genetic variants using summarized data. Genetic Epidemiology. 2013. doi:10.1002/gepi.21758.
Multiplicative random effects and pleiotropy framework: Bowden J et al. A framework for the investigation of pleiotropy in two-sample summary data Mendelian randomization. Statistics in Medicine. 2017. doi:10.1002/sim.7221.

MR-Egger

Use when: directional horizontal pleiotropy is plausible and enough instrument-strength variation exists.

How it works: weighted regression with an intercept. The slope estimates the exposure effect and the intercept tests average directional pleiotropy.

Assumption: Instrument Strength Independent of Direct Effect, commonly called InSIDE.

Caveats: low power, sensitivity to weak instruments, and imprecise estimates with few SNPs. A non-significant intercept does not establish absence of pleiotropy.

Bowden J, Davey Smith G, Burgess S. Mendelian randomization with invalid instruments: effect estimation and bias detection through Egger regression. International Journal of Epidemiology. 2015. doi:10.1093/ije/dyv080.

Median estimators

Bowden J, Davey Smith G, Haycock PC, Burgess S. Consistent estimation in Mendelian randomization with some invalid instruments using a weighted median estimator. Genetic Epidemiology. 2016. doi:10.1002/gepi.21965.

Simple median

Use when: the majority of instruments are expected to be valid by count and instrument precision should not dominate the estimate.

How it works: median of the SNP-specific ratio estimates with equal instrument weights.

Caveats: discards precision information and can be inefficient when instrument standard errors differ substantially.

Weighted median

Use when: more than half of the total inverse-variance weight is expected to come from valid instruments.

Strengths: usually more efficient than the simple median and robust to a minority of invalid weighted instruments.

Caveats: the 50 percent condition concerns weight, not SNP count. Correlated instruments and winner's curse can distort those weights.

Penalized weighted median

Use when: a weighted median analysis contains ratio estimates with strong heterogeneity.

How it works: downweights variants whose ratio estimates are inconsistent with the initial weighted median.

Caveats: penalty behavior depends on the configured constant. Report the parameter and compare with the unpenalized estimate.

Penalization follow-up: Burgess S, Bowden J, Dudbridge F, Thompson SG. Robust instrumental variable methods using multiple candidate instruments with application to Mendelian randomization. 2016. arXiv:1606.03729.

Mode estimators

Hartwig FP, Davey Smith G, Bowden J. Robust inference in summary data Mendelian randomization via the zero modal pleiotropy assumption. International Journal of Epidemiology. 2017. doi:10.1093/ije/dyx102.

Simple mode

Use when: the largest cluster of similar ratio estimates is expected to represent valid instruments.

Assumption: Zero Modal Pleiotropy Assumption, or ZEMPA.

How it works: kernel density estimation identifies the mode of equally weighted ratio estimates.

Caveats: sensitive to bandwidth choice and weakly separated clusters.

Weighted mode

Use when: ZEMPA is plausible and more precise instruments should contribute more strongly to the modal cluster.

Strengths: uses instrument precision while retaining the modal robustness target.

Caveats: a highly precise invalid cluster can dominate the estimate.

Penalized mode

Use when: a weighted mode analysis contains isolated heterogeneous ratio estimates.

How it works: penalizes variants based on distance from the initial weighted-mode estimate before recalculating the density mode.

Caveats: remains bandwidth-sensitive and should be compared with the unpenalized weighted mode. Penalization can hide disagreement and make uncertainty look smaller.

No distinct primary peer-reviewed paper defines this exact TwoSampleMR penalized-mode implementation. Cite the Hartwig mode paper, the penalization references, and the implementation used.

Simple and weighted mode with NOME

Use when: exposure effects are estimated precisely enough that measurement error can reasonably be treated as negligible.

How it differs: bootstrap ratio uncertainty uses outcome standard errors divided by the absolute exposure effect, omitting exposure-effect uncertainty.

Caveats: weak instruments violate the NOME approximation and can make uncertainty estimates optimistic.

Measurement error: Bowden J et al. Assessing the suitability of summary data for two-sample Mendelian randomization analyses using MR-Egger regression: the role of the I2 statistic. International Journal of Epidemiology. 2016. doi:10.1093/ije/dyw220.

Outlier analysis

MR-PRESSO

Use when: horizontal pleiotropic outliers are plausible and at least four instruments are available.

Assumptions: a majority of variants support the main relation, pleiotropy is sufficiently balanced, and outliers are separable from the main IVW pattern.

Outputs: global residual sum-of-squares test, per-SNP outlier test, distortion test, raw IVW estimate, and an outlier-corrected estimate when outliers are detected.

Strengths: identifies influential outliers and quantifies how their removal changes the estimate.

Caveats: empirical p-value precision depends on simulation_count. The method does not solve widespread balanced or directional pleiotropy when outliers are not isolated.

Verbanck M, Chen CY, Neale B, Do R. Detection of widespread horizontal pleiotropy in causal relationships inferred from Mendelian randomization between complex traits and diseases. Nature Genetics. 2018. doi:10.1038/s41588-018-0099-7.

Practical selection

  1. Run IVW as the main pooled estimate.
  2. Use MR-Egger to inspect directional pleiotropy, while expecting lower precision.
  3. Compare weighted median and weighted mode for robustness to different invalid-instrument patterns.
  4. Use MR-PRESSO when isolated outliers and enough instruments are present.
  5. Report heterogeneity, retained SNP count, harmonization decisions, and all configured bootstrap parameters.
results, diagnostics = pype.mendelian_randomization(
    exposure,
    outcome,
    methods=(
        "ivw",
        "egger",
        "weighted_median",
        "weighted_mode",
        "presso",
    ),
    seed=0,
)

Interpretation language

  • Describe an estimate as consistent with an effect under the stated assumptions rather than proof that an exposure causes an outcome.
  • Name the exact robustness condition: InSIDE, valid-weight majority, ZEMPA, balanced pleiotropy, or sparse outliers.
  • Describe NOME as an assumption of negligible exposure-effect measurement error, not a correction for measurement error.
  • Describe MR-PRESSO as detecting and removing outlying variants under its assumptions, not removing all pleiotropy.