---
output: html_document
---

```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
  echo = as.logical(opt$X_e),
  error = TRUE,
  eval = TRUE
)
```


# Per sequence quality score

```{r 'Per sequence quality score', fig.width=10}
## reads 1
psqs_1 = extract_data_module(paste0(opt$X_d, '/read_1_fastqc/fastqc_data.txt'), 'Per sequence quality scores')
psqs_1$trim = 'before'

## reads 2
psqs_2 = extract_data_module(paste0(opt$X_d, '/read_2_fastqc/fastqc_data.txt'), 'Per sequence quality scores')
psqs_2$trim = 'after'

comb_psqs = rbind(psqs_1, psqs_2)
comb_psqs$trim = factor(levels = c('before', 'after'), comb_psqs$trim)

p = ggplot(data = comb_psqs, aes(x = X.Quality, y = Count)) + 
  geom_line(color = 'red') + 
  facet_grid(. ~ trim) + 
  xlim(min(comb_psqs$X.Quality), max(comb_psqs$X.Quality)) + 
  xlab('Mean Sequence Qaulity (Phred Score)') + 
  ylab('')
ggplotly(p)
```
