comparison 09_sequence_duplication_levels.Rmd @ 0:b7c115edd970 draft

planemo upload
author mingchen0919
date Tue, 27 Feb 2018 10:37:12 -0500
parents
children c64267b9f754
comparison
equal deleted inserted replaced
-1:000000000000 0:b7c115edd970
1 ---
2 output: html_document
3 ---
4
5 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
6 knitr::opts_chunk$set(
7 echo = as.logical(opt$X_e),
8 error = TRUE,
9 eval = TRUE
10 )
11 ```
12
13
14 # Sequence Duplication Levels
15
16 ```{r 'Sequence Duplication Levels', fig.width=10}
17 ## reads 1
18 sdl_1 = extract_data_module(paste0(opt$X_d, '/read_1_fastqc/fastqc_data.txt'), 'Sequence Duplication Levels', header = FALSE, comment.char = '#')
19 names(sdl_1) = c('Duplication_Level', 'Percentage_of_deduplicated', 'Percentage_of_total')
20 sdl_1$id = 1:length(sdl_1$Duplication_Level)
21
22 melt_sdl_1 = melt(sdl_1, id=c('Duplication_Level', 'id'))
23 melt_sdl_1$trim = 'before'
24
25
26 ## reads 2
27 sdl_2 = extract_data_module(paste0(opt$X_d, '/read_2_fastqc/fastqc_data.txt'), 'Sequence Duplication Levels', header = FALSE, comment.char = '#')
28 names(sdl_2) = c('Duplication_Level', 'Percentage_of_deduplicated', 'Percentage_of_total')
29 sdl_2$id = 1:length(sdl_2$Duplication_Level)
30
31 melt_sdl_2 = melt(sdl_2, id=c('Duplication_Level', 'id'))
32 melt_sdl_2$trim = 'after'
33
34 comb_sdl = rbind(melt_sdl_1, melt_sdl_2)
35 comb_sdl$trim = factor(levels = c('before', 'after'), comb_sdl$trim)
36
37 p = ggplot(data = comb_sdl, aes(x = id, y = value, color = variable)) +
38 geom_line() +
39 scale_x_continuous(breaks = sdl_2$id, labels = sdl_2$Duplication_Level) +
40 facet_grid(. ~ trim) +
41 xlab('Sequence Duplication Level') +
42 ylab('') +
43 theme(axis.text.x = element_text(angle=45))
44 ggplotly(p)
45 ```