Mercurial > repos > mingchen0919 > aurora_deseq2_site
annotate rmarkdown_report_render.R @ 1:32210899a3dd draft
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author | mingchen0919 |
---|---|
date | Sun, 30 Dec 2018 12:45:56 -0500 |
parents | |
children |
rev | line source |
---|---|
1
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
1 ##============ Sink warnings and errors to a file ============== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
2 ## use the sink() function to wrap all code within it. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
3 ##============================================================== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
4 zz = file(paste0(Sys.getenv('REPORT_FILES_PATH'), '/.r_rendering.log.txt')) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
5 sink(zz) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
6 sink(zz, type = 'message') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
7 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
8 #============== preparation ==================================== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
9 # import libraries |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
10 #------------------------------------------------------------------ |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
11 # ADD MORE LIBRARIES HERE IF YOUR TOOL DEPENDS ON OTHER R LIBRARIES |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
12 #------------------------------------------------------------------ |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
13 library('getopt') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
14 library('rmarkdown') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
15 library('htmltools') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
16 library('ggplot2') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
17 library('plotly') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
18 library('DESeq2') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
19 library('pheatmap') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
20 #------------------------------------------------------------------ |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
21 options(stringsAsFactors = FALSE) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
22 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
23 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
24 # define two helper functions |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
25 #-----: helper function 1 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
26 #' \code{getopt_specification_matrix} returns a getopt specification matrix. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
27 #' |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
28 #' @param specification_file a cvs file within the \code{galaxy_tool_directory} which stores getopt specification matrix data. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
29 #' The first column are short flags, the second column are argument masks, the third column |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
30 #' is data types. The fourth column are variable names used in the tool XML. These three columns are required. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
31 #' @param gtg_name the name of a running GTG. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
32 getopt_specification_matrix = function(specification_file, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
33 gtg_name = 'gtg', |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
34 tool_dir = Sys.getenv('TOOL_INSTALL_DIR')) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
35 df = read.csv( |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
36 paste0(tool_dir, '/', specification_file), |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
37 header = TRUE, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
38 stringsAsFactors = FALSE |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
39 ) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
40 # check if there are duplicated short flags |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
41 short_flags = df[, 1] |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
42 if (length(unique(short_flags)) < length(short_flags)) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
43 cat('----Duplicated short flags found ----\n') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
44 cat('short flags: ', df[, 1][duplicated(df[, 1])], '\n') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
45 stop('Duplicated short flags are not allowed.') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
46 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
47 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
48 # use short flags to generate long flags |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
49 long_flags = paste0('X_', df[, 1]) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
50 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
51 # specification matrix |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
52 df2 = data.frame( |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
53 long_flags = long_flags, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
54 short_flags = df[, 1], |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
55 argument_mask = df[, 2], |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
56 data_type = df[, 3] |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
57 ) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
58 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
59 as.matrix(df2) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
60 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
61 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
62 #-----: helper function 2 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
63 #' \code{file_tree} generate file tree of a directory in the format of HTML lists. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
64 #' |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
65 #' @param dir the path to the directory for generating the file tree. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
66 #' @param output_dir the REPORT_FILES_PATH folder name, which has the name style: dataset_NUMBER_files. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
67 # define a recursive function to build html string of the file tree |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
68 file_tree = function(dir = '.') { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
69 # get the OUTPUT_DIR folder data: dataset_NUMBER_files |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
70 report_files_path = Sys.getenv('REPORT_FILES_PATH') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
71 output_dir = tail(strsplit(report_files_path, '/')[[1]], 1) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
72 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
73 files = list.files(path = dir, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
74 recursive = FALSE, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
75 full.names = TRUE) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
76 # files also include directorys, need to remove directorys |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
77 files = files[!dir.exists(files)] |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
78 dirs = list.dirs(path = dir, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
79 recursive = FALSE, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
80 full.names = TRUE) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
81 tags$ul({ |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
82 if (length(files) > 0) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
83 lapply(files, function(x) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
84 path_end = tail(strsplit(x, '/')[[1]], 1) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
85 href_path = strsplit(x, paste0(output_dir, '/'))[[1]][2] |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
86 li_item = tags$li(tags$a(path_end, href = href_path)) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
87 li_item$attribs = list('data-jstree' = '{"icon":"jstree-file"}') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
88 li_item |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
89 }) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
90 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
91 }, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
92 { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
93 if (length(dirs) > 0) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
94 lapply(dirs, function(x) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
95 path_end = tail(strsplit(x, '/')[[1]], 1) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
96 # hide vakata-jstree-3.3.5 folder |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
97 if (!(path_end %in% c('vakata-jstree-3.3.5', 'rmarkdown_report_files', 'site_libs'))) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
98 # x_path = strsplit(x, paste0(output_dir, '/'))[[1]][2] |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
99 li_item = tags$li(path_end, file_tree(x)) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
100 li_item$attribs = list('data-jstree' = '{"icon":"jstree-folder"}') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
101 li_item |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
102 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
103 }) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
104 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
105 }) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
106 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
107 #----------------- end of help functions ------------------------- |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
108 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
109 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
110 # import getopt specification matrix from a csv file |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
111 opt = getopt(getopt_specification_matrix('command-line-arguments.csv', |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
112 tool_dir = Sys.getenv('TOOL_INSTALL_DIR'))) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
113 # define environment variables for all input values. this is useful when we |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
114 # want to use input values by other programming language in r markdown |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
115 do.call(Sys.setenv, opt[-1]) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
116 #=============================================================== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
117 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
118 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
119 #======================== render Rmd files ========================= |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
120 # copy jstree javascript library to tool output directory |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
121 file.copy( |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
122 from = paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/vakata-jstree-3.3.5'), |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
123 to = Sys.getenv('REPORT_FILES_PATH'), |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
124 recursive = TRUE |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
125 ) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
126 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
127 # if '_site.yml' file exists, this tool is assumed to render a website. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
128 # otherwise, it renders a single html. |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
129 if (file.exists(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/_site.yml'))) { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
130 # render a website |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
131 system(command = 'cp -r ${TOOL_INSTALL_DIR}/*.Rmd ${REPORT_FILES_PATH}') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
132 system(command = 'cp -r ${TOOL_INSTALL_DIR}/_site.yml ${REPORT_FILES_PATH}') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
133 render_site(input = Sys.getenv('REPORT_FILES_PATH')) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
134 } else { |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
135 # render a single html |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
136 system(command = 'cp -r ${TOOL_INSTALL_DIR}/rmarkdown_report.Rmd ${REPORT_FILES_PATH}') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
137 # add a few lines to 'rmarkdown_report.Rmd' to generate file tree outputs |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
138 jstree_lines = ' |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
139 ## Outputs |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
140 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
141 ```{r, echo=FALSE} |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
142 tags$div(id="jstree", file_tree(Sys.getenv(\'REPORT_FILES_PATH\'))) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
143 ```' |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
144 write( |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
145 x = jstree_lines, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
146 append = TRUE, |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
147 file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/rmarkdown_report.Rmd') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
148 ) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
149 render(input = paste0(Sys.getenv('REPORT_FILES_PATH'), '/rmarkdown_report.Rmd')) |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
150 } |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
151 #=============================================================== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
152 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
153 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
154 #============== expose outputs to galaxy history =============== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
155 system(command = 'sh ${TOOL_INSTALL_DIR}/expose-outputs-to-galaxy-history.sh') |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
156 #=============================================================== |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
157 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
158 |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
159 ##--------end of code rendering .Rmd templates---------------- |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
160 sink() |
32210899a3dd
planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff
changeset
|
161 ##=========== End of sinking output============================= |