← Back to all sparks
T

TwoSampleMR

ANALYTICS
Velocity0.0

Two Sample MR Functions and Interface to MRC Integrative Epidemiology Unit OpenGWAS Database

The flagship Mendelian randomization package is auditing its own estimators, one bootstrap at a time.

mendelian-randomizationgenetic-epidemiologycorrectness-fixesopengwasstatistical-software
Current state
TwoSampleMR is the MRC-IEU package for two-sample Mendelian randomization against OpenGWAS. Its 2026 releases are a sustained correctness review rather than feature work: 0.7.9 fixed bootstrap standard errors in mr_mode() and mr_rucker_bootstrap() that had been inflated since v0.6.30, and repaired two Rucker functions that were returning malformed objects. Point estimates were not affected by the bootstrap bug.
Where it's heading
The pattern across these releases is a package being read line by line — a copy-paste weight vector in ldsc_rg(), chunking that produced zero splits for short SNP lists, penalisation recycled across the wrong SNPs, dead code paths removed, and regression tests added behind each fix. Alongside it runs a mechanical modernization pass: seq_len() for loop indices, tidyr in place of reshape2, current ggplot2 idioms, and the OpenGWAS URL migration. Feature work is limited to forest plot presentation.
Prediction
Expect the audit to continue through the remaining bootstrap and jackknife routines, with releases staying in the 0.7.x patch range and each fix arriving with its own regression test.

Recent moves

  1. 1mo ago

    Bootstrap standard errors corrected in mode and Rucker estimators

    Fixes a layout bug present since v0.6.30 in which the pre-generated rnorm() matrix was filled column-by-column while per-SNP means and standard errors recycled element-wise, so each bootstrap draw came from the wrong SNP's distribution and standard errors and p-values came out inflated. Point estimates were unaffected, but inference from mr_mode() and mr_rucker_bootstrap() shifts. Two Rucker functions that accessed per-combination results directly are also unwrapped correctly.

    View source ↗
  2. 2mo ago

    Wrong weight vector and chunking fixes across the estimator set

    A dense correctness release: ldsc_rg() was passing trait 1's weight vector into the trait-2 heritability call, extract_split() produced zero chunks for SNP lists smaller than half the split size, and the penalised mode recycled the mode vector across SNPs for vector-valued phi. Results are unchanged at the default scalar phi, which is how a bug like that survives.

    View source ↗
  3. 2mo ago

    Deprecated ggplot2 idioms and dead code removed

    Replaces aes_string(), the deprecated size argument and reshape2::dcast() with current equivalents, and removes an unreachable mr_mode_broken() function. Cleanup that clears check warnings without changing any result.

    View source ↗
  4. 3mo ago

    OpenGWAS URLs migrated and Wald ratio warnings quieted

    Moves gwas.mrcieu.ac.uk references to opengwas.io and stops mr_wald_ratio() from firing its multi-SNP warning during default multi-method mr() runs while preserving it when the method is requested alone. Also hardens loop indices against empty vectors across the singlesnp, leaveoneout, rucker and multivariable code paths.

    View source ↗
  5. 4mo ago

    Categorized forest plots aligned with the published figures

    Cosmetic adjustments bringing the categorized forest plots closer to the versions in the original article, plus an expanded multivariable MR vignette section.

    View source ↗
  6. 4mo ago

    Further internal code optimizations

    A one-line release note covering unspecified code optimizations, shipped a day after the previous release during the densest stretch of the modernization pass.

    View source ↗