From 17823ad4b44b0feb9ae99ec648df34bdcc3f3939 Mon Sep 17 00:00:00 2001 From: Francesco Sabatini <francesco.sabatini@idiv.de> Date: Wed, 29 Apr 2020 16:29:16 +0200 Subject: [PATCH] Changed 01b to set relax round --- 01b_MesobromionCluster.R | 20 +++++++++++++-- cli_01b.r | 55 +++++++++++++++++++++++----------------- submit_01b.sh | 3 ++- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/01b_MesobromionCluster.R b/01b_MesobromionCluster.R index 2a73aff..74c33e5 100644 --- a/01b_MesobromionCluster.R +++ b/01b_MesobromionCluster.R @@ -55,7 +55,7 @@ get.best <- function(x, N){ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY.bootstrap", - combinations=c("all", "sequential"), start.round=NA, max.inter.t, + combinations=c("all", "sequential"), start.round=NA, relax.round=NA, max.inter.t, chunkn, chunk.i, nperm=199, ncores){ if(ncores>1){ @@ -196,7 +196,7 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY print(paste("new best at nround=", nround, "is trait combination", best)) } - if(nround>1){ + if(nround>1 & nround < relax.round){ better <- corXY.ci %>% filter(ntraits==nround) %>% filter(q025>upper) %>% @@ -219,6 +219,22 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY print(paste("new best at round=", nround, "is trait combination", best)) } else {print(paste("no new best at round=", nround))} } + + if(nround>1 & nround > relax.round){ + better <- corXY.ci %>% + filter(ntraits==nround) %>% + arrange(desc(Coef.obs)) %>% + slice(1) %>% + pull(Trait.comb) + + new.best.row <- corXY.ci %>% + filter(Trait.comb==better) + upper <- new.best.row$q975 + lower <- new.best.row$q025 + best <- better + print(paste("Assumptions relaxed - new best at round=", nround, "is trait combination", best)) + } + print(paste("save intermediate results at round", nround)) save(corXY.output, best, traits.sign.alone, corXY.ci, file = paste(output, "_round_",nround, ".RData", sep="")) } diff --git a/cli_01b.r b/cli_01b.r index 37e3175..587a2e1 100644 --- a/cli_01b.r +++ b/cli_01b.r @@ -12,7 +12,7 @@ default.ncores <- 1 # ------------------------------------------------------------------------------ options <- list ( - + make_option( opt_str = c("-c", "--ncores"), dest = "ncores", @@ -31,23 +31,23 @@ options <- list ( metavar = "4" ), - make_option( - opt_str = c("-n", "--chunkn"), - dest = "chunkn", - type = "integer", - default = 1, - help = "How many chunks?", - metavar = "4" - ), - - make_option( - opt_str = c("-i", "--chunk.i"), - dest = "chunk.i", - type = "integer", - default = NA, - help = "Which chunk?", - metavar = "4" - ), + make_option( + opt_str = c("-n", "--chunkn"), + dest = "chunkn", + type = "integer", + default = 1, + help = "How many chunks?", + metavar = "4" + ), + + make_option( + opt_str = c("-i", "--chunk.i"), + dest = "chunk.i", + type = "integer", + default = NA, + help = "Which chunk?", + metavar = "4" + ), make_option( opt_str = c("-p", "--nperm"), dest = "nperm", @@ -63,14 +63,22 @@ options <- list ( default = NA, help = "Which start round?", metavar = "4" + ), + make_option( + opt_str = c("-x", "--relax.round"), + dest = "relax.round", + type = "integer", + default = NA, + help = "After what round should the selection of new best combos stop being based on c.i.?", + metavar = "4" ) ) parser <- OptionParser( - usage = "Rscript %prog [options] data dt_beals header output", - option_list = options, - description = "\nan awesome R script", - epilogue = "use with caution, the awesomeness might slap you in the face!" + usage = "Rscript %prog [options] data dt_beals header output", + option_list = options, + description = "\nan awesome R script", + epilogue = "use with caution, the awesomeness might slap you in the face!" ) cli <- parse_args(parser, positional_arguments = 5) @@ -85,6 +93,7 @@ output <- cli$args[3] myfunction <- cli$args[4] combinations <- cli$args[5] start.round <- cli$options$start.round +start.round <- cli$options$relax.round max.inter.t <- cli$options$max.inter.t chunkn <- cli$options$chunkn chunk.i <- cli$options$chunk.i @@ -97,5 +106,5 @@ ncores <- cli$options$ncores source("01b_MesobromionCluster.R") -Mesobromion(species.path, traits.path, output, myfunction, combinations, start.round +Mesobromion(species.path, traits.path, output, myfunction, combinations, start.round, relax.round, max.inter.t, chunkn, chunk.i, nperm, ncores) diff --git a/submit_01b.sh b/submit_01b.sh index 9f3f613..6184a13 100644 --- a/submit_01b.sh +++ b/submit_01b.sh @@ -22,10 +22,11 @@ Rscript \ cli_01b.r \ --max.inter.t 20 \ --chunk.i NA \ - --chunkn 32 \ + --chunkn NA \ --nperm 999 \ --ncores ${NSLOTS:-1} \ --start.round 4 \ + --relax.round 7 \ /data/splot/HIDDEN/species.out.10perc.txt \ /data/splot/HIDDEN/traits.out.10perc.txt \ "$output" \ -- GitLab