Skip to content

Commit 264a8b7

Browse files
authored
Merge pull request #663 from remlapmot/fix-extract-instruments-arg
Fix two issues in `extract_instruments()`
2 parents 0bf030f + 620bed3 commit 264a8b7

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
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.25
4+
Version: 0.6.26
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# TwoSampleMR v0.6.26
2+
3+
(Release date 2025-12-12)
4+
5+
* Fixed the passing of the `force_server` argument within `extract_instruments()` through to `ieugwasr::tophits()` (thanks @yikeshu0611).
6+
* Amended the `extract_instruments()` `clump` argument to additionally take values `1` or `0` as per the `ieugwasr::tophits()` `clump` argument (thanks @yikeshu0611).
7+
18
# TwoSampleMR v0.6.25
29

310
(Release date 2025-12-05)

R/instruments.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,28 @@
55
#'
66
#' @param outcomes Array of outcome IDs (see [available_outcomes()]).
77
#' @param p1 Significance threshold. The default is `5e-8`.
8-
#' @param clump Logical; whether to clump results. The default is `TRUE`.
8+
#' @param clump Whether to clump results (`1`) or not (`0`). Default is `1`. (`TRUE` and `FALSE` are also allowed for backwards compatibility.)
99
#' @param p2 Secondary clumping threshold. The default is `5e-8`.
1010
#' @param r2 Clumping r2 cut off. The default is `0.001`.
1111
#' @param kb Clumping distance cutoff. The default is `10000`.
1212
#' @param opengwas_jwt Used to authenticate protected endpoints. Login to <https://api.opengwas.io> to obtain a jwt. Provide the jwt string here, or store in .Renviron under the keyname OPENGWAS_JWT.
13-
#' @param force_server Force the analysis to extract results from the server rather than the MRInstruments package.
13+
#' @param force_server Whether to search through pre-clumped dataset or to re-extract and clump directly from the server. The default is `FALSE`.
1414
#'
1515
#' @export
1616
#' @return data frame
1717
extract_instruments <- function(
1818
outcomes,
1919
p1 = 5e-8,
20-
clump = TRUE,
20+
clump = 1,
2121
p2 = 5e-8,
2222
r2 = 0.001,
2323
kb = 10000,
2424
opengwas_jwt = ieugwasr::get_opengwas_jwt(),
2525
force_server = FALSE
2626
) {
27+
if (!(clump %in% c(0, 1, FALSE, TRUE))) stop("The clump argument should be 0 or 1.")
28+
if (clump) clump <- 1
29+
if (!clump) clump <- 0
2730
# .Deprecated("ieugwasr::tophits()")
2831
outcomes <- ieugwasr::legacy_ids(unique(outcomes))
2932

@@ -33,7 +36,7 @@ extract_instruments <- function(
3336
clump = clump,
3437
r2 = r2,
3538
kb = kb,
36-
force_server = FALSE,
39+
force_server = force_server,
3740
opengwas_jwt = opengwas_jwt,
3841
x_api_source = x_api_source_header()
3942
)

man/extract_instruments.Rd

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

tests/testthat/test_ld.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ skip_if_offline(host = "api.opengwas.io")
66
skip_on_cran()
77

88
# extract some data
9-
a <- try(extract_instruments("ieu-a-2", clump = FALSE))
9+
a <- try(extract_instruments("ieu-a-2", clump = 0))
1010
if (class(a) == "try-error") {
1111
skip("Server issues")
1212
}
@@ -37,7 +37,7 @@ test_that("matrix", {
3737

3838

3939
test_that("clump multiple", {
40-
a <- try(extract_instruments(c("ieu-a-2", "ieu-a-1001"), clump = FALSE))
40+
a <- try(extract_instruments(c("ieu-a-2", "ieu-a-1001"), clump = 0))
4141
if (class(a) == "try-error") {
4242
skip("Server issues")
4343
}

0 commit comments

Comments
 (0)