---
title: "biocharkit GUI \u2014 Session Report"
date: "`r format(Sys.time(), '%Y-%m-%d %H:%M')`"
output: html_document
params:
  store: NULL
---

```{r, include = FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
store <- params$store
has <- function(x) !is.null(x)
```

This report bundles every analysis run in this session, in the order the
tabs appear in the app. Sections for analyses you haven't run yet are
omitted.

```{r, results = "asis"}
if (has(store$sample_ids)) {
  cat("## Sample ID Parser\n\n")
  print(knitr::kable(store$sample_ids))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$adsorption)) {
  cat("## Adsorption Capacity\n\n")
  print(knitr::kable(store$adsorption))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$isotherm)) {
  cat("## Isotherm\n\n")
  cat("Model: **", store$isotherm$model, "**", if (isTRUE(store$isotherm$batch)) " (batch mode)" else "", "\n\n", sep = "")
  print(knitr::kable(store$isotherm$params))
  cat("\n\n")
  if (has(store$isotherm$plot_path) && file.exists(store$isotherm$plot_path)) {
    cat(sprintf("![](%s)\n\n", store$isotherm$plot_path))
  }
}
```

```{r, results = "asis"}
if (has(store$kinetics)) {
  cat("## Kinetics\n\n")
  cat("Model: **", store$kinetics$model, "**", if (isTRUE(store$kinetics$batch)) " (batch mode)" else "", "\n\n", sep = "")
  print(knitr::kable(store$kinetics$params))
  cat("\n\n")
  if (has(store$kinetics$plot_path) && file.exists(store$kinetics$plot_path)) {
    cat(sprintf("![](%s)\n\n", store$kinetics$plot_path))
  }
}
```

```{r, results = "asis"}
if (has(store$thermo)) {
  cat("## Thermodynamics (van't Hoff)\n\n")
  cat(sprintf("\u0394H\u00b0 = %.3f kJ/mol, \u0394S\u00b0 = %.3f J/(mol K), R\u00b2 = %.4f\n\n",
              store$thermo$deltaH_kJmol, store$thermo$deltaS_Jmolk, store$thermo$R2))
  print(knitr::kable(store$thermo$table))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$ftir_functional_groups)) {
  cat("## FTIR \u2014 Functional Group Density\n\n")
  print(knitr::kable(store$ftir_functional_groups$table))
  cat("\n\n")
  if (has(store$ftir_functional_groups$plot_path) && file.exists(store$ftir_functional_groups$plot_path)) {
    cat(sprintf("![](%s)\n\n", store$ftir_functional_groups$plot_path))
  }
  if (has(store$ftir_functional_groups$autopeaks)) {
    cat("### Auto-detected peaks\n\n")
    print(knitr::kable(store$ftir_functional_groups$autopeaks))
    cat("\n\n")
  }
}
```

```{r, results = "asis"}
if (has(store$ftir_peak_assignment)) {
  cat("## FTIR \u2014 Peak Assignment\n\n")
  print(knitr::kable(store$ftir_peak_assignment))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$xrd)) {
  cat("## XRD Crystallinity\n\n")
  print(knitr::kable(store$xrd))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$bet)) {
  cat("## BET Surface Area\n\n")
  print(knitr::kable(store$bet))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$tga)) {
  cat("## TGA Analysis\n\n")
  cat("Proximate analysis", if (isTRUE(store$tga$batch)) " (batch mode)" else "",
      " from the TGA curve:\n\n", sep = "")
  print(knitr::kable(store$tga$stages))
  cat("\n\n")
  if (has(store$tga$plot_path) && file.exists(store$tga$plot_path)) {
    cat(sprintf("![](%s)\n\n", store$tga$plot_path))
  }
  if (has(store$tga$peaks) && nrow(store$tga$peaks) > 0) {
    cat("### Auto-detected DTG peaks\n\n")
    print(knitr::kable(store$tga$peaks))
    cat("\n\n")
  }
}
```

```{r, results = "asis"}
if (has(store$tga_kissinger)) {
  cat("## TGA \u2014 Kissinger Kinetics\n\n")
  print(knitr::kable(store$tga_kissinger))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$proximate)) {
  cat("## Proximate Analysis\n\n")
  print(knitr::kable(store$proximate))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$ultimate)) {
  cat("## Ultimate Analysis (Atomic Ratios)\n\n")
  print(knitr::kable(store$ultimate))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (has(store$correlation)) {
  cat("## Correlation Matrix\n\n")
  print(knitr::kable(store$correlation))
  cat("\n\n")
}
```

```{r, results = "asis"}
if (!any(vapply(store, has, logical(1)))) {
  cat("*No analyses have been run yet in this session.*\n")
}
```

---

*Generated by `biocharkitgui`, a 'Shiny' interface to the `biocharkit` R package.*
