diff --git a/01b_MesobromionCluster.R b/01b_MesobromionCluster.R index 8b0798049143cea91d99c48cfa8ea53c0dc31686..ba3546474166410734a7f911020c717a638ad4a8 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 51a65a6948b4bee01fa52ac119faa687e1012518..912e0360ef6930b09f355d451ecb333fee9c05c3 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 722702fd477ded05c28e90b2e0e283835eaa50b7..c62e04869bbdb9542ba71fef80d667cb0e487edd 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 bfd8cecba1fb8c6e1ae82d2c2c73738bea90c0b4..56b0e1159a1dbe619f6fe516e12c29123e981191 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