comparison 01_skewer_analysis.Rmd @ 0:a42e58c71e5b draft default tip

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Sun, 30 Dec 2018 12:55:49 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a42e58c71e5b
1 ---
2 title: 'Skewer Analysis'
3 output:
4 html_document:
5 highlight: pygments
6 ---
7
8 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
9 knitr::opts_chunk$set(error = TRUE, echo = FALSE)
10 ```
11
12
13 ## Job script
14
15 ```{bash echo=FALSE}
16 sh ${TOOL_INSTALL_DIR}/build-and-run-job-scripts.sh
17 ```
18
19 ```{r echo=FALSE,warning=FALSE,results='asis'}
20 # display content of the job-script.sh file.
21 cat('```bash\n')
22 cat(readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/job-1-script.sh')), sep = '\n')
23 cat('\n```')
24 ```
25
26
27 # Results summary
28
29 ## Reads processing summary
30
31 ```{r echo=TRUE}
32 log = readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/trim-trimmed.log'))
33 start_line = grep('read.+processed; of these:', log)
34 end_line = grep('untrimmed.+available after processing', log)
35 processing_summary = gsub('(\\d+) ', '\\1\t', log[start_line:end_line])
36 processing_summary_df = do.call(rbind, strsplit(processing_summary, '\t'))
37 colnames(processing_summary_df) = c('Total reads:', processing_summary_df[1,1])
38 knitr::kable(processing_summary_df[-1, ])
39 ```
40
41 ## Length distribution of reads after trimming
42
43 ```{r echo=TRUE, message=FALSE, warning=FALSE}
44 start_line = grep('length count percentage', log)
45 len_dist = log[(start_line):length(log)]
46 len_dist = do.call(rbind, strsplit(len_dist, '\t'))
47 columns = len_dist[1, ]
48 len_dist = as.data.frame(len_dist[-1, ])
49 colnames(len_dist) = columns
50
51 library(plotly)
52 library(ggplot2)
53 len_dist$count = as.numeric(len_dist$count)
54 labels = as.character(len_dist$length)
55 len_dist$length = 1:nrow(len_dist)
56 pp = ggplot(data = len_dist, aes(length, count)) +
57 geom_line(color='red') +
58 scale_x_continuous(name = 'Length',
59 breaks = 1:nrow(len_dist),
60 labels = labels) +
61 theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
62 ylab('Count') +
63 ggtitle('Length distribution')
64 ggplotly(pp)
65 ```