annotate fastqc_site_render.R @ 15:a6f8382f852c draft default tip

remove unnecessary dependencies
author mingchen0919
date Thu, 09 Nov 2017 09:49:39 -0500
parents 507eec497730
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
1 library(getopt)
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
2 library(rmarkdown)
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
3 library(htmltools)
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
4 library(plyr)
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
5 library(dplyr)
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
6 library(stringr)
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
7 library(DT)
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
8 library(reshape2)
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
9 library(plotly)
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
10 options(stringsAsFactors=FALSE, useFancyQuotes=FALSE)
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
11
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
12 ##============ Sink warnings and errors to a file ==============
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
13 ## use the sink() function to wrap all code within it.
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
14 ##==============================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
15 zz = file('warnings_and_errors.txt')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
16 sink(zz)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
17 sink(zz, type = 'message')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
18 ##---------below is the code for rendering .Rmd templates-----
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
19
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
20 ##=============STEP 1: handle command line arguments==========
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
21 ##
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
22 ##============================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
23 # column 1: the long flag name
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
24 # column 2: the short flag alias. A SINGLE character string
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
25 # column 3: argument mask
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
26 # 0: no argument
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
27 # 1: argument required
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
28 # 2: argument is optional
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
29 # column 4: date type to which the flag's argument shall be cast.
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
30 # possible values: logical, integer, double, complex, character.
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
31 #-------------------------------------------------------------
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
32 #++++++++++++++++++++ Best practice ++++++++++++++++++++++++++
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
33 # 1. short flag alias should match the flag in the command section in the XML file.
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
34 # 2. long flag name can be any legal R variable names
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
35 # 3. two names in args_list can have common string but one name should not be a part of another name.
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
36 # for example, one name is "ECHO", if another name is "ECHO_XXX", it will cause problems.
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
37 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
38 args_list=list()
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
39 ##------- 1. input data ---------------------
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
40 args_list$ECHO = c('echo', 'e', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
41 args_list$READS_1 = c('reads_1', 'r', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
42 args_list$NAME_1 = c('name_1', 'n', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
43 args_list$READS_2 = c('reads_2', 'R', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
44 args_list$NAME_2 = c('name_2', 'N', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
45 args_list$CONTAMINANTS = c('contaminants', 'c', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
46 args_list$LIMITS = c('limits', 'l', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
47 ##--------2. output report and outputs --------------
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
48 args_list$REPORT_HTML = c('report_html', 'o', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
49 args_list$REPORT_DIR = c('report_dir', 'd', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
50 args_list$SINK_MESSAGE = c('sink_message', 's', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
51 ##--------3. .Rmd templates in the tool directory ----------
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
52 args_list$SITE_YML = c('site_yml', 'S', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
53 args_list$INDEX_RMD = c('index_rmd', 'I', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
54 args_list$X01_EVALUATION_OVERVIEW = c('x01_evaluation_overview', 'A', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
55 args_list$X02_PER_BASE_SEQUENCE_QUALITY = c('x02_per_base_sequence_quality', 'B', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
56 args_list$X03_PER_TILE_SEQUENCE_QUALITY = c('x03_per_tile_sequence_quality', 'C', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
57 args_list$X04_PER_SEQUENCE_QUALITY_SCORE = c('x04_per_sequence_quality_score', 'D', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
58 args_list$X05_PER_BASE_SEQUENCE_CONTENT = c('x05_per_base_sequence_content', 'E', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
59 args_list$X06_PER_SEQUENCE_GC_CONTENT = c('x06_per_sequence_gc_content', 'F', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
60 args_list$X07_PER_BASE_N_CONTENT = c('x07_per_base_n_content', 'G', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
61 args_list$X08_SEQUENCE_LENGTH_DISTRIBUTION = c('x08_sequence_length_distribution', 'H', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
62 args_list$X09_SEQUENCE_DUPLICATION_LEVELS = c('x09_sequence_duplication_levels', 'J', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
63 args_list$X10_ADAPTER_CONTENT = c('x10_adapter_content', 'K', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
64 args_list$X11_KMER_CONTENT = c('x11_kmer_content', 'L', '1', 'character')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
65 ##-----------------------------------------------------------
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
66 opt = getopt(t(as.data.frame(args_list)))
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
67
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
68
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
69
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
70 ##=======STEP 2: create report directory (optional)==========
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
71 ##
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
72 ##===========================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
73 dir.create(opt$report_dir)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
74
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
75 ##==STEP 3: copy index.Rmd and _site.yml to job working directory======
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
76 ##
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
77 ##=====================================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
78 file.copy(opt$index_rmd, 'index.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
79 file.copy(opt$site_yml, '_site.yml')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
80
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
81 ##=STEP 4: replace placeholders in .Rmd files with argument values=
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
82 ##
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
83 ##=================================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
84 #++ need to replace placeholders with args values one by one+
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
85
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
86 # 01_evaluation_overview.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
87 readLines(opt$x01_evaluation_overview) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
88 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
89 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
90 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
91 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
92 gsub('READS_1', opt$reads_1, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
93 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
94 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
95 gsub('NAME_1', opt$name_1, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
96 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
97 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
98 gsub('READS_2', opt$reads_2, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
99 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
100 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
101 gsub('NAME_2', opt$name_1, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
102 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
103 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
104 gsub('CONTAMINANTS', opt$contaminants, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
105 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
106 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
107 gsub('LIMITS', opt$limits, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
108 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
109 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
110 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
111 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
112 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
113 fileConn = file('x01_evaluation_overview.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
114 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
115 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
116 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
117
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
118 # 02_per_base_sequence_quality.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
119 readLines(opt$x02_per_base_sequence_quality) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
120 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
121 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
122 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
123 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
124 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
125 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
126 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
127 fileConn = file('x02_per_base_sequence_quality.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
128 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
129 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
130 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
131
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
132 # 03_per_tile_sequence_quality.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
133 readLines(opt$x03_per_tile_sequence_quality) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
134 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
135 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
136 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
137 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
138 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
139 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
140 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
141 fileConn = file('x03_per_tile_sequence_quality.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
142 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
143 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
144 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
145
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
146 # 04_per_sequence_quality_score.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
147 readLines(opt$x04_per_sequence_quality_score) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
148 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
149 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
150 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
151 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
152 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
153 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
154 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
155 fileConn = file('x04_per_sequence_quality_score.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
156 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
157 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
158 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
159
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
160 # 05_per_base_sequence_content.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
161 readLines(opt$x05_per_base_sequence_content) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
162 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
163 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
164 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
165 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
166 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
167 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
168 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
169 fileConn = file('x05_per_base_sequence_content.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
170 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
171 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
172 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
173
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
174 # 06_per_sequence_gc_content.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
175 readLines(opt$x06_per_sequence_gc_content) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
176 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
177 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
178 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
179 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
180 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
181 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
182 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
183 fileConn = file('x06_per_sequence_gc_content.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
184 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
185 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
186 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
187
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
188 # 07_per_base_n_content.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
189 readLines(opt$x07_per_base_n_content) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
190 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
191 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
192 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
193 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
194 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
195 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
196 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
197 fileConn = file('x07_per_base_n_content.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
198 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
199 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
200 })
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
201
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
202 # 08_sequence_length_distribution.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
203 readLines(opt$x08_sequence_length_distribution) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
204 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
205 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
206 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
207 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
208 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
209 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
210 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
211 fileConn = file('x08_sequence_length_distribution.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
212 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
213 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
214 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
215
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
216 # 09_sequence_duplication_levels.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
217 readLines(opt$x09_sequence_duplication_levels) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
218 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
219 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
220 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
221 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
222 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
223 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
224 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
225 fileConn = file('x09_sequence_duplication_levels.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
226 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
227 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
228 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
229
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
230 # 10_adapter_content.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
231 readLines(opt$x10_adapter_content) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
232 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
233 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
234 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
235 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
236 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
237 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
238 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
239 fileConn = file('x10_adapter_content.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
240 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
241 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
242 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
243
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
244 # 11_kmer_content.Rmd
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
245 readLines(opt$x11_kmer_content) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
246 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
247 gsub('ECHO', opt$echo, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
248 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
249 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
250 gsub('REPORT_DIR', opt$report_dir, x)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
251 }) %>%
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
252 (function(x) {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
253 fileConn = file('x11_kmer_content.Rmd')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
254 writeLines(x, con=fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
255 close(fileConn)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
256 })
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
257
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
258 ##=============STEP 5: render all .Rmd templates=================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
259 ##
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
260 ##===========================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
261 extract_data_module = function(fastqc_data, module_name, header = TRUE, comment.char = "") {
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
262 f = readLines(fastqc_data)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
263 start_line = grep(module_name, f)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
264 end_module_lines = grep('END_MODULE', f)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
265 end_line = end_module_lines[which(end_module_lines > start_line)[1]]
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
266 module_data = f[(start_line+1):(end_line-1)]
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
267 writeLines(module_data, 'temp.txt')
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
268 read.csv('temp.txt', sep = '\t', header = header, comment.char = comment.char)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
269 }
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
270 render_site()
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
271
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
272 ##=============STEP 6: manipulate outputs====================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
273 ##
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
274 ##===========================================================
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
275 file.copy('my_site/index.html', opt$report_html, recursive = TRUE)
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
276 system(paste0('cp -r my_site/* ', opt$report_dir))
7
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
277
d820be692d74 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit d91f269e8bc09a488ed2e005122bbb4a521f44a0-dirty
mingchen0919
parents:
diff changeset
278
11
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
279 ##--------end of code rendering .Rmd templates----------------
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
280 sink()
507eec497730 update fastqc site
mingchen0919
parents: 7
diff changeset
281 ##=========== End of sinking output=============================