Skip to content

Commit b6617dd

Browse files
committed
fixed detect cores for windows
1 parent 5b7284b commit b6617dd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

R/ppcSeq.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,16 @@ do_inference = function(my_df,
833833
ifelse_pipe(pass_fit, ~ .x %>% add_attr(fit, "fit") )
834834
}
835835

836+
detect_cores = function(){
837+
838+
if(.Platform$OS.type == "unix")
839+
system("nproc", intern = TRUE) %>% as.integer %>% sum(-1)
840+
else if(.Platform$OS.type == "windows")
841+
parallel::detectCores() %>% as.integer %>% sum(-1)
842+
else stop("Your platform type is not recognised")
843+
844+
}
845+
836846
#' pcc_seq main
837847
#'
838848
#' @description This function calls the stan model.
@@ -876,7 +886,7 @@ ppc_seq = function(input.df,
876886
# For development purpose
877887
additional_parameters_to_save = c(),
878888
# For development purpose,
879-
cores = system("nproc", intern = TRUE) %>% as.integer %>% sum(-1),
889+
cores = detect_cores(),
880890
percent_false_positive_genes = "1%", pass_fit = F,
881891
do_check_only_on_detrimental = parse_formula(formula) %>% length %>% `>` (0),
882892
tol_rel_obj = 0.01,

0 commit comments

Comments
 (0)