---
title: "The tmod Visualization Gallery"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{The tmod Visualization Gallery}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  echo = FALSE,
  collapse = TRUE,
  comment = "#>"
)
library(dplyr)
```

```{r setup}
library(tmod)
```

The purpose of this document is the demonstration and explanation of the
main visualizations which can be generated by tmod. In the following, we
make use of `tidyverse` and `colorDF`.

# tmod PanelPlots

The function tmodPanelPlot generates a heatmap-like representation
combining information on gene enrichment and differential gene expression,
including both a q-value and effect size for the enrichment part.

```{r preparation1}
data(vaccination)
vaccination %>% 
  select(GeneName, Description, logFC.F.D1, qval.F.D1) %>%
  arrange(qval.F.D1)
```

```{r tmod_results1, eval=FALSE}
days <- paste0("D", c(1:5, 7))
res <- lapply(days, function(d) {
  q <- paste0("qval.F.", d)
  l <- vaccination$GeneName[ order(vaccination[[q]]) ]
  tmodCERNOtest(l, mset="LI", qval=.1)
})

lfcs <- vaccination %>% select(starts_with("logFC"))
pvals <- vaccination %>% select(starts_with("qval"))

pie <- tmodDecideTests(vaccination$GeneName, lfc=lfcs, pval=pvals)
names(pie) <- names(res) <- days
```



