tests/testthat/test_outcomes.R

context("outcome")

skip_if_offline()
skip_if_offline(host = "api.opengwas.io")
skip_on_cran()

a <- try(extract_instruments("ieu-a-7"))
if(inherits(a, "try-error")) skip("Server issues")

test_that("outcomes 1", {
	b <- try(extract_outcome_data(a$SNP, "ieu-a-2", proxies=FALSE))
	if(inherits(b, "try-error")) skip("Server issues")
	expect_true(nrow(b) < 30 & nrow(b) > 15)
})

test_that("outcomes 2", {
	b <- try(extract_outcome_data(a$SNP, "ieu-a-2", proxies=TRUE))
	if(inherits(b, "try-error")) skip("Server issues")
	expect_true(nrow(b) > 30 & nrow(b) < nrow(a))
})

test_that("outcomes 3", {
	b <- try(extract_outcome_data(a$SNP, c("ieu-a-2", "a"), proxies=FALSE))
	if(inherits(b, "try-error")) skip("Server issues")
	expect_true(nrow(b) < 30 & nrow(b) > 15)
})

test_that("outcomes 4", {
	b <- extract_outcome_data(a$SNP, c("ieu-a-2", "a"), proxies=TRUE)
	if(inherits(b, "try-error")) skip("Server issues")
	expect_true(nrow(b) > 30 & nrow(b) < nrow(a))
})

test_that("outcomes 5", {
	b <- extract_outcome_data(a$SNP, c("ieu-a-2", "ieu-a-7"), proxies=FALSE)
	if(inherits(b, "try-error")) skip("Server issues")
	expect_true(nrow(b) > 60)
})

test_that("outcomes 6", {
	b <- extract_outcome_data(a$SNP, c("ieu-a-2", "ieu-a-7"), proxies=TRUE)
	if(inherits(b, "try-error")) skip("Server issues")
	expect_true(nrow(b) > 70)
})
MRCIEU/TwoSampleMR documentation built on Sept. 28, 2024, 6:51 p.m.