Skip to content

Commit

Permalink
Merge pull request MRCIEU#104 from remlapmot/fix-api-url
Browse files Browse the repository at this point in the history
Fix OpenGWAS API URL in DESCRIPTION
  • Loading branch information
explodecomputer authored Aug 22, 2024
2 parents 9f4a0bb + 172579d commit 8aa24f7
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 49 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
Expand All @@ -24,7 +26,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Create and populate .Renviron file
Expand All @@ -34,13 +36,23 @@ jobs:

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ieugwasr
Title: Interface to the 'OpenGWAS' Database API
Version: 1.0.1
Version: 1.0.2
Authors@R: c(
person("Gibran", "Hemani", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0003-0920-1055")),
Expand All @@ -11,7 +11,7 @@ Authors@R: c(
person("Rita", "Rasteiro", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0002-4217-3060"))
)
Description: Interface to the 'OpenGWAS' database API <https://gwas-api.mrcieu.ac.uk/>. Includes a wrapper
Description: Interface to the 'OpenGWAS' database API <https://api.opengwas.io/api/>. Includes a wrapper
to make generic calls to the API, plus convenience functions for
specific queries.
License: MIT + file LICENSE
Expand All @@ -34,4 +34,4 @@ VignetteBuilder:
knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ieugwasr 1.0.2

* Bump roxygen2 version
* Update OpenGWAS API URL

# ieugwasr 1.0.1

* Checking for allowance depletion, and erroring until the allowance is reset
Expand Down
3 changes: 2 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
url: https://mrcieu.github.io/ieugwasr/
template:
bootstrap: 5
light-switch: true

navbar:
structure:
left: [reference, articles, news]
right: [search, github]
right: [search, github, lightswitch]
components:
articles:
text: Tutorials
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ coverage:
informational: true

codecov:
token: 9dd0881a-47f3-4c04-8dc6-fedd9dfa8206
token: 9dd0881a-47f3-4c04-8dc6-fedd9dfa8206
2 changes: 2 additions & 0 deletions ieugwasr.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
Expand Down
2 changes: 1 addition & 1 deletion man/ieugwasr-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions tests/testthat/test_afl2.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
skip_on_cran()
# skip_on_ci()

snpinfo1 <- afl2_list()
if(inherits(snpinfo1, "response")) skip("Server issues")
snpinfo2 <- afl2_list("hapmap3")
snpinfo1 <- try(afl2_list())
if (inherits(snpinfo1, c("try-error", "response"))) skip("Server issues")
snpinfo2 <- try(afl2_list("hapmap3"))
if (inherits(snpinfo2, c("try-error", "response"))) skip("Server issues")

test_that("snplist", {
expect_true(nrow(snpinfo2) > 1000000)
Expand All @@ -15,13 +16,15 @@ test_that("snplist", {
})

test_that("ancestry", {
a <- associations(snpinfo1$rsid, "bbj-a-10", prox=FALSE)
a <- try(associations(snpinfo1$rsid, "bbj-a-10", prox=FALSE))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
res <- infer_ancestry(a, snpinfo1)
expect_true(res$pop[1] == "EAS")
})

test_that("chrpos", {
a <- afl2_chrpos("1:100000-900000")
a <- try(afl2_chrpos("1:100000-900000"))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
expect_true(nrow(a) > 100)
})

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_api.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# skip_on_cran()
# skip_on_ci()

stat <- api_status()
if(inherits(stat, "response")) skip("Server issues")
stat <- try(api_status())
if (inherits(stat, c("try-error", "response"))) skip("Server issues")

test_that("status",
{
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test_check429.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
skip_on_cran()
if(Sys.getenv("OPENGWAS_X_TEST_MODE_KEY") == "") {
test_that("no allowance", {
a <- api_query("tophits", query=list(id="ieu-a-2"), override_429=TRUE)
a <- try(api_query("tophits", query=list(id="ieu-a-2"), override_429=TRUE))
if (inherits(a, c("try-error", "response"))) skip("Server issues")

expect_warning(set_reset(a))
expect_error(check_reset())
Expand Down
29 changes: 18 additions & 11 deletions tests/testthat/test_ld.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ skip_on_cran()

library(dplyr)

a <- tophits("ieu-a-2")
if(inherits(a, "response")) skip("Server issues")
ap <- tophits("ieu-a-2", force_server=TRUE)
au <- tophits("ieu-a-2", clump=1)
a <- try(tophits("ieu-a-2"))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
ap <- try(tophits("ieu-a-2", force_server=TRUE))
if (inherits(ap, c("try-error", "response"))) skip("Server issues")
au <- try(tophits("ieu-a-2", clump=1))
if (inherits(au, c("try-error", "response"))) skip("Server issues")
b <- dplyr::tibble(rsid=au$rsid, pval=au$p, id=au$id, clump=0)
bc <- ld_clump(b)
bc <- try(ld_clump(b))
if (inherits(bc, c("try-error", "response"))) skip("Server issues")
# bcl <- ld_clump(b, bfile="/Users/gh13047/data/ld_files/data_maf0.01_rs", plink_bin="plink")

test_that("preclumped", {
Expand All @@ -31,26 +34,30 @@ test_that("ld matrix", {
)
})

ab <- tophits(c("ieu-a-2", "ieu-a-1001"))
expect_warning(ab2 <- ld_clump(ab))
test_that("multiple", {
ab <- try(tophits(c("ieu-a-2", "ieu-a-1001")))
if (inherits(ab, c("try-error", "response"))) skip("Server issues")
ab2 <- try(ld_clump(ab))
if (inherits(ab2, c("try-error", "response"))) skip("Server issues")
expect_equal(
length(unique(ab2$id)), length(unique(ab$id))
)
})


a <- tophits(c("ieu-a-2", "ieu-a-7")) %>% subset(., !duplicated(id))
expect_warning(ab <- ld_clump(a))
test_that("onesnp", {
th <- try(tophits(c("ieu-a-2", "ieu-a-7")))
if (inherits(th, c("try-error", "response"))) skip("Server issues")
a <- th %>% subset(., !duplicated(id))
expect_warning(ab <- ld_clump(a))
expect_equal(nrow(ab), 2)
})



test_that("ld_reflookup", {

a <- ld_reflookup(c("rs234", "fakesnp"), pop="AFR")
a <- try(ld_reflookup(c("rs234", "fakesnp"), pop="AFR"))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
expect_true(a == "rs234")
})

34 changes: 23 additions & 11 deletions tests/testthat/test_query.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ skip_on_cran()

library(dplyr)

a <- api_status()
if(inherits(a, "response")) skip("Server issues")
a <- try(api_status())
if (inherits(a, c("try-error", "response"))) skip("Server issues")

test_that("get_query_content", {
a <- api_query("FALSE_ENDPOINT")
a <- try(api_query("FALSE_ENDPOINT"))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
expect_true(inherits(a, "response"))
})


test_that("gwasinfo",
{
skip_on_ci()
expect_true(
nrow(api_query('gwasinfo/ieu-a-2') %>% get_query_content()) == 1
)
Expand All @@ -29,6 +31,7 @@ test_that("gwasinfo",
})

test_that("gwasinfo without token", {
skip_on_ci()
a1 <- gwasinfo("ieu-a-2", opengwas_jwt="")
a2 <- gwasinfo("ieu-a-2")
expect_true(all(a1 == a2, na.rm=TRUE))
Expand All @@ -37,6 +40,7 @@ test_that("gwasinfo without token", {

test_that("associations",
{
skip_on_ci()
expect_true(
nrow(associations(c("rs9662760", "rs12759473"), "ieu-a-2")) == 2
)
Expand All @@ -53,6 +57,7 @@ test_that("associations",

test_that("fill_n",
{
skip_on_ci()
x <- associations(c("rs12759473"), "bbj-a-10") %>% fill_n
expect_true(
is.numeric(x$n) & !is.na(x$n)
Expand All @@ -61,11 +66,11 @@ test_that("fill_n",

test_that("phewas",
{
a <- phewas("rs977747", 0.01)
if(inherits(a, "response")) skip("Server issues")
a <- try(phewas("rs977747", 0.01))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
expect_true(nrow(a)>100)
b <- phewas("rs977747", 0.01, batch=c("ieu-a"))
if(inherits(b, "response")) skip("Server issues")
b <- try(phewas("rs977747", 0.01, batch=c("ieu-a")))
if (inherits(b, c("try-error", "response"))) skip("Server issues")
expect_true(nrow(b) < nrow(a))
expect_true(nrow(b) > 0)
})
Expand All @@ -80,20 +85,26 @@ test_that("phewas",

test_that("phewas",
{
a <- phewas("1:1850428", 0.001)
a <- try(phewas("1:1850428", 0.001))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
expect_true(nrow(a)>10)
})


test_that("tophits",
{
expect_equal(nrow(tophits("ieu-a-2")), 79)
expect_true(nrow(tophits("ieu-a-2", clump=0))>79)
a <- try(tophits("ieu-a-2"))
if (inherits(a, c("try-error", "response"))) skip("Server issues")
expect_equal(nrow(a), 79)
b <- try(tophits("ieu-a-2", clump=0))
if (inherits(b, c("try-error", "response"))) skip("Server issues")
expect_true(nrow(b)>79)
})


test_that("batch", {
b <- batch_from_id(c("ieu-a-1", "ukb-b-100-10"))
b <- try(batch_from_id(c("ieu-a-1", "ukb-b-100-10")))
if (inherits(b, c("try-error", "response"))) skip("Server issues")
expect_true(all(b == c("ieu-a", "ukb-b")))
})

Expand All @@ -105,6 +116,7 @@ test_that("user", {

skip_on_cran()
skip_on_ci()
skip_if(Sys.getenv('OPENGWAS_X_TEST_MODE_KEY') != "")

# make sure valid jwt is in .Renviron
key <- get_opengwas_jwt()
Expand Down
Loading

0 comments on commit 8aa24f7

Please sign in to comment.