Skip to content

Commit 2468a5e

Browse files
authored
Merge pull request #666 from remlapmot/2025-12-fixes-2
TwoSampleMR 0.6.28
2 parents 8470e3d + 0076bf9 commit 2468a5e

6 files changed

Lines changed: 56 additions & 12 deletions

File tree

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.27
4+
Version: 0.6.28
55
Authors@R: c(
66
person("Gibran", "Hemani", , "g.hemani@bristol.ac.uk", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0003-0920-1055")),

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# TwoSampleMR v0.6.28
2+
3+
(Release date 2025-12-15)
4+
5+
* Allowed the arguments for `clump_data()` to be specified from `read_exposure_data()` (thanks @al3xjwood).
6+
* Fixed two function calls in `mr_moe_single()`
7+
18
# TwoSampleMR v0.6.27
29

310
(Release date 2025-12-15)

R/moe.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ get_rsq <- function(dat) {
174174
#' # been sorted in order from most likely to least likely to
175175
#' # be accurate, based on MOE prediction
176176
#' r[[1]]$estimates
177-
#'}
177+
#' }
178178
mr_moe <- function(res, rf) {
179179
if (!requireNamespace("randomForest", quietly = TRUE)) {
180180
stop(
@@ -210,8 +210,8 @@ mr_moe_single <- function(res, rf) {
210210
)
211211
return(d)
212212
}) %>%
213-
bind_rows %>%
214-
arrange(desc(MOE))
213+
dplyr::bind_rows() %>%
214+
dplyr::arrange(desc(MOE))
215215
if ("MOE" %in% names(res$estimates)) {
216216
message("Overwriting previous MOE estimate")
217217
res$estimates <- subset(res$estimates, select = -c(MOE, method2))

R/read_data.R

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ read_outcome_data <- function(
104104
#' @param log_pval The p-value is -log10(P). The default is `FALSE`.
105105
#' @param chr_col Optional column name for chromosome. Default is `"chr"`.
106106
#' @param pos_col Optional column name for genetic position Default is `"pos"`.
107-
#'
107+
#' @inheritParams clump_data
108108
#' @export
109109
#' @return data frame
110110
read_exposure_data <- function(
@@ -128,7 +128,13 @@ read_exposure_data <- function(
128128
min_pval = 1e-200,
129129
log_pval = FALSE,
130130
chr_col = "chr",
131-
pos_col = "pos"
131+
pos_col = "pos",
132+
clump_kb = 10000,
133+
clump_r2 = 0.001,
134+
clump_p1 = 1,
135+
pop = "EUR",
136+
bfile = NULL,
137+
plink_bin = NULL
132138
) {
133139
exposure_dat <- data.table::fread(filename, header = TRUE, sep = sep)
134140
exposure_dat <- format_data(
@@ -156,7 +162,15 @@ read_exposure_data <- function(
156162
)
157163
exposure_dat$data_source.exposure <- "textfile"
158164
if (clump) {
159-
exposure_dat <- clump_data(exposure_dat)
165+
exposure_dat <- clump_data(
166+
exposure_dat,
167+
clump_kb = clump_kb,
168+
clump_r2 = clump_r2,
169+
clump_p1 = clump_p1,
170+
pop = pop,
171+
bfile = bfile,
172+
plink_bin = plink_bin
173+
)
160174
}
161175
return(exposure_dat)
162176
}
@@ -593,7 +607,7 @@ check_units <- function(x, id, col) {
593607
#' data(gwas_catalog)
594608
#' bmi <- subset(gwas_catalog, Phenotype=="Body mass index" & Year==2010 & grepl("kg", Units))
595609
#' bmi <- format_data(bmi)
596-
#'}
610+
#' }
597611
format_gwas_catalog <- function(gwas_catalog_subset, type = "exposure") {
598612
message("This function is now deprecated and has been replaced by 'format_data'.")
599613
return(NULL)

man/read_exposure_data.Rd

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/perform_mr.Rmd

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,14 +704,14 @@ MR-MoE operates by taking a set of harmonised data, inferring some characteristi
704704

705705
In order to run the analysis you must download an RData object that contains the trained random forests that are used to predict the efficacy of each method. This can be downloaded from here:
706706

707-
[dropbox.com/s/5la7y38od95swcf](dropbox.com/s/5la7y38od95swcf)
707+
<https://www.dropbox.com/s/5la7y38od95swcf>
708708

709709
**Caution: this is a large file (approx 167Mb)**
710710

711711
Once downloaded, read in the object and use the `mr_moe()` function to perform the analysis. An example is shown here, estimating the causal effect of BMI on coronary heart disease:
712712

713713
```{r eval=FALSE}
714-
# Extact instruments for BMI
714+
# Extract instruments for BMI
715715
exposure_dat <- extract_instruments("ieu-a-2")
716716
717717
# Get corresponding effects for CHD
@@ -728,6 +728,11 @@ res_all <- mr_wrapper(dat)
728728
729729
# MR-MoE - predict the performance of each method
730730
res_moe <- mr_moe(res_all, rf)
731+
732+
# Now you can view the estimates, and see that they have
733+
# been sorted in order from most likely to least likely to
734+
# be accurate, based on MOE prediction
735+
res_moe[[1]]$estimates
731736
```
732737

733738
The function does the following:
@@ -754,7 +759,7 @@ The TwoSampleMR package also provides the following functions for managing or ed
754759

755760
### Split outcome names
756761

757-
The outcome column in the output of mr() combines the original outcome name with the outcome trait ID.
762+
The outcome column in the output of `mr()` combines the original outcome name with the outcome trait ID.
758763

759764
```{r}
760765
head(res)

0 commit comments

Comments
 (0)