From 4798a781507eed876d90886577c95fd70239a865 Mon Sep 17 00:00:00 2001 From: Francesco Sabatini <francesco.sabatini@idiv.de> Date: Mon, 27 Apr 2020 10:32:22 +0200 Subject: [PATCH] Added new argument start.round --- 01b_MesobromionCluster.R | 17 +++++++++++------ cli_01b.r | 3 ++- session.R | 5 +++-- submit_01b.sh | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/01b_MesobromionCluster.R b/01b_MesobromionCluster.R index 8b07980..ba35464 100644 --- a/01b_MesobromionCluster.R +++ b/01b_MesobromionCluster.R @@ -55,7 +55,8 @@ get.best <- function(x, N){ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY.bootstrap", - combinations=c("all", "sequential"), max.inter.t, chunkn, chunk.i, nperm=199, ncores){ + combinations=c("all", "sequential"), start.round=NA, max.inter.t, + chunkn, chunk.i, nperm=199, ncores){ if(ncores>1){ require(parallel) @@ -72,9 +73,9 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY species <- read_delim(species.path, delim="\t") %>% as.data.frame() traits <- read_delim(traits.path, delim="\t") %>% - as.data.frame() %>% + as.data.frame() #%>% ### TEMPORARY FOR TESTING! - dplyr::select(1:11) + #dplyr::select(1:11) traits <- traits %>% @@ -115,8 +116,11 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY if(combinations=="sequential"){ - corXY.ci <- NULL - for(nround in 1:max.inter.t){ + if(!is.na(start.round)){ + print(paste("Load data from previous round=", start.round-1)) + load(file = paste(output, "_round_", start.round-1, ".RData", sep="")) + } else {corXY.ci <- NULL} + for(nround in start.round:max.inter.t){ corXY.output <- NULL ## select combination of traits based on best if(nround==1) { @@ -211,8 +215,9 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY } else {print(paste("no new best at round=", nround))} } print(paste("save intermediate results at round", nround)) - save(corXY.output, file = paste(output, "_round_",nround, ".RData", sep="")) + save(corXY.output, best, traits.sign.alone, corXY.ci, file = paste(output, "_round_",nround, ".RData", sep="")) } } if(ncores>1){stopCluster(cl)} } + diff --git a/cli_01b.r b/cli_01b.r index 51a65a6..912e036 100644 --- a/cli_01b.r +++ b/cli_01b.r @@ -65,7 +65,7 @@ parser <- OptionParser( epilogue = "use with caution, the awesomeness might slap you in the face!" ) -cli <- parse_args(parser, positional_arguments = 5) +cli <- parse_args(parser, positional_arguments = 6) # ------------------------------------------------------------------------------ # assign a few shortcuts @@ -76,6 +76,7 @@ traits.path <- cli$args[2] output <- cli$args[3] myfunction <- cli$args[4] combinations <- cli$args[5] +start.round <- cli$args[6] max.inter.t <- cli$options$max.inter.t chunkn <- cli$options$chunkn chunk.i <- cli$options$chunk.i diff --git a/session.R b/session.R index 722702f..c62e048 100644 --- a/session.R +++ b/session.R @@ -6,11 +6,12 @@ myfunction <- "get.corXY.bootstrap" max.inter.t <- 3 chunk.i <- NA nperm <- 20 -ncores <- 10 +ncores <- 1 chunkn <- 3*ncores combinations <- "sequential" +start.round <- 4 source("01b_MesobromionCluster.R") #Mesobromion(species.path, traits.path, output, myfunction, max.inter.t, chunkn, chunk.i, nperm) -Mesobromion(species.path, traits.path, output, myfunction, combinations, max.inter.t, +Mesobromion(species.path, traits.path, output, myfunction, combinations, start.round, max.inter.t, chunkn, chunk.i, nperm, ncores) diff --git a/submit_01b.sh b/submit_01b.sh index bfd8cec..56b0e11 100644 --- a/submit_01b.sh +++ b/submit_01b.sh @@ -29,4 +29,5 @@ Rscript \ /data/splot/HIDDEN/traits.out.10perc.txt \ "$output" \ "get.corXY.bootstrap" \ - "sequential" + "sequential" \ + 4 -- GitLab