Skip to content

Commit

Permalink
Merge pull request #716 from molgenis/test/omics
Browse files Browse the repository at this point in the history
test: xenon-omics
  • Loading branch information
timcadman committed Apr 25, 2024
2 parents cd6a734 + 67b684e commit 58908fb
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 4 deletions.
1 change: 1 addition & 0 deletions docker/ci/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ armadillo:
- dsMediation
- dsMTLBase
- dsSurvival
- dsOmics
function-blacklist: [ ]
options:
datashield:
Expand Down
5 changes: 4 additions & 1 deletion scripts/release/install_release_script_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ packages <- c(
"MolgenisArmadillo",
"DSMolgenisArmadillo",
"purrr",
"stringr"
"stringr",
"tibble"
)

install_requirements_from_cran <- function(packages) {
Expand Down Expand Up @@ -62,6 +63,8 @@ install_github("datashield/dsMediationClient", ref = "0.0.3")
install_github("https://github.com/transbioZI/dsMTLClient", ref = "0.9.9")
install_github("neelsoumya/dsSurvivalClient") # There is no version for this package
install_github("isglobal-brge/dsExposomeClient", ref = "2.0.8")
install_github('isglobal-brge/dsOmicsClient', ref = "1.0.18")


# check if all packages are installed
cli_alert_success("All packages are installed")
9 changes: 8 additions & 1 deletion scripts/release/lib/common-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ verify_output <- function(function_name = NULL, object = NULL, expected = NULL,
cli_alert_success(sprintf("%s passed", function_name))
} else {
cli_alert_danger(sprintf("%s failed", function_name))
exit_test(sprintf("%s %s", function_name, message))
exit_test(sprintf("%s %s", function_name, fail_msg))
}

}
Expand Down Expand Up @@ -261,3 +261,10 @@ resolve_many_resources <- function(resource_names) {
resource_names %>%
map(~ datashield.assign.expr(conns, symbol = .x, expr = as.symbol(paste0("as.resource.data.frame(", .x, ")"))))
}

xenon_fail_msg <- list(
srv_class = "did not create a serverside object with the expected class",
clt_class = "did not create a clientside object with the expected class",
clt_var = "did not create a clientside object with the expected variable names",
clt_list_names = "did not return a clientside list with the expected names",
clt_dim = "did not return a clientside object with the expected dimensions")
8 changes: 8 additions & 0 deletions scripts/release/release-test.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ run_exposome_tests(project = project1, url = test_config$armadillo_url, token =
user = test_config$user, admin_pwd = test_config$admin_pwd, interactive = test_config$interactive,
update_auto = test_config$update_auto)

cli_alert_info("Testing dsOmics")
source("test-cases/xenon-omics.R")
run_omics_tests(project = project1, url = test_config$armadillo_url, token = token, auth_type = test_config$auth_type,
ADMIN_MODE = test_config$ADMIN_MODE, profile = test_config$profile, profile_info = profile_info,
ref = omics_ref, skip_tests = test_config$skip_tests,
user = test_config$user, admin_pwd = test_config$admin_pwd, interactive = test_config$interactive,
update_auto = test_config$update_auto)

cli_h2("Removing data as admin")
source("test-cases/remove-data.R") # Add link_project once module works
dm_clean_up(user = test_config$user, admin_pwd = test_config$admin_pwd, required_projects = list(project1), update_auto = test_config$update_auto, url = test_config$armadillo_url, skip_tests = test_config$skip_tests, interactive = test_config$interactive)
Expand Down
9 changes: 7 additions & 2 deletions scripts/release/test-cases/test-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ configure_test <- function() {
show_version_info(c("MolgenisArmadillo", "DSI", "dsBaseClient", "DSMolgenisArmadillo", "resourcer", "dsSurvivalClient", "dsMediationClient", "dsMTLClient"))

cli_alert_success("Loaded other libraries:")
show_version_info(c("getPass", "arrow", "httr", "jsonlite", "future", "purrr", "stringr"))
show_version_info(c("getPass", "arrow", "httr", "jsonlite", "future", "purrr", "stringr", "tibble"))

cli_alert_info("Trying to read config from '.env'")
readRenviron(".env")

skip_tests <- Sys.getenv("SKIP_TESTS")
skip_tests <- str_split(skip_tests, ",")[[1]]

armadillo_url <- Sys.getenv("ARMADILLO_URL")
if (armadillo_url == "") {
cli_alert_warning("You probably did not used one of the '*.env.dist' files.")
Expand All @@ -34,6 +34,11 @@ configure_test <- function() {
} else {
cli_alert_info(paste0("ARMADILLO_URL from '.env' file: ", armadillo_url))
}

if(str_detect(armadillo_url, "localhost") & !any(skip_tests %in% "xenon-omics")){
skip_tests <- c(skip_tests, "xenon-omics")
}


interactive <- TRUE
if (Sys.getenv("INTERACTIVE") == "N") {
Expand Down
79 changes: 79 additions & 0 deletions scripts/release/test-cases/xenon-omics.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
library(dsOmicsClient)
library(purrr)
library(tibble)
gwas_prepare_data <- function() {
lapply(1:2, function(x) {
ds.GenotypeData(
x = paste0("chr", x), covars = "pheno_object",
columnId = "subject_id", sexId = "sex",
male_encoding = "male", female_encoding = "female",
case_control_column = "diabetes_diagnosed_doctor",
case = "Yes", control = "No",
newobj.name = paste0("gds.Data", x), datasources = conns
)
})
}

verify_meta_gwas <- function(gwas_results) {
gwas_dim <- dim(gwas_results)
verify_output(
function_name = "ds.metaGWAS", object = gwas_dim,
expected = as.integer(c(144785, 10)),
fail_msg = xenon_fail_msg$clt_dim
)
}

omics_ref <- tribble(
~file_name, ~path, ~url, ~object_name, ~format,
"chr1.gds", file.path(test_config$test_file_path, "chr1.gds"), "https://github.com/isglobal-brge/brge_data_large/blob/master/inst/extdata/GWAS_example/chr1_maf_filtered_small.vcf.gz?raw=true", "chr1", "VCF2GDS",
"chr2.gds", file.path(test_config$test_file_path, "chr2.gds"), "https://github.com/isglobal-brge/brge_data_large/blob/master/inst/extdata/GWAS_example/chr2_maf_filtered_small.vcf.gz?raw=true", "chr2", "VCF2GDS",
"ega_phenotypes.tsv", file.path(test_config$test_file_path, "ega_phenotypes.tsv"), "https://github.com/isglobal-brge/brge_data_large/blob/master/inst/extdata/GWAS_example/ega_synthetic_data_phenotypes_treated_with_nas.tsv?raw=true", "ega_phenotypes", "tsv"
)

run_omics_tests <- function(project, url, token, auth_type, ADMIN_MODE, profile, profile_info, ref,
skip_tests, user, admin_pwd, interactive, update_auto) {
test_name <- "xenon-omics"
if (do_skip_test(test_name, skip_tests)) {
return()
}
if (ADMIN_MODE) {
cli_alert_warning("Cannot test working with resources as basic authenticated admin")
} else if (!"resourcer" %in% profile_info$packageWhitelist) {
cli_alert_warning(sprintf("Resourcer not available for profile: %s, skipping testing using resources.", profile))
} else {
set_dm_permissions(user = user, admin_pwd = admin_pwd, required_projects = list(project), interactive = interactive, update_auto = update_auto, url = url)

download_many_sources(ref = omics_ref, skip_tests = NULL)

upload_many_sources(
project = project, ref = omics_ref, folder = "omics", url = url,
token = token, auth_type = auth_type, skip_tests = NULL
)

omics_resources <- create_many_resources(
ref = omics_ref, project = project,
folder = "omics", url = url, skip_tests = NULL
)

upload_many_resources(
project = project, folder = "omics", resource = omics_resources,
ref = omics_ref
)

assign_many_resources(project = project, folder = "omics", ref = omics_ref)

map(c("chr1", "chr2"), ~ DSI::datashield.assign.expr(
conns = conns, symbol = .x, expr = as.symbol(paste0("as.resource.object(", .x, ")"))
))

DSI::datashield.assign.expr(conns = conns, symbol = "pheno_object", expr = quote(as.resource.data.frame(ega_phenotypes)))

gwas_prepare_data()
gwas_results <- ds.metaGWAS(
genoData = paste0("gds.Data", 1:2),
model = diabetes_diagnosed_doctor ~ sex + hdl_cholesterol
)[[1]]
verify_meta_gwas(gwas_results)
}
cli_alert_success(sprintf("%s passed!", test_name))
}

0 comments on commit 58908fb

Please sign in to comment.