annotate deseq2_render.R @ 3:caae0a188548 draft

add deseq2 package
author mingchen0919
date Thu, 08 Mar 2018 21:03:01 -0500
parents 405d8fa2f560
children cadfcfb4036d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
1 ##============ Sink warnings and errors to a file ==============
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
2 ## use the sink() function to wrap all code within it.
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
3 ##==============================================================
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
4 zz = file('warnings_and_errors.txt')
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
5 sink(zz)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
6 sink(zz, type = 'message')
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
7
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
8 #------------import libraries--------------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
9 options(stringsAsFactors = FALSE)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
10
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
11 library(getopt)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
12 library(rmarkdown)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
13 library(ggplot2)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
14 library(plotly)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
15 library(htmltools)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
16 #------------------------------------------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
17
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
18
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
19 #------------get arguments into R--------------------
3
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
20 # library(dplyr)
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
21 # getopt_specification_matrix(extract_short_flags('deseq2.xml')) %>%
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
22 # write.table(file = 'spec.txt', sep = ',', row.names = FALSE, col.names = TRUE, quote = FALSE)
2
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
23
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
24
3
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
25 spec_matrix = as.matrix(
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
26 data.frame(stringsAsFactors=FALSE,
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
27 long_flags = c("X_e", "X_o", "X_d", "X_s", "X_t", "X_A", "X_B",
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
28 "X_C", "X_D", "X_E", "X_F", "X_G", "X_H", "X_I"),
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
29 short_flags = c("e", "o", "d", "s", "t", "A", "B", "C", "D", "E",
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
30 "F", "G", "H", "I", "J"),
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
31 argument_mask_flags = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
32 1L, 1L),
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
33 data_type_flags = c("character", "character", "character", "character",
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
34 "character", "character", "character", "character",
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
35 "character", "character", "character", "character",
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
36 "character", "character", "character")
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
37 )
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
38 )
2
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
39 opt = getopt(spec_matrix)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
40 #----------------------------------------------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
41
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
42
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
43 #-----------using passed arguments in R
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
44 # to define system environment variables---
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
45 do.call(Sys.setenv, opt[-1])
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
46 #----------------------------------------------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
47
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
48 #---------- often used variables ----------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
49 # OUTPUT_DIR: path to the output associated directory, which stores all outputs
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
50 # TOOL_DIR: path to the tool installation directory
3
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
51 OUTPUT_DIR = opt$X_d
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
52 TOOL_DIR = opt$X_t
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
53 RMD_NAME = 'deseq2.Rmd'
2
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
54 OUTPUT_REPORT = opt$X_o
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
55
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
56 # create the output associated directory to store all outputs
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
57 dir.create(OUTPUT_DIR, recursive = TRUE)
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
58
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
59 #-----------------render Rmd--------------
3
caae0a188548 add deseq2 package
mingchen0919
parents: 2
diff changeset
60 render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT)
2
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
61 #------------------------------------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
62
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
63 #==============the end==============
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
64
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
65
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
66 ##--------end of code rendering .Rmd templates----------------
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
67 sink()
405d8fa2f560 version 2.2.0
mingchen0919
parents:
diff changeset
68 ##=========== End of sinking output=============================