|
0
|
1 ##============ Sink warnings and errors to a file ==============
|
|
|
2 ## use the sink() function to wrap all code within it.
|
|
|
3 ##==============================================================
|
|
|
4 zz = file('warnings_and_errors.txt')
|
|
|
5 sink(zz)
|
|
|
6 sink(zz, type = 'message')
|
|
|
7
|
|
|
8 #------------import libraries--------------------
|
|
|
9 options(stringsAsFactors = FALSE)
|
|
|
10
|
|
|
11 library(getopt)
|
|
|
12 library(rmarkdown)
|
|
|
13 library(DESeq2)
|
|
|
14 library(pheatmap)
|
|
|
15 library(DT)
|
|
|
16 #------------------------------------------------
|
|
|
17
|
|
|
18
|
|
|
19 #------------get arguments into R--------------------
|
|
3
|
20 # getopt_specification_matrix(extract_short_flags('')) %>%
|
|
0
|
21 # write.table(file = 'spec.txt', sep = ',', row.names = FALSE, col.names = TRUE, quote = FALSE)
|
|
|
22
|
|
|
23
|
|
3
|
24 spec_matrix = as.matrix(
|
|
|
25 data.frame(stringsAsFactors=FALSE,
|
|
|
26 long_flags = c("X_e", "X_o", "X_d", "X_s", "X_t", "X_P", "X_N",
|
|
|
27 "X_S", "X_p", "X_w"),
|
|
|
28 short_flags = c("e", "o", "d", "s", "t", "P", "N", "S", "p", "w"),
|
|
|
29 argument_mask_flags = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
|
|
|
30 data_type_flags = c("character", "character", "character", "character",
|
|
|
31 "character", "character", "character",
|
|
|
32 "character", "character", "character")
|
|
|
33 )
|
|
|
34 )
|
|
0
|
35 opt = getopt(spec_matrix)
|
|
|
36 #----------------------------------------------------
|
|
|
37
|
|
|
38
|
|
|
39 #-----------using passed arguments in R
|
|
|
40 # to define system environment variables---
|
|
|
41 do.call(Sys.setenv, opt[-1])
|
|
|
42 #----------------------------------------------------
|
|
|
43
|
|
|
44 #---------- often used variables ----------------
|
|
|
45 # OUTPUT_DIR: path to the output associated directory, which stores all outputs
|
|
|
46 # TOOL_DIR: path to the tool installation directory
|
|
|
47 # RMD_NAME: name of Rmd file to be rendered
|
|
3
|
48 # OUTPUT_REPORT: path to galaxy output report
|
|
0
|
49 OUTPUT_DIR = opt$X_d
|
|
|
50 TOOL_DIR = opt$X_t
|
|
|
51 RMD_NAME = 'DESeq.Rmd'
|
|
|
52 OUTPUT_REPORT = opt$X_o
|
|
|
53
|
|
|
54 # create the output associated directory to store all outputs
|
|
3
|
55 dir.create(OUTPUT_DIR, recursive = TRUE)
|
|
0
|
56
|
|
|
57 #-----------------render Rmd--------------
|
|
3
|
58 render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT)
|
|
0
|
59 #------------------------------------------
|
|
|
60
|
|
|
61 #==============the end==============
|
|
|
62
|
|
|
63
|
|
|
64 ##--------end of code rendering .Rmd templates----------------
|
|
|
65 sink()
|
|
|
66 ##=========== End of sinking output============================= |