comparison 01_evaluation_overview.Rmd @ 2:c64267b9f754 draft default tip

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Sun, 30 Dec 2018 12:48:14 -0500
parents b7c115edd970
children
comparison
equal deleted inserted replaced
1:92e3de11b9f8 2:c64267b9f754
7 theme: cosmo 7 theme: cosmo
8 highlight: tango 8 highlight: tango
9 --- 9 ---
10 10
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE} 11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
12 knitr::opts_chunk$set( 12 knitr::opts_knit$set(progress = FALSE)
13 echo = as.logical(opt$X_e), 13 knitr::opts_chunk$set(error = TRUE, echo = FALSE)
14 error = TRUE,
15 eval = TRUE
16 )
17 ``` 14 ```
18 15
19 # Run FastQC 16 # Run FastQC
20 17
21 ```{bash eval=TRUE,echo=FALSE} 18 ```{bash}
22 cd ${X_d} 19 sh ${TOOL_INSTALL_DIR}/build-and-run-job-scripts.sh
23 cp ${X_r} ${X_d}/read_1.fq
24 cp ${X_R} ${X_d}/read_2.fq
25
26 cat >temp.sh <<EOL
27 fastqc \\
28 -q \\
29 -c ${X_c} \\
30 -l ${X_l} \\
31 ${X_d}/read_1.fq > /dev/null 2>&1
32
33 fastqc \\
34 -q \\
35 -c ${X_c} \\
36 -l ${X_l} \\
37 ${X_d}/read_2.fq > /dev/null 2>&1
38 EOL
39
40 grep -v None temp.sh > fastqc.sh
41
42 # run fastqc
43 sh fastqc.sh
44
45 # unzip outputs
46 unzip -q read_1_fastqc.zip
47 unzip -q read_2_fastqc.zip
48 ``` 20 ```
49 21
50 ```{r} 22 ```{r echo=FALSE,results='asis'}
51 # display fastqc job script 23 # display fastqc job script
52 fastqc_sh = paste0(opt$X_d, '/fastqc.sh') 24 cat('```bash\n')
53 tags$code(tags$pre(readChar(fastqc_sh, file.info(fastqc_sh)$size ))) 25 cat(readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/job-1-script.sh')), sep = '\n')
26 cat('\n```')
54 ``` 27 ```
55
56 # Raw FastQC reports
57
58 ## Before trimming
59 ```{r eval=TRUE}
60 ori_html = tags$a(href = 'read_1_fastqc/fastqc_report.html', opt$X_n)
61 ori_fastqc_data = tags$a(href = 'read_1_fastqc/fastqc_data.txt', 'fastqc_data.txt')
62 ori_summary = tags$a(href = 'read_1_fastqc/summary.txt', 'summary.txt')
63 tags$ul(
64 tags$li(ori_html),
65 tags$li(ori_fastqc_data),
66 tags$li(ori_summary)
67 )
68 ```
69
70 ## After trimming
71 ```{r eval=TRUE}
72 ori_html = tags$a(href = 'read_2_fastqc/fastqc_report.html', opt$X_n)
73 ori_fastqc_data = tags$a(href = 'read_2_fastqc/fastqc_data.txt', 'fastqc_data.txt')
74 ori_summary = tags$a(href = 'read_2_fastqc/summary.txt', 'summary.txt')
75 tags$ul(
76 tags$li(ori_html),
77 tags$li(ori_fastqc_data),
78 tags$li(ori_summary)
79 )
80 ```
81
82 28
83 # Fastqc Output Visualization 29 # Fastqc Output Visualization
84 30
85 ## Overview 31 ## Overview
86 32
87 ```{r eval=TRUE} 33 ```{r eval=TRUE}
88 read_1_summary = read.csv(paste0(opt$X_d, '/read_1_fastqc/summary.txt'), header = FALSE, sep = '\t')[, 2:1] 34 read_1_summary = read.csv(paste0(opt$X_d, '/read_1_fastqc/summary.txt'),
89 read_2_summary = read.csv(paste0(opt$X_d, '/read_2_fastqc/summary.txt'), header = FALSE, sep = '\t')[, 1] 35 stringsAsFactors = FALSE,
90 combined_summary = cbind(read_1_summary, read_2_summary) 36 header = FALSE, sep = '\t')[, 2:1]
91 names(combined_summary) = c('MODULE', paste0(opt$X_n, '(before)'), paste0(opt$X_N, '(after)')) 37 read_2_summary = read.csv(paste0(opt$X_d, '/read_2_fastqc/summary.txt'),
38 stringsAsFactors = FALSE,
39 header = FALSE, sep = '\t')[, 1]
40 combined_summary = data.frame(read_1_summary, read_2_summary, stringsAsFactors = FALSE)
41 names(combined_summary) = c('MODULE', 'Pre-trimming', 'Post-trimming')
92 combined_summary[combined_summary == 'FAIL'] = 'FAIL (X)' 42 combined_summary[combined_summary == 'FAIL'] = 'FAIL (X)'
93 combined_summary[combined_summary == 'WARN'] = 'WARN (!)' 43 combined_summary[combined_summary == 'WARN'] = 'WARN (!)'
94 knitr::kable(combined_summary) 44 knitr::kable(combined_summary)
95 ``` 45 ```
46
47 ```{r 'function definition', echo=FALSE}
48 extract_data_module = function(fastqc_data, module_name, header = TRUE, comment.char = "") {
49 f = readLines(fastqc_data)
50 start_line = grep(module_name, f)
51 end_module_lines = grep('END_MODULE', f)
52 end_line = end_module_lines[which(end_module_lines > start_line)[1]]
53 module_data = f[(start_line+1):(end_line-1)]
54 writeLines(module_data, '/tmp/temp.txt')
55 read.csv('/tmp/temp.txt', sep = '\t', header = header, comment.char = comment.char)
56 }
57 ```