@@ -35,6 +35,34 @@ command_line_args = tibble(
3535 filteringTable = optigrab :: opt_get(' filteringTable' )) %> %
3636 glimpse()
3737
38+ # ### Define workers
39+ future :: plan(multiprocess )
40+
41+ # num_cores = availableCores() - 1
42+ num_cores = availableCores(methods = " system" ) - 1
43+
44+ tvc_cores <- as.numeric(command_line_args $ tvc_cores )
45+
46+ if (is.null(tvc_cores )){
47+ tvc_scores <- 4
48+ }
49+
50+ # workers <- floor(num_cores/tvc_cores)
51+ workers <- num_cores - 1
52+
53+
54+
55+ plan_workers <- function (workers , num_cores ){
56+ if (is.null(workers ) || workers < 1 ){
57+ workers <- 1
58+ }
59+ cat(sprintf(" Number of cores: %d and workers: %d \n " , num_cores , workers ))
60+ future :: plan(multicore , workers = workers )
61+ }
62+
63+
64+
65+
3866# ### B. create workflow plan ####
3967pkgconfig :: set_config(" drake::strings_in_dots" = " literals" )
4068ion_plan <- drake :: drake_plan(
@@ -58,12 +86,20 @@ ion_plan <- drake::drake_plan(
5886 glimpse(),
5987
6088 # ### 5. run tvc on demux bams ####
61- vcf_files = sorted_bam %T > %
89+ vcf_files = {
90+ tmp_workers <- floor(num_cores / tvc_cores )
91+ plan_workers(tmp_workers , num_cores )
92+
93+ rv <- sorted_bam %T > %
6294 map_df(~ system(paste0(" cp " , args_df $ reference , " ./" ))) %T > %
6395 map_df(~ system(paste0(" samtools faidx " , basename(args_df $ reference )))) %> %
6496 split(. $ sample ) %> %
6597 future_map_dfr(tvc_cli , args_df ) %> %
66- glimpse(),
98+ glimpse()
99+
100+ plan_workers(workers , num_cores )
101+ rv
102+ },
67103
68104 # ### 6. merge vcf files in to 1 table ####
69105 variant_table = vcf_files %> %
@@ -110,15 +146,15 @@ ion_plan <- drake::drake_plan(
110146# ### C. execute workflow plan ####
111147system(" mkdir vcf" )
112148
113- future :: plan(multiprocess )
114149
115- num_cores = availableCores() - 1
116- future :: plan( multicore , workers = num_cores )
150+ # future::plan(multicore, workers = workers)
151+ plan_workers( workers , num_cores )
117152
118153drake :: make(ion_plan )
119154# ### E. make html block for torrent server ####
120155html_block = if ( command_line_args $ is_torrent_server == " yes" ) {
121- render(" /TypeSeqHPV2/inst/typeseq2/torrent_server_html_block.R" ,
122- output_dir = " ./" )}
156+ system(" cp /TypeSeqHPV2/inst/typeseq2/torrent_server_html_block.R ./" )
123157
158+ render(" ./torrent_server_html_block.R" , output_dir = " ./" )
159+ }
124160
0 commit comments