---
title: "Multiple Signatures"
vignette: >
  %\VignetteIndexEntry{Multiple Signatures}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include=FALSE, messages=FALSE, warnings=FALSE}
knitr::opts_chunk$set(comment="", fig.align="center", fig.width=8.75, cache=FALSE)
devtools::load_all(".")
```

Often computational biologists must process, interpret, and share large amounts of biological data. A common example is interpreting gene co-expression modules across one or more phenotype, resulting in potentially hundreds of signatures to annotate. Here we have signatures of gene co-expression modules, generated with WGCNA, for two distinct phenotypes. In this case, we can feed `hypeR()` a named list of signatures and a `multihyp` object will be returned. This object is essentially just multiple `hyp` objects. However it is recognized and handled differently by downstream methods.

```{r}
data(wgcna)
```

We start by annotating signatures for the first phenotype..

```{r}
signatures <- wgcna[[1]]
str(signatures)
```

The signatures will be processed together...

```{r, message=FALSE, warning=FALSE, results='hide'}
genesets <- msigdb_gsets("Homo sapiens", "C2", "CP:KEGG_LEGACY", clean=TRUE)

mhyp <- hypeR(signatures, genesets, test="hypergeometric", background=50000, fdr=0.05)
```

### A `multihyp` Object

```{r}
print(mhyp)
```

A `multihyp` object can be passed to any downstream method, with some altered behavior.

#### Altered Methods

With `hyp_to_excel` each signature is exported to its own sheet...

```{r, eval=FALSE}
hyp_to_excel(mhyp, file_path="hypeR.xlsx")
```

With `hyp_to_table` each signature is exported as its own table in a single directory...

```{r, eval=FALSE}
hyp_to_table(mhyp, file_path="hypeR")
```

With `hyp_to_rmd` each signature is displayed under its own tab...

```{r, eval=FALSE}
hyp_to_rmd(lmultihyp_obj, file_path="hypeR.rmd",
```

With `hyp_dots()`, `hyp_emap()`, and `hyp_hmap()` each signatures is plotted and returned separately...

```{r}
p <- hyp_dots(mhyp)
```

```{r, fig.height=5}
p[1:3]
```

Alternatively `hyp_dots(merge=TRUE)` can combine mulitple signatures into a single plot...

```{r}
hyp_dots(mhyp, merge=TRUE)
```
