diff --git a/DESCRIPTION b/DESCRIPTION index 71f2c80b1..31fe5ade5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: TwoSampleMR Title: Two Sample MR Functions and Interface to MRC Integrative Epidemiology Unit OpenGWAS Database -Version: 0.7.9 +Version: 0.7.10 Authors@R: c( person("Gibran", "Hemani", , "g.hemani@bristol.ac.uk", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0920-1055")), diff --git a/NEWS.md b/NEWS.md index c293a255b..49e885269 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# TwoSampleMR v0.7.10 + +(Release date 2026-09-24) + +* Fixed the removal of duplicated proxy SNPs in `extract_outcome_data()`, which since v0.6.30 ignored its intended grouping by outcome and emitted the warning "Ignoring by/keyby because 'j' is not supplied" whenever proxies were used. Results were unaffected because proxies are looked up one outcome at a time. (thanks @amymariemason for the report) + # TwoSampleMR v0.7.9 (Release date 2026-06-24) diff --git a/R/query.R b/R/query.R index 36cc3f2d9..7cdcb1488 100644 --- a/R/query.R +++ b/R/query.R @@ -286,7 +286,7 @@ format_d <- function(d) { # If two SNPs have the same proxy SNP then one has to be removed d <- data.table::as.data.table(d) - d <- d[!duplicated(proxy_snp.outcome), , by = outcome] + d <- d[!duplicated(d, by = c("outcome", "proxy_snp.outcome"))] data.table::setDF(d) } else { d <- d1 diff --git a/justfile b/justfile index 6f36eb563..9ebf294e6 100644 --- a/justfile +++ b/justfile @@ -1,8 +1,16 @@ docs: - R -e "devtools::document()" + Rscript -e "devtools::document()" check: docs - R -e "devtools::check()" + Rscript -e "devtools::check()" +test: + Rscript -e "devtools::test()" +test-server: + TWOSAMPLEMR_ENABLE_OPENGWAS_TESTS=TRUE Rscript -e "devtools::test()" install: docs - R -e "devtools::install(build_vignettes = TRUE)" + Rscript -e "devtools::install(build_vignettes = TRUE)" +install-fast: docs + Rscript -e "pkg <- pkgbuild::build(dest_path = tempdir(), vignettes = FALSE); install.packages(pkg, repos = NULL, type = 'source')" dev: - R -e "pak::local_install_dev_deps()" + Rscript -e "pak::local_install_dev_deps()" +readme: + Rscript -e "rmarkdown::render('README.Rmd', output_options = list(html_preview = FALSE))" diff --git a/tests/testthat/test_format_d.R b/tests/testthat/test_format_d.R new file mode 100644 index 000000000..dfc062058 --- /dev/null +++ b/tests/testthat/test_format_d.R @@ -0,0 +1,26 @@ +test_that("format_d() removes duplicated proxy SNPs within each outcome without warning", { + d <- data.frame( + rsid = c("rs1", "rs2", "rs1", "rs2"), + chr = "1", + position = c(100, 200, 100, 200), + beta = 0.1, + se = 0.01, + n = 1000, + p = 1e-8, + eaf = 0.3, + ea = "A", + nea = "G", + trait = c("Trait A", "Trait A", "Trait B", "Trait B"), + id = c("id-a", "id-a", "id-b", "id-b"), + proxy = TRUE, + target_snp = c("rs1", "rs2", "rs1", "rs2"), + proxy_snp = "rs3", + target_a1 = "A", + target_a2 = "G", + proxy_a1 = "A", + proxy_a2 = "G" + ) + expect_no_warning(out <- format_d(d)) + expect_equal(nrow(out), 2) + expect_setequal(out$id.outcome, c("id-a", "id-b")) +})