Skip to content

Commit 6199e90

Browse files
authored
Merge pull request #604 from remlapmot/read-data-fix
TwoSampleMR v0.6.12
2 parents 119ab49 + e59815b commit 6199e90

File tree

8 files changed

+47
-6
lines changed

8 files changed

+47
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: TwoSampleMR
22
Title: Two Sample MR Functions and Interface to MRC Integrative
33
Epidemiology Unit OpenGWAS Database
4-
Version: 0.6.11
4+
Version: 0.6.12
55
Authors@R: c(
66
person("Gibran", "Hemani", , "[email protected]", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0003-0920-1055")),

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# TwoSampleMR v0.6.12
2+
3+
(Release date 2025-03-18)
4+
5+
* Fixed a bug in `format_data()` (thanks to @lea-urpa)
6+
* For MVMR data extraction in `mv_extract_exposures()` and `mv_extract_exposures_local()`, SNPs that do not pass harmonisation between exposures in MVMR are now dropped (thanks @yatest)
7+
* The comments about **mr.raps** in the Perform MR vignette have been updated
8+
19
# TwoSampleMR v0.6.11
210

311
(Release date 2025-03-06)

R/mr.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mr <- function(dat, parameters=default_parameters(), method_list=subset(mr_metho
1818
stop("You can install mr.raps with install.packages('mr.raps', repos = c('https://mrcieu.r-universe.dev', 'https://cloud.r-project.org'))")
1919
}
2020
}
21-
21+
2222
mr_tab <- plyr::ddply(dat, c("id.exposure", "id.outcome"), function(x1)
2323
{
2424
# message("Performing MR analysis of '", x1$id.exposure[1], "' on '", x18WII58$id.outcome[1], "'")
@@ -984,7 +984,7 @@ mr_raps <- function(b_exp, b_out, se_exp, se_out, parameters = default_parameter
984984
if (!(requireNamespace("mr.raps", quietly = TRUE))) {
985985
stop("You can install mr.raps with install.packages('mr.raps', repos = c('https://mrcieu.r-universe.dev', 'https://cloud.r-project.org'))")
986986
}
987-
987+
988988
data <- data.frame(beta.exposure = b_exp,
989989
beta.outcome = b_out,
990990
se.exposure = se_exp,

R/multivariable_mr.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ mv_extract_exposures <- function(id_exposure, clump_r2=0.001, clump_kb=10000, ha
4141
# Harmonise against the first id
4242
d <- harmonise_data(d1, d2, action=harmonise_strictness)
4343

44+
# Drop SNPs that do not pass harmonisation (e.g. palindromic)
45+
d <- subset(d, mr_keep)
46+
4447
# Only keep SNPs that are present in all
4548
tab <- table(d$SNP)
4649
keepsnps <- names(tab)[tab == length(id_exposure)-1]
@@ -224,6 +227,9 @@ mv_extract_exposures_local <- function(
224227
# Harmonise against the first id
225228
d <- harmonise_data(d1, d2, action=harmonise_strictness)
226229

230+
# Drop SNPs that do not pass harmonisation (e.g. palindromic)
231+
d <- subset(d, mr_keep)
232+
227233
# Only keep SNPs that are present in all
228234
tab <- table(d$SNP)
229235
keepsnps <- names(tab)[tab == length(id_exposure)-1]

R/read_data.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ if (inherits(dat, "data.table")) {
196196
if(!is.null(snps))
197197
{
198198
dat <- subset(dat, SNP %in% snps)
199+
if (nrow(dat) == 0L) {
200+
stop("No SNPs specified for the exposure are present in the outcome dataset.")
201+
}
199202
}
200203

201204
if(! phenotype_col %in% names(dat))

codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
comment: false
2+
3+
coverage:
4+
status:
5+
project:
6+
default:
7+
target: auto
8+
threshold: 0%
9+
informational: true
10+
patch:
11+
default:
12+
target: auto
13+
threshold: 0%
14+
informational: true

vignettes/perform_mr.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,14 @@ dev.off()
482482

483483
## MR.RAPS: Many weak instruments analysis
484484

485-
MR.RAPS (Robust Adjusted Profile Score) is a recently proposed method that considers the measurement error in SNP-exposure effects, is unbiased when there are many (e.g. hundreds of) weak instruments, and is robust to systematic and idiosyncratic pleiotropy. See the [arXiv preprint](https://arxiv.org/abs/1801.09652) for more detail about the statistical methodology.
485+
MR.RAPS (Robust Adjusted Profile Score) is a recently proposed method that considers the measurement error in SNP-exposure effects, is unbiased when there are many (e.g. hundreds of) weak instruments, and is robust to systematic and idiosyncratic pleiotropy. See @zhao2020 for more detail about the statistical methodology.
486486

487-
MR.RAPS is implemented in the R package _mr.raps_ that is available on CRAN. It can be directly called from TwoSampleMR by
487+
MR.RAPS is implemented in the R package **mr.raps** that is available on [GitHub](https://github.com/qingyuanzhao/mr.raps) which is installed when you install TwoSampleMR. It can be directly called from TwoSampleMR by
488488
```{r eval=FALSE}
489489
res <- mr(dat, method_list = c("mr_raps"))
490490
```
491491

492-
MR.RAPS comes with two main options: `over.dispersion` (whether the method should consider systematic pleiotropy) and `loss.function` (either `"l2"`, `"huber"`, or `"tukey"`). The latter two loss functions are robust to idiosyncratic pleiotropy. The default option is `over.dispersion = TRUE` and `loss.function = "tukey"`. To change these options, modify the `parameters` argument of `mr()` by (for example)
492+
MR.RAPS comes with two main options: `over.dispersion` (whether the method should consider systematic pleiotropy) and `loss.function` (either `"l2"`, `"huber"`, or `"tukey"`). The latter two loss functions are robust to idiosyncratic pleiotropy. The default option is `over.dispersion = TRUE` and `loss.function = "huber"`. To change these options, modify the `parameters` argument of `mr()` by (for example)
493493
```{r eval=FALSE}
494494
res <-
495495
mr(

vignettes/refs.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,13 @@ @article{hemani-plosgen-2017
8383
pages = {e1007081},
8484
number = {11},
8585
}
86+
87+
@article{zhao2020,
88+
title={{Statistical inference in two-sample summary-data Mendelian randomization using robust adjusted profile score}},
89+
author={Zhao, Qingyuan and Wang, Jingshu and Hemani, Gibran and Bowden, Jack and Small, Dylan S},
90+
year={2020},
91+
volume = {48},
92+
issue = {3},
93+
pages = {1742--1769},
94+
url = {https://doi.org/10.1214/19-AOS1866}
95+
}

0 commit comments

Comments
 (0)