Skip to content

Commit 2f0736e

Browse files
authored
Merge pull request #529 from remlapmot/v0-6-5
TwoSampleMR 0.6.5
2 parents 49fd1cb + 74046aa commit 2f0736e

20 files changed

+228
-144
lines changed

.github/workflows/check-full.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ jobs:
2525
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
2626
- {os: ubuntu-latest, r: 'release'}
2727
- {os: ubuntu-latest, r: 'oldrel-1'}
28-
- {os: ubuntu-latest, r: 'oldrel-2'}
29-
- {os: ubuntu-latest, r: 'oldrel-3'}
30-
- {os: ubuntu-latest, r: 'oldrel-4'}
28+
- {os: ubuntu-latest, r: '4.3.2'}
3129

3230
env:
3331
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -48,10 +46,7 @@ jobs:
4846
- uses: r-lib/actions/setup-r-dependencies@v2
4947
with:
5048
extra-packages: >
51-
any::rcmdcheck,
52-
randomForest=?ignore-before-r=4.1.0,
53-
car=?ignore-before-r=4.4.0,
54-
MendelianRandomization=?ignore-before-r=4.4.0
49+
any::rcmdcheck
5550
needs: check
5651

5752
- name: Create and populate .Renviron file

.github/workflows/test-coverage.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- uses: r-lib/actions/setup-r-dependencies@v2
2626
with:
27-
extra-packages: any::covr
27+
extra-packages: any::covr, any::xml2
2828
needs: coverage
2929

3030
- name: Create and populate .Renviron file
@@ -34,15 +34,22 @@ jobs:
3434

3535
- name: Test coverage
3636
run: |
37-
token <- Sys.getenv("CODECOV_TOKEN", "")
38-
covr::codecov(
37+
cov <- covr::package_coverage(
3938
quiet = FALSE,
4039
clean = FALSE,
41-
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"),
42-
token = if (token != "") token
40+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
4341
)
42+
covr::to_cobertura(cov)
4443
shell: Rscript {0}
4544

45+
- uses: codecov/codecov-action@v4
46+
with:
47+
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
48+
file: ./cobertura.xml
49+
plugin: noop
50+
disable_search: true
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
4653
- name: Show testthat output
4754
if: always()
4855
run: |

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: TwoSampleMR
22
Title: Two Sample MR Functions and Interface to MR Base Database
3-
Version: 0.6.4
3+
Version: 0.6.5
44
Authors@R: c(
55
person("Gibran", "Hemani", , "g.hemani@bristol.ac.uk", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-0920-1055")),
@@ -69,4 +69,4 @@ Remotes:
6969
WSpiller/RadialMR
7070
Encoding: UTF-8
7171
Roxygen: list(markdown = TRUE)
72-
RoxygenNote: 7.3.1
72+
RoxygenNote: 7.3.2

NEWS.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
# TwoSampleMR v0.6.5
2+
3+
(Release date: 2024-06-30)
4+
5+
* Bumped version of **roxygen2** for creating package documentation
6+
* Update the earliest version of R in the `R CMD check` GitHub Actions workflow to be 4.3.2. This is because the **meta** dependency depends on **lme4**, and the recent 1.1-35.4 release of **lme4** requires **Matrix** 1.6-2 which was released a few days after R 4.3.2.
7+
* Made package tests more robust to non-response from the OpenGWAS API
8+
19
# TwoSampleMR v0.6.4
210

311
(Release date: 2024-06-05)
412

513
* Update installation instructions in README.md
6-
714
* Fixed a bug in which the wrong indels recoding function was called (thanks @ruochiz)
815

916
# TwoSampleMR v0.6.3

R/moe.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ get_rsq <- function(dat)
171171
#' \dontrun{
172172
#' # Example of body mass index on coronary heart disease
173173
#' # Extract and harmonise data
174-
#' a <- extract_instruments(2)
174+
#' a <- extract_instruments("ieu-a-2")
175175
#' b <- extract_outcome_data(a$SNP, 7)
176-
#' dat <- harmonise_data(a,b)
176+
#' dat <- harmonise_data(a, b)
177177
#'
178178
#' # Apply all MR methods
179179
#' r <- mr_wrapper(dat)

man/mr_moe.Rd

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

tests/testthat/test_add_metadata.r

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
context("add metadata")
22

3+
skip_if_offline()
4+
skip_if_offline(host = "api.opengwas.io")
5+
skip_on_cran()
6+
37
# get required data
48
# d1 <- extract_instruments('ieu-a-2')
59
# d2 <- extract_instruments(c('ieu-a-2', 'ieu-a-7'))
@@ -18,65 +22,65 @@ context("add metadata")
1822
load(system.file("extdata", "test_add_metadata.RData", package="TwoSampleMR"))
1923

2024
test_that("exposure data 1", {
21-
skip("Skip unless you have good access to the API.")
22-
d1 <- d1 %>% add_metadata()
25+
d1 <- try(d1 %>% add_metadata())
26+
if (class(d1) == "try-error") skip("Server issues")
2327
expect_true("units.exposure" %in% names(d1))
2428
})
2529

2630
test_that("exposure data 2", {
27-
skip("Skip unless you have good access to the API.")
28-
d2 <- d2 %>% add_metadata()
31+
d2 <- try(d2 %>% add_metadata())
32+
if (class(d2) == "try-error") skip("Server issues")
2933
expect_true("units.exposure" %in% names(d2))
3034
})
3135

3236
test_that("outcome data 1", {
33-
skip("Skip unless you have good access to the API.")
34-
d3 <- d3 %>% add_metadata()
37+
d3 <- try(d3 %>% add_metadata())
38+
if (class(d3) == "try-error") skip("Server issues")
3539
expect_true("units.outcome" %in% names(d3))
3640
})
3741

3842
test_that("outcome data 2", {
39-
skip("Skip unless you have good access to the API.")
40-
d4 <- d4 %>% add_metadata()
43+
d4 <- try(d4 %>% add_metadata())
44+
if (class(d4) == "try-error") skip("Server issues")
4145
expect_true("units.outcome" %in% names(d4))
4246
})
4347

4448
test_that("dat 2", {
45-
skip("Skip unless you have good access to the API.")
46-
d5 <- d5 %>% add_metadata()
49+
d5 <- try(d5 %>% add_metadata())
50+
if (class(d5) == "try-error") skip("Server issues")
4751
expect_true("units.outcome" %in% names(d5) & "units.exposure" %in% names(d5))
4852
})
4953

5054
test_that("no id1", {
51-
skip("Skip unless you have good access to the API.")
5255
d6$id.exposure <- "not a real id"
53-
d6 <- add_metadata(d6)
56+
d6 <- try(add_metadata(d6))
57+
if (class(d6) == "try-error") skip("Server issues")
5458
expect_true(!"units.exposure" %in% names(d6))
5559
})
5660

5761
test_that("no id2", {
58-
skip("Skip unless you have good access to the API.")
5962
d7$id.outcome <- "not a real id"
60-
d7 <- add_metadata(d7)
63+
d7 <- try(add_metadata(d7))
64+
if (class(d7) == "try-error") skip("Server issues")
6165
expect_true(!"units.outcome" %in% names(d7))
6266
})
6367

6468
test_that("ukb-d", {
65-
skip("Skip unless you have good access to the API.")
66-
d8 <- add_metadata(d8)
69+
d8 <- try(add_metadata(d8))
70+
if (class(d8) == "try-error") skip("Server issues")
6771
expect_true("units.outcome" %in% names(d8))
6872
})
6973

7074
test_that("bbj-a-1", {
71-
skip("Skip unless you have good access to the API.")
72-
d9 <- d9 %>% add_metadata()
75+
d9 <- try(d9 %>% add_metadata())
76+
if (class(d9) == "try-error") skip("Server issues")
7377
expect_true("samplesize.exposure" %in% names(d9))
7478
expect_true(all(!is.na(d9$samplesize.exposure)))
7579
})
7680

7781
test_that("ieu-b-109", {
78-
skip("Skip unless you have good access to the API.")
79-
d10 <- d10 %>% add_metadata()
82+
d10 <- try(d10 %>% add_metadata())
83+
if (class(d10) == "try-error") skip("Server issues")
8084
expect_true("samplesize.exposure" %in% names(d10))
8185
expect_true(all(!is.na(d10$samplesize.exposure)))
8286
})

tests/testthat/test_eve.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ context("eve")
33
# dat <- make_dat("ieu-a-2", "ieu-a-7") %>% add_metadata()
44
load(system.file("extdata", "test_commondata.RData", package="TwoSampleMR"))
55

6-
76
test_that("wrapper", {
87
skip_if_not_installed("car")
98
expect_warning(w <- mr_wrapper(dat))

tests/testthat/test_harmonise_edge_cases.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ set.seed(1)
66
old <- options(stringsAsFactors = FALSE)
77
on.exit(options(old), add = TRUE)
88

9-
109
df <- data.frame(
1110
"SNP" = c("9_69001927_C_T", "9_69459263_A_G", "9_69508544_G_A"),
1211
"effect_allele" = c("T", "G", "A"),
@@ -47,7 +46,6 @@ df_out <- format_data(
4746
samplesize_col = "n"
4847
)
4948

50-
5149
test_that("harmonise_data works when exposure and outcome df are 1 row.", {
5250
for (i in seq(1,3)) {
5351
result <- harmonise_data(
@@ -59,7 +57,6 @@ test_that("harmonise_data works when exposure and outcome df are 1 row.", {
5957
}
6058
})
6159

62-
6360
test_that("harmonise_data works when there are no matching SNPs.", {
6461
for (i in seq(1,3)) {
6562
df_out$SNP <- paste(df_out$SNP, "foo", sep = "_")

tests/testthat/test_instruments.R

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,61 @@
11
context("Instruments")
22

3-
test_that("server and mrinstruments", {
3+
skip_if_offline()
4+
skip_if_offline(host = "api.opengwas.io")
5+
skip_on_cran()
46

5-
skip("Skip unless you have good access to the API.")
6-
7+
test_that("server and mrinstruments 1", {
78
# no no
8-
exp_dat <- extract_instruments(outcomes=c("ieu-a-1032"))
9+
exp_dat <- try(extract_instruments(outcomes=c("ieu-a-1032")))
10+
if (class(exp_dat) == "try-error") skip("Server issues")
911
expect_true(length(unique(exp_dat$id)) == 0)
12+
})
13+
1014

15+
test_that("server and mrinstruments 2", {
1116
# no yes
12-
exp_dat <- extract_instruments(outcomes=c("ebi-a-GCST004634"))
17+
exp_dat <- try(extract_instruments(outcomes=c("ebi-a-GCST004634")))
18+
if (class(exp_dat) == "try-error") skip("Server issues")
1319
expect_true(length(unique(exp_dat$id)) == 1)
14-
20+
})
21+
22+
test_that("server and mrinstruments 3", {
1523
# yes no
16-
exp_dat <- extract_instruments(outcomes=c("ieu-a-2", "ieu-a-1032"))
24+
exp_dat <- try(extract_instruments(outcomes=c("ieu-a-2", "ieu-a-1032")))
25+
if (class(exp_dat) == "try-error") skip("Server issues")
1726
expect_true(length(unique(exp_dat$id)) == 1)
27+
})
1828

29+
test_that("server and mrinstruments 4", {
1930
# yes yes
20-
exp_dat <- extract_instruments(outcomes=c("ieu-a-2", "ebi-a-GCST004634"))
31+
exp_dat <- try(extract_instruments(outcomes=c("ieu-a-2", "ebi-a-GCST004634")))
32+
if (class(exp_dat) == "try-error") skip("Server issues")
2133
expect_true(length(unique(exp_dat$id)) == 2)
34+
})
2235

23-
exp_dat <- extract_instruments(outcomes=c("ieu-a-1032", "ebi-a-GCST004634"))
36+
test_that("server and mrinstruments 5", {
37+
exp_dat <- try(extract_instruments(outcomes=c("ieu-a-1032", "ebi-a-GCST004634")))
38+
if (class(exp_dat) == "try-error") skip("Server issues")
2439
expect_true(length(unique(exp_dat$id)) == 1)
40+
})
2541

26-
exp_dat <- extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999))
42+
test_that("server and mrinstruments 6", {
43+
exp_dat <- try(extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999)))
44+
if (class(exp_dat) == "try-error") skip("Server issues")
2745
expect_true(length(unique(exp_dat$id)) == 5)
46+
})
2847

29-
exp_dat <- extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999, "ebi-a-GCST004634"))
48+
test_that("server and mrinstruments 7", {
49+
exp_dat <- try(extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999, "ebi-a-GCST004634")))
50+
if (class(exp_dat) == "try-error") skip("Server issues")
3051
expect_true(length(unique(exp_dat$id)) == 6)
3152
})
3253

3354
load(system.file("extdata", "test_commondata.RData", package="TwoSampleMR"))
3455

3556
test_that("read data", {
36-
# exp_dat <- extract_instruments("ieu-a-2")
57+
exp_dat <- try(extract_instruments("ieu-a-2"))
58+
if (class(exp_dat) == "try-error") skip("Server issues")
3759
names(exp_dat) <- gsub(".exposure", "", names(exp_dat))
3860
fn <- tempfile()
3961
write.table(exp_dat, file=fn, row=FALSE, col=TRUE, qu=FALSE, sep="\t")

0 commit comments

Comments
 (0)