changeset 12:68ea2ebbf866 draft

add boxplot for per base sequence quality
author mingchen0919
date Thu, 09 Nov 2017 09:23:43 -0500
parents 507eec497730
children 6faa68239cd7
files 02_per_base_sequence_quality.Rmd
diffstat 1 files changed, 18 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/02_per_base_sequence_quality.Rmd	Tue Nov 07 16:52:24 2017 -0500
+++ b/02_per_base_sequence_quality.Rmd	Thu Nov 09 09:23:43 2017 -0500
@@ -21,27 +21,32 @@
 ## reads 1
 pbsq_1 = extract_data_module('REPORT_DIR/reads_1_fastqc_data.txt', 'Per base sequence quality')
 pbsq_1$id = 1:length(pbsq_1$X.Base)
-
-melt_pbsq_1 = filter(melt(pbsq_1, id=c('X.Base', 'id')), variable == 'Mean')
-melt_pbsq_1$trim = 'before'
-
+pbsq_1$trim = 'before'
 
 ## reads 2
 pbsq_2 = extract_data_module('REPORT_DIR/reads_2_fastqc_data.txt', 'Per base sequence quality')
 pbsq_2$id = 1:length(pbsq_2$X.Base)
+pbsq_2$trim = 'after'
 
-melt_pbsq_2 = filter(melt(pbsq_2, id=c('X.Base', 'id')), variable == 'Mean')
-melt_pbsq_2$trim = 'after'
-
-comb_pbsq = rbind(melt_pbsq_1, melt_pbsq_2)
+comb_pbsq = rbind(pbsq_1, pbsq_2)
 comb_pbsq$trim = factor(levels = c('before', 'after'), comb_pbsq$trim)
 
 p = ggplot(data = comb_pbsq) +
-  geom_line(mapping = aes(x = id, y = value, group = variable, color = variable)) +
-  scale_x_continuous(breaks = pbsq_2$id, labels = pbsq_2$X.Base) + 
-  facet_grid(. ~ trim) + 
-  ylim(0, max(comb_pbsq$value) + 5) +
+  geom_boxplot(mapping = aes(x = id, 
+                             lower = Lower.Quartile, 
+                             upper = Upper.Quartile, 
+                             middle = Median, 
+                             ymin = X10th.Percentile, 
+                             ymax = X90th.Percentile,
+                             fill = "yellow"),
+               stat = 'identity') +
+  geom_line(mapping = aes(x = id, y = Mean, color = "red")) +
+  scale_x_continuous(breaks = pbsq_2$id, labels = pbsq_2$X.Base) +
+  scale_fill_identity() +
+  scale_color_identity() + 
+  ylim(0, max(comb_pbsq$Upper.Quartile) + 5) +
+  facet_grid(. ~ trim) +
   theme(axis.text.x = element_text(angle=45))
-ggplotly(p)
+p
 
 ```
\ No newline at end of file