annotate htseq_count_render.R @ 5:aacd5f53ac99 draft

v2.0.0
author mingchen0919
date Wed, 18 Apr 2018 13:17:28 -0400
parents 0fdb0d5f53ce
children 7c54fd452b8e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
1 ##============ Sink warnings and errors to a file ==============
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
2 ## use the sink() function to wrap all code within it.
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
3 ##==============================================================
5
mingchen0919
parents: 4
diff changeset
4 zz = file(paste0(Sys.getenv('REPORT_FILES_PATH'), '/.r_rendering.log.txt'))
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
5 sink(zz)
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
6 sink(zz, type = 'message')
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
7
5
mingchen0919
parents: 4
diff changeset
8 #-------------------preparation -----------------
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
9 options(stringsAsFactors = FALSE)
5
mingchen0919
parents: 4
diff changeset
10 # import libraries
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
11 library(getopt)
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
12 library(rmarkdown)
2
db9da9716914 add r-dt
mingchen0919
parents: 1
diff changeset
13 library(htmltools)
5
mingchen0919
parents: 4
diff changeset
14 # load helper functions
mingchen0919
parents: 4
diff changeset
15 source(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/helper.R'))
mingchen0919
parents: 4
diff changeset
16 # import getopt specification matrix from a csv file
mingchen0919
parents: 4
diff changeset
17 opt = getopt(getopt_specification_matrix('getopt_specification.csv',
mingchen0919
parents: 4
diff changeset
18 tool_dir=Sys.getenv('TOOL_INSTALL_DIR')))
mingchen0919
parents: 4
diff changeset
19 # define a unix variable versions for all input values. this is useful when we
mingchen0919
parents: 4
diff changeset
20 # want to use input values by other programming language in r markdown
mingchen0919
parents: 4
diff changeset
21 do.call(Sys.setenv, opt[-1])
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
22 #------------------------------------------------
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
23
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
24
5
mingchen0919
parents: 4
diff changeset
25 #-----------------render Rmd files --------------
mingchen0919
parents: 4
diff changeset
26 # NOTICE:
mingchen0919
parents: 4
diff changeset
27 # we should copy all rmarkdown files from tool install directory to REPORT_FILES_PATH directory.
mingchen0919
parents: 4
diff changeset
28 # and render rmarkdown files in the REPORT_FILES_PATH directory.
mingchen0919
parents: 4
diff changeset
29 file.copy(from = paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/vakata-jstree-3.3.5'),
mingchen0919
parents: 4
diff changeset
30 to = Sys.getenv('REPORT_FILES_PATH'), recursive = TRUE)
mingchen0919
parents: 4
diff changeset
31 system(command = 'cp -r ${TOOL_INSTALL_DIR}/*.Rmd ${REPORT_FILES_PATH}')
mingchen0919
parents: 4
diff changeset
32 # render Rmd files in order
mingchen0919
parents: 4
diff changeset
33 render(input = paste0(Sys.getenv('REPORT_FILES_PATH'), '/htseq_count.Rmd'))
mingchen0919
parents: 4
diff changeset
34 # add more lines below if there are more Rmd files to be rendered
mingchen0919
parents: 4
diff changeset
35
mingchen0919
parents: 4
diff changeset
36 #------------------------------------------
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
37
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
38
5
mingchen0919
parents: 4
diff changeset
39 #---------------- copy the output html to REPORT ----
mingchen0919
parents: 4
diff changeset
40 system(command = 'cp ${REPORT_FILES_PATH}/htseq_count.html ${REPORT}')
mingchen0919
parents: 4
diff changeset
41 # add more lines below if there are more output html files
0
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
42
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
43 #==============the end==============
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
44
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
45
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
46 ##--------end of code rendering .Rmd templates----------------
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
47 sink()
10a460f61ac2 planemo upload
mingchen0919
parents:
diff changeset
48 ##=========== End of sinking output=============================