annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
1 ---
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
2 title: 'Short reads evaluation with [FastQC](https://www.bioinformatics.babraham.ac.uk/projects/fastqc/)'
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
3 output:
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
4 html_document:
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
5 number_sections: true
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
6 toc: true
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
7 theme: cosmo
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
8 highlight: tango
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
9 ---
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
10
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
2
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
12 knitr::opts_knit$set(progress = FALSE)
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
13 knitr::opts_chunk$set(error = TRUE, echo = FALSE)
0
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
14 ```
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
15
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
16 # Run FastQC
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
17
2
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
18 ```{bash}
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
19 sh ${TOOL_INSTALL_DIR}/build-and-run-job-scripts.sh
0
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
20 ```
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
21
2
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
22 ```{r echo=FALSE,results='asis'}
0
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
23 # display fastqc job script
2
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
24 cat('```bash\n')
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
25 cat(readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/job-1-script.sh')), sep = '\n')
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
26 cat('\n```')
0
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
27 ```
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
28
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
29 # Fastqc Output Visualization
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
30
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
31 ## Overview
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
32
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
33 ```{r eval=TRUE}
2
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
34 read_1_summary = read.csv(paste0(opt$X_d, '/read_1_fastqc/summary.txt'),
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
35 stringsAsFactors = FALSE,
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
36 header = FALSE, sep = '\t')[, 2:1]
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
37 read_2_summary = read.csv(paste0(opt$X_d, '/read_2_fastqc/summary.txt'),
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
38 stringsAsFactors = FALSE,
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
39 header = FALSE, sep = '\t')[, 1]
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
40 combined_summary = data.frame(read_1_summary, read_2_summary, stringsAsFactors = FALSE)
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
41 names(combined_summary) = c('MODULE', 'Pre-trimming', 'Post-trimming')
0
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
42 combined_summary[combined_summary == 'FAIL'] = 'FAIL (X)'
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
43 combined_summary[combined_summary == 'WARN'] = 'WARN (!)'
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
44 knitr::kable(combined_summary)
b7c115edd970 planemo upload
mingchen0919
parents:
diff changeset
45 ```
2
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
46
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
47 ```{r 'function definition', echo=FALSE}
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
48 extract_data_module = function(fastqc_data, module_name, header = TRUE, comment.char = "") {
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
49 f = readLines(fastqc_data)
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
50 start_line = grep(module_name, f)
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
51 end_module_lines = grep('END_MODULE', f)
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
52 end_line = end_module_lines[which(end_module_lines > start_line)[1]]
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
53 module_data = f[(start_line+1):(end_line-1)]
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
54 writeLines(module_data, '/tmp/temp.txt')
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
55 read.csv('/tmp/temp.txt', sep = '\t', header = header, comment.char = comment.char)
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
56 }
c64267b9f754 planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents: 0
diff changeset
57 ```