---
title: "PTXQC Quality Report"
output:
  html_document:
    mathjax: null
    number_sections: yes
    toc: yes
  pdf_document:
    toc: yes
---


<!-- the TOC (table of content) will go here - use 'toc: no' above to disable the TOC -->


<style type="text/css">
  p { 
    padding: 5px 0;
  }

  .helpSymbol {
    border: 1px solid #AAAAAA;
    padding: 3px;
    text-align: center;
    width: 100px;
  }
  .helpText {
    clear: left;
  }
  
</style>

```{r setup, include=FALSE}
## global options
knitr::opts_chunk$set(echo=FALSE, warning=TRUE, error=TRUE, message=TRUE, fig.width=8)
```

<a name="Overview"></a>

# Overview

**Quick guide**

  - navigate using the 'Table of Content' above or just scroll
  - collapse sections by just clicking their name
  - click on the "&darr; Show Help" symbol to see a description for each metric and its scoring
  - edit the config `r paste0("file:///", gsub("\\\\", "/", fh_out$yaml_file))` to
     - set the report format (HTML, plainPDF, or both)
     - disable metrics
     - customize the order of metrics
     - set individual target thresholds
  - edit `r paste0("file:///", gsub("\\\\", "/", fh_out$filename_sorting))` to customize
     - the order of Raw files in plots and heatmap
     - abbreviations of Raw file names
  - edit the Html template `r paste0("file:///", gsub("\\\\", "/", html_template))` to
     - alter the look and feel of this report (e.g. colors, font sizes, help texts, etc.)
  - report bugs and file requests via the [GitHub issue tracker](https://github.com/cbielow/PTXQC/issues)
  - full PTXQC manual available [here](https://github.com/cbielow/PTXQC)

## HeatMap
```{r MQparams, echo=FALSE, results="asis"}
hm[["plot"]]
```

## Name Mapping
```{r nameMapping, echo=FALSE, results="asis"}
for (i in 1:length(pl_nameMapping)) {
  print(pl_nameMapping[[i]])
}
```


## Metrics
```{r metrics, echo=FALSE, results="asis"}
  #for (qcm in lst_qcMetrics_ord[1:3])
  for (qcm in lst_qcMetrics_ord)
  {
    if (length(qcm$plots) == 0) next; # skip empty metrics
    v_titles = qcm$getTitles(subtitle_sep = "\n<b>")
    plots = qcm$getPlots(withTitle = FALSE)
    if (length(v_titles) != length(plots)) {
      ## this is weird...
      stop("Number of titles is unequal to number of plots ...")
    }
    last_title = ""
    for (i in 1:length(v_titles))
    {
      if (last_title != v_titles[i]) {  ## print only new titles
        cat(paste0("\n\n### ", gsub("\n", "\n<br>", v_titles[i]), "</b>\n\n"))
      }
      if (i == 1) { ## print helpText only once
        cat(paste0('\n
<div>
  <div class="helpSymbol">&darr; Show Help</div>
  <div class="helpText">', qcm$helpText, "</div>
</div>"))
      }
      print(plots[[i]])
      cat("\n<br>\n")
      last_title = v_titles[i]
    }
    cat('\n<p style="text-align: right">[back to top](#Overview)</p>\n\n')
  }
```



<script type="text/javascript">
jQuery(document).ready(function()
{
 // initially hide the help text
  jQuery(".helpText").hide();
  
  // toggle help text by clicking on the symbol
  jQuery(".helpSymbol").click(function(event)
  {
    var target = $( event.target );
    // "Show Help &darr;" is the first item in a <div> which encloses their section
    // so toggling its sibling (the actual text) will just leave the "Show Help &darr;" visible
    if ( target.is( "div" ) )
    {
      target.siblings().slideToggle(200);
      event.stopPropagation()
    }
  });
  
  
  // enable shortening the report
  jQuery(".section").click(function(event)
  {
    var target = $( event.target );
    // headings are the first item in a <div> which encloses their section
    // so toggling their siblings will just leave the heading visible
    if ( target.is( "h1, h2, h3, h4" ) )
    {
      target.siblings().slideToggle(200);
      event.stopPropagation()
    }
  });
});

</script>








