| name | bio-causal-genomics-pleiotropy-detection |
| description | Detect and correct for horizontal pleiotropy in Mendelian randomization analyses using MR-PRESSO for outlier removal, MR-Egger regression for directional pleiotropy, and Steiger filtering for variant directionality. Use when validating MR results, detecting pleiotropic instruments, or running sensitivity analyses for causal inference. |
| tool_type | r |
| primary_tool | MR-PRESSO |
Version Compatibility
Reference examples tested with: MR-PRESSO 1.0+, TwoSampleMR 0.5+
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion("<pkg>") then ?function_name to 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.
Pleiotropy Detection
"Check my MR results for pleiotropic bias" → Detect and correct for horizontal pleiotropy using outlier removal (MR-PRESSO), directional pleiotropy testing (MR-Egger intercept), and variant directionality filtering (Steiger) to validate causal inference results.
- R:
MRPRESSO::mr_presso() for global and distortion tests
- R:
TwoSampleMR::mr_egger_regression() for Egger intercept test
Overview
Horizontal pleiotropy violates the exclusion restriction assumption of MR: instruments
affect the outcome through pathways other than the exposure. Detecting and correcting
for pleiotropy is essential for valid causal inference.
Types of pleiotropy:
- Vertical (mediated): Instrument -> exposure -> outcome (valid, not a problem)
- Horizontal (direct): Instrument -> outcome bypassing exposure (violates MR assumptions)
- Balanced: Pleiotropic effects cancel out (IVW still valid, Egger intercept ~0)
- Directional: Pleiotropic effects are systematic (biases IVW, Egger detects this)
MR-PRESSO
Goal: Detect and remove pleiotropic outlier instruments from an MR analysis.
Approach: Run MR-PRESSO to test for global pleiotropy, identify individual outlier SNPs, test whether their removal changes the causal estimate (distortion test), and obtain a corrected estimate.
library(MRPRESSO)
presso_input <- data.frame(
bx = dat$beta.exposure,
by = dat$beta.outcome,
bxse = dat$se.exposure,
byse = dat$se.outcome
)
presso_result <- mr_presso(
BetaOutcome = 'by', BetaExposure = 'bx',
SdOutcome = 'byse', SdExposure = 'bxse',
OUTLIERtest = TRUE, DISTORTIONtest = TRUE,
data = presso_input,
NbDistribution = 5000,
SignifThreshold =
global_p presso_result`MR-PRESSO results``Global Test`Pvalue
cat global_p
outliers presso_result`MR-PRESSO results``Outlier Test`
cat
printoutliers
outlier_indices whichoutliersPvalue
cat outlier_indices
distortion_p presso_result`MR-PRESSO results``Distortion Test`Pvalue
cat distortion_p
main_results presso_result`Main MR results`
cat main_results`Causal Estimate`
cat main_results`Causal Estimate`
MR-Egger Diagnostics
Goal: Test for directional pleiotropy and obtain a pleiotropy-adjusted causal estimate.
Approach: Fit MR-Egger regression where the intercept estimates average pleiotropic bias, and check I-squared for instrument strength under the NOME assumption.
library(TwoSampleMR)
egger <- mr_egger_regression(dat$beta.exposure, dat$beta.outcome,
dat$se.exposure, dat$se.outcome)
cat('Egger intercept:', round(egger$b_i, 5), '\n')
cat('Intercept SE:', round(egger$se_i, 5), '\n')
cat('Intercept p-value:', format.pval(egger$pval_i), '\n')
cat eggerb
cat eggerse
cat format.pvaleggerpval
isq Isqdatbeta.exposure datse.exposure
cat isq
isq cat
Steiger Filtering
Goal: Verify that instruments act in the correct causal direction (exposure -> outcome, not reverse).
Approach: Apply the Steiger test to each instrument, remove those explaining more outcome variance than exposure variance, and re-run MR on filtered instruments.
library(TwoSampleMR)
steiger <- steiger_filtering(dat)
dat_steiger <- steiger[steiger$steiger_dir == TRUE, ]
cat('Instruments passing Steiger filter:', nrow(dat_steiger), 'of', nrow(steiger), '\n')
results_steiger <- mr(dat_steiger)
print(results_steiger[, c('method', 'nsnp', 'b', 'se', 'pval')])
direction <- directionality_testdat
cat directioncorrect_causal_direction
cat format.pvaldirectionsteiger_pval
Additional Sensitivity Methods
library(TwoSampleMR)
mr_conmix <- mr(dat, method_list = 'mr_raps')
library(MendelianRandomization)
mr_input <- mr_input(
bx = dat$beta.exposure, bxse = dat$se.exposure,
by = dat$beta.outcome, byse = dat$se.outcome
)
raps_result <- mr_raps(mr_input)
cat('MR-RAPS estimate:', raps_result$Estimate, '\n')
cat('MR-RAPS p-value:', raps_result$Pvalue, '\n')
exposure1 extract_instruments
exposure2 extract_instruments
Comprehensive Sensitivity Framework
Goal: Run a complete battery of MR sensitivity analyses to validate causal findings.
Approach: Apply IVW, MR-Egger, weighted median, weighted mode, heterogeneity, Egger intercept, leave-one-out, and MR-PRESSO in a single function and summarize results.
library(TwoSampleMR)
library(MRPRESSO)
run_sensitivity <- function(dat) {
results <- list()
results$ivw <- mr(dat, method_list = 'mr_ivw')
results$egger <- mr(dat, method_list = 'mr_egger_regression')
results$median <- mr(dat, method_list = 'mr_weighted_median')
results$mode <- mr(dat, method_list = 'mr_weighted_mode')
results$het <- mr_heterogeneity(dat)
results$pleio <- mr_pleiotropy_testdat
resultsloo mr_leaveoneoutdat
presso_input data.frame
bx datbeta.exposure by datbeta.outcome
bxse datse.exposure byse datse.outcome
resultspresso mr_presso
BetaOutcome BetaExposure
SdOutcome SdExposure
OUTLIERtest DISTORTIONtest
data presso_input NbDistribution SignifThreshold
results
summarize_sensitivity sens
cat
all_mr rbindsensivw sensegger sensmedian sensmode
cat
printall_mr
cat
cat senshetQ_pvalsenshetmethod
cat
cat senspleioegger_intercept
cat senspleiopval
cat
senspresso`MR-PRESSO results``Global Test`Pvalue
cat
cat
cat
cat
cat
STROBE-MR Reporting
When reporting MR analyses, follow STROBE-MR guidelines:
- Report all MR methods tested (not just the most significant)
- Report heterogeneity Q-statistic and p-value
- Report Egger intercept with p-value
- Report MR-PRESSO global test and number of outliers removed
- Report F-statistics for instrument strength
- Report Steiger directionality test
- State whether results are consistent across sensitivity analyses
- Acknowledge limitations of the MR assumptions
Related Skills
- mendelian-randomization - Primary MR analysis that pleiotropy tests validate
- fine-mapping - Identify causal variants at instrument loci
- population-genetics/association-testing - GWAS data for MR instruments