---
title: "countfitteR report"
author: ""
date: ""
output:
  html_document:
    theme: united
    toc: true
    toc_float: true
---

# Overview

```{r echo=FALSE, results='asis'}
library(knitr)
opts_chunk$set(echo=FALSE, results='asis', fig.align='center', fig.width=14, warning = FALSE)
# TO DO add warning = FALSE later
library(xtable)

source("ggtheme.R")
print_table <- function(x)
  print(xtable(x), type = "html", sanitize.colnames.function = function(x) x, digits = 4,
        include.rownames = FALSE)

```

Report generated on `r Sys.time()`.

Detected input file: `r ifelse(is.null(input[["input_file"]][["name"]]), "none", input[["input_file"]][["name"]])`.  

```{r echo=FALSE, results='asis'}


cat("MD5 sum of the input file:",  ifelse(is.null(input[["input_file"]][["name"]]), "none", tools::md5sum(input[["input_file"]][["datapath"]])))
```

Confidence level: `r input[["conf_level"]]`.  

Type of analysis: `r ifelse(input[["conf_level"]], "separate experiments", "technical replicates")`.

Models selected: `r paste0(countfitteR:::nice_model_names[input[["chosen_models"]]], collapse = ", ")`.

```{r}
if(input[["mean_value_rep"]]) {
  cat("\n",readLines("../readmes/mean_value/1.md"), sep = "    \n")
  plot(countfitteR:::plot_fitlist(fits()) + cf_theme)
  cat("\n",readLines("../readmes/mean_value/2.md"), sep = "    \n")
  fit_tab_dt()
  
}
```

```{r}
if(input[["coef_rep"]]) {
  cat("\n", readLines("../readmes/mean_value/3.md"), sep = "    \n")
  coef_tab_dt()
}
```

```{r}
if(input[["decision_rep"]]) {
  cat("\n", readLines("../readmes/mean_value/4.md"), sep = "    \n")
  cat(countfitteR:::decide(summarized_fits(), input[["sep_exp"]]))
}
```

```{r}
if(input[["cmp_distr_rep"]]) {
  cat("\n", readLines("../readmes/cmp_distr/1.md"), sep = "    \n")
  plot(countfitteR:::plot_fitcmp(compared_fits()) + cf_theme)
  cat("\n")
  cmp_sep_tab()
}
```

# R Session

```{r,results='markup'}
pander::pander(sessionInfo())
```