annotate fastqc_report.Rmd @ 14:2efa46ce2c4c draft

upgrade fastqc_report
author mingchen0919
date Wed, 18 Oct 2017 22:06:39 -0400
parents e629c2288316
children d1d20f341632
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
1 ---
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
2 title: 'HTML report title'
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
3 output:
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
4 html_document:
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
5 number_sections: true
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
6 toc: true
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
7 theme: cosmo
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
8 highlight: tango
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
9 ---
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
10
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
12 knitr::opts_chunk$set(
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
13 echo = ECHO
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
14 )
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
15 ```
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
16
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
17
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
18 # Fastqc Analysis
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
19
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
20 * Copy fastq files to job working directory
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
21
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
22 ```{bash 'copy files'}
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
23 for f in $(echo READS | sed "s/,/ /g")
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
24 do
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
25 cp $f ./
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
26 done
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
27 ```
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
28
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
29 * Run fastqc
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
30
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
31 ```{bash 'run fastqc'}
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
32 for r in $(ls *.dat)
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
33 do
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
34 fastqc -o REPORT_DIR $r > /dev/null 2>&1
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
35 done
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
36 ```
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
37
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
38 * Create links to original HTML reports
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
39
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
40 ```{r 'html report links'}
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
41 html_report_list = list()
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
42 html_files = list.files('REPORT_DIR', pattern = '.*html')
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
43 for (i in html_files) {
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
44 html_report_list[[i]] = tags$li(tags$a(href=i, i))
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
45 }
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
46 tags$ul(html_report_list)
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
47 ```
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
48
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
49 # Fastqc output summary
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
50
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
51 * Define a function to extract outputs for each module from fastqc output
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
52
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
53 ```{r 'function definition'}
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
54 extract_data_module = function(fastqc_data, module_name) {
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
55 f = readLines(fastqc_data)
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
56 start_line = grep(module_name, f)
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
57 end_module_lines = grep('END_MODULE', f)
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
58 end_line = end_module_lines[which(end_module_lines > start_line)[1]]
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
59 module_data = f[(start_line+1):(end_line-1)]
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
60 writeLines(module_data, 'temp.txt')
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
61 read.csv('temp.txt', sep = '\t')
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
62 }
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
63 ```
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
64
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
65 ##
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
66
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
67 # Session Info
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
68
14
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
69 ```{r 'session info'}
2efa46ce2c4c upgrade fastqc_report
mingchen0919
parents: 6
diff changeset
70 sessionInfo()
2
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
71 ```
0374e090e38e Uploaded
mingchen0919
parents:
diff changeset
72