Mercurial > repos > mingchen0919 > elastic_expose_data
annotate individuals_render.R @ 4:9ff33a3631fa draft
planemo upload commit 979e0f1c28c74ca7df02ef20c2208e9677bc820a-dirty
author | mingchen0919 |
---|---|
date | Mon, 02 Apr 2018 08:32:59 -0400 |
parents | 5838300fc1aa |
children |
rev | line source |
---|---|
3 | 1 ##============ Sink warnings and errors to a file ============== |
2 ## use the sink() function to wrap all code within it. | |
3 ##============================================================== | |
4 zz = file(Sys.getenv('TOOL_LOG')) | |
5 sink(zz) | |
6 sink(zz, type = 'message') | |
7 | |
8 #------------import libraries-------------------- | |
9 options(stringsAsFactors = FALSE) | |
10 | |
11 library(rmarkdown) | |
12 #------------------------------------------------ | |
13 | |
14 #------------------------------------------------ | |
15 options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), | |
16 sep = '|', header = TRUE) | |
17 | |
18 #------------------------------------------------ | |
19 # create three folders within working directory | |
20 dir.create('individual_outputs') | |
21 | |
4
9ff33a3631fa
planemo upload commit 979e0f1c28c74ca7df02ef20c2208e9677bc820a-dirty
mingchen0919
parents:
3
diff
changeset
|
22 job_working_dir = getwd() |
9ff33a3631fa
planemo upload commit 979e0f1c28c74ca7df02ef20c2208e9677bc820a-dirty
mingchen0919
parents:
3
diff
changeset
|
23 individual_outputs_path = paste0(job_working_dir, '/individual_outputs/') |
9ff33a3631fa
planemo upload commit 979e0f1c28c74ca7df02ef20c2208e9677bc820a-dirty
mingchen0919
parents:
3
diff
changeset
|
24 |
3 | 25 #-----------------render Rmd-------------- |
26 # copy R markdown file to working directory and render it within the working directory. | |
4
9ff33a3631fa
planemo upload commit 979e0f1c28c74ca7df02ef20c2208e9677bc820a-dirty
mingchen0919
parents:
3
diff
changeset
|
27 render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/individuals.Rmd'), |
3 | 28 output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html')) |
29 | |
30 # for some unknow reason, directly using REPORT as the input value for output_file parameter | |
31 # in the render function can cause empty report file when the tool runs in batch mode. | |
32 # the solution is to render the rmarkdown to a explicitly specified file and then copy the | |
33 # file to ${REPORT} | |
34 system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}') | |
35 # system(command = 'sh ${REPORT_FILES_PATH}/script.sh') | |
36 #------------------------------------------ | |
37 | |
38 | |
39 ##--------end of code rendering .Rmd templates---------------- | |
40 sink() | |
41 ##=========== End of sinking output============================= |