---
title: "Multiple QC Reports"
subtitle: "Quality control of reads"
output: 
  html_document:
    df_print: paged
    toc: true
    toc_float: 
      collapsed: false
---
   
   
```{r, echo = FALSE}
#Knitr settings
knitr::opts_chunk$set(
  warning=FALSE, message=FALSE, echo=TRUE, tidy=FALSE, error=FALSE,
  fig.show='hold', fig.width=3.5, fig.height = 3.5
)
options(width=150)
```
     
     
<style>
.error,.notice,.warning,.success,.question{height:auto;padding:10px 10px 10px 40px;margin:5px auto 15px;line-height:20px;border:1px solid #FFF;border-radius:4px;position:relative;display:block;text-align:left}.question{background-color:#DAEEF8;border-color:#BDE9F2}.notice{background-color:#F0F0F0;border-color:#E2E2E2}.warning{background-color:#FDF9E4;border-color:#FBECCD}.error{background-color:#F3DFDF;border-color:#ECCDD2}.success{background-color:#E0F1D9;border-color:#D7EAC7}.block,.medium-block,.small-block{border:1px solid #CCC;border-top:2px solid #366393;border-bottom:1px solid #99B1CB;background:#F2F8FF;padding:10px}.block{width:auto;margin-top:10px;margin-bottom:10px}img{background-color:#fff;background-color:#FFF;border-radius:3px;border:1px solid #CCC;box-shadow:2px 2px 12px -5px #999;margin:0 5px;margin-bottom:5px;padding:5px;text-align:center}
</style>
    
     
```{r, echo = FALSE}
if(is.null(experiment)) experiment <- "Sequencing data"
```
    
- **Date:** `r Sys.Date()`
- **Scanned QC directory (qc.path):** `r qc.path`
- **R packages:** Report generated with the R package fastqcr version `r packageDescription("fastqcr")$Version`
- **Experiment description:** `r experiment`
     
     
## Required R packages
     
```{r, echo = TRUE}
library(fastqcr)
library(dplyr)
```

     
     
## Aggregating Reports
     
     
```{r}
qc <- qc_aggregate(qc.path, progressbar = FALSE)
qc
```
   
   
Column names:   
   
- **sample**: sample names
- **module**: fastqc modules
- **status**: fastqc module status for each sample
- **tot.seq**: total sequences (i.e.: the number of reads)
- **seq.length**: sequence length
- **pct.gc**: percentage of GC content
- **pct.dup**: percentage of duplicate reads
 
   
   
```{block, type = "block"}  
The table shows, for each sample, the names of tested FastQC modules, the status of the test, as well as, some general statistics including the number of reads, the length of reads, the percentage of GC content and the percentage of duplicate reads.
```  
    
    
## Summary
   
```{r}
summary(qc)
```
    
    
Column names:
     
     
- **module**: fastqc modules
- **nb_samples**: the number of samples tested
- **nb_pass, nb_fail, nb_warn**: the number of samples that passed, failed and warned, respectively.
- **failed, warned**: the name of samples that failed and warned, respectively.

    
    
```{block, type = "block"} 
The table shows, for each FastQC module, the number and the name of samples that failed or warned.
```
    
    
## General statistics
   
   
```{r}
qc_stats(qc)
```
    
    
Column names:   
    
- *pct.dup*: the percentage of duplicate reads,
- *pct.gc*: the percentage of GC content,
- *tot.seq*: total sequences or the number of reads and 
- *seq.length*: sequence length or the length of reads.
    
    
      
```{block, type = "block"} 
The table shows, for each sample, some genral statistics such as the total number of reads, the length of reads, the percentage of GC content and the percentage of duplicate reads
```
    
## Inspecting Problems
     
### Failed modules in the most samples
    
    
```{r}
qc_fails(qc, "module")
```
   
   
```{block, type = "block"}
For each module, the number of problems (failures) and the name of samples, that failed, are shown.
```
   
   
### Warned module in the most samples
    
    
```{r}
qc_warns(qc, "module")
```
    
    
### Samples with Problems
   
   
- **Compact format**
   
```{r}
qc_problems(qc, "sample")
```
    
   
   
- **Stretched format** with details
    
    
```{r}
qc_problems(qc, "sample", compact = FALSE)
```
    
    
   
    
    
    
