---
title: "QC report"
author: "Created by Federal Institute for Risk Assessment (BfR)"
date: "Last updated on `r format(Sys.time(), '%d %B, %Y')`"
output: html_document
---

<style type="text/css">
.main-container {
  max-width: 2400px;
  margin-left: auto;
  margin-right: auto;
}
</style>


```{r setup, include=FALSE}


knitr::opts_chunk$set(out.width = '80%',fig.asp= 0.5,fig.align='center',echo=FALSE, warning=FALSE, message=FALSE)
options(markdown.HTML.header = system.file("misc", "datatables.html", package = "knitr"))

workdir <- snakemake@input[["workdir"]]
stats_file <- snakemake@input[["stats"]]


```


```{r table}

#print(params$file)

mytable_file <- file.path(workdir,stats_file)

if(!file.exists(mytable_file)){
  stop(paste("File",mytable_file,"does NOT exist"))
}

mytable <- read.delim(mytable_file, sep = "\t", stringsAsFactors = F)

colnames(mytable) <- gsub("_"," ",colnames(mytable))
colnames(mytable) <- gsub("^X[.]","",colnames(mytable))



# create html links
mytable[,ncol(mytable)] <- paste0("<a href=",mytable[,ncol(mytable)],">","QC report","</a>") 



DT::datatable(mytable, filter = 'top',rownames= FALSE, escape = FALSE, options = list( autoWidth = TRUE, search.regex = TRUE, searchHighlight = TRUE, pageLength = 40, scrollCollapse=TRUE,scrollX=TRUE))

```
