From cd33853b51dbb1a6c4cd6811ef60c512b80d8d0b Mon Sep 17 00:00:00 2001 From: Lucas Kook Date: Wed, 10 Jul 2024 11:53:11 +0200 Subject: [PATCH 1/2] fix path --- inst/code/dependencies.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/code/dependencies.R b/inst/code/dependencies.R index bb586dd..1679d5a 100644 --- a/inst/code/dependencies.R +++ b/inst/code/dependencies.R @@ -6,7 +6,7 @@ install.packages("remotes", repos = "https://cloud.r-project.org") ### GitHub packages remotes::install_github("igraph/rigraph") -remotes::install_github("strobl/RCIT") +remotes::install_github("ericstrobl/RCIT") ### Bioconductor packages remotes::install_bioc(c("graph", "Rgraphviz", "RBGL")) From 7d2c9c3c0d259b43dc80835b61c11dd7869f3ad8 Mon Sep 17 00:00:00 2001 From: Lucas Kook Date: Thu, 11 Jul 2024 12:12:47 +0200 Subject: [PATCH 2/2] paths --- inst/code/run-simulation.R | 20 ++++++++++---------- inst/code/vis-simulation.R | 29 +++-------------------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/inst/code/run-simulation.R b/inst/code/run-simulation.R index 2437a09..fea639b 100644 --- a/inst/code/run-simulation.R +++ b/inst/code/run-simulation.R @@ -4,7 +4,6 @@ set.seed(27) # Seed parall <- FALSE # Parallel computing? -.libPaths(c("~/tutu/lib", .libPaths())) ### Command line args and defaults args <- as.numeric(commandArgs(TRUE)) @@ -110,14 +109,15 @@ fobs <- list(types = types, fml = fml, resp = resp, env = env, preds = preds, affect_variance = affect_variance) if (save) { - pvec <- c("nanc", nanc, "ndec", ndec, "panc", panc, "pdec", pdec, "penv", penv, - "stdz", stdz, "sde", round(sde, 2), "errDist", errDistAnY, errDistDeY, - "spec", spec) - outdir <- file.path( - "inst", "results", Sys.Date(), paste0(paste0( - names(pvec), pvec, collapse = ""), collapse = "_")) + specname <- switch(spec, "correct" = "results_main", + "link" = "results_link", "hidden" = "results_hidden", + "roc" = "results_binary-roc", "larger" = "results_larger") + outdir <- file.path("inst", "results", specname) + resdir <- file.path(outdir, "results") if (!dir.exists(outdir)) dir.create(outdir, recursive = TRUE) + if (!dir.exists(resdir)) + dir.create(resdir, recursive = TRUE) write_rds(fobs, file.path(outdir, "fobs.rds")) } @@ -138,7 +138,6 @@ if (TEST) { Design <- Design[ROW <- 1, ] } - # Run --------------------------------------------------------------------- suppressWarnings(file.remove(list.files(pattern = "SIMDESIGN-TEMPFILE"))) @@ -158,7 +157,8 @@ res <- runSimulation( packages = pkgs, filename = file.path(outdir, paste0("sim-results", ROW, ".rds")), save_details = list( - safe = TRUE, save_results_dirname = file.path(outdir, paste0("results-row-", ROW)), - save_seeds_dirname = file.path(outdir, "seeds") + safe = TRUE, save_results_dirname = file.path(resdir, paste0("results-row-", ROW)), + save_results_filename = paste0("results-row-", ROW), + save_seeds_dirname = file.path(resdir, "seeds") ) ) diff --git a/inst/code/vis-simulation.R b/inst/code/vis-simulation.R index e1b01b7..01403d9 100644 --- a/inst/code/vis-simulation.R +++ b/inst/code/vis-simulation.R @@ -2,7 +2,7 @@ # Visualize simulation results # LK 2023 -settings <- c("main", "app", "hidden", "link", "wald-extended", "larger") +settings <- c("main", "app", "hidden", "link", "larger") setting <- settings[as.numeric(commandArgs(TRUE))[1]] if (is.na(setting)) @@ -112,29 +112,6 @@ if (setting == "main") { fobs <- readRDS(file.path(bpath, "fobs.rds")) res <- read_sim_results(file.path(bpath, "results")) res$oicp[res$oicp == "empty"] <- "Empty" -} else if (setting == "wald-extended") { - ### paths - bpath <- file.path(rpath, "results_main") - tmods <- c(mods[-1], amods) - ttests <- tests - out <- "sim-wald-extended.pdf" - th <- 4.5 - tw <- 11 - - fobs <- readRDS(file.path(bpath, "fobs.rds")) - res <- read_sim_results(file.path(bpath, "results")) - res$oicp[res$oicp == "empty"] <- "Empty" - res <- dplyr::filter(res, test == "wald") - - bpath <- file.path(rpath, "results_wald-extended") - bfobs <- readRDS(file.path(bpath, "fobs.rds")) - bres <- read_sim_results(file.path(bpath, "results")) - bres$oicp[bres$oicp == "empty"] <- "Empty" - bres <- dplyr::filter(bres, test == "wald") - bres$test <- "wald.test" - - res <- full_join(res, bres) - } ### Summarize for plotting @@ -163,5 +140,5 @@ if (setting == "hidden") { # Vis --------------------------------------------------------------------- p1 <- vis(tmods, ttests) -ggsave(file.path(rpath, out), p1, height = th, width = tw, scale = 1) -ggsave(file.path("inst", "figures", out), p1, height = th, width = tw, scale = 1) +ggsave(file.path(rpath, out), p1, height = th, width = tw, scale = 1, create.dir = TRUE) +ggsave(file.path("inst", "figures", out), p1, height = th, width = tw, scale = 1, create.dir = TRUE)