annotate fastqc_site_render.R @ 12:68ea2ebbf866 draft

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