---
title: "Overview of pathway network databases"
author: "Kim Philipp Jablonski, Martin Pirkl"
date: "`r Sys.Date()`"
graphics: yes
output: BiocStyle::html_document
bibliography: bibliography.bib
vignette: >
    %\VignetteIndexEntry{Overview of pathway network databases}
    %\VignetteEngine{knitr::rmarkdown}
    %\VignetteEncoding{UTF-8}
---

# Introduction

## Load required packages

Load the package with the library function.

```{r message=FALSE}
library(tidyverse)
library(ggplot2)

library(dce)

set.seed(42)
```

# Pathway database overview

We provide access to the following topological pathway databases using
graphite [@sales2012graphite] in a processed format.
This format looks as follows:

```{r}
dce::df_pathway_statistics %>%
  arrange(desc(node_num)) %>%
  head(10) %>%
  knitr::kable()
```

Let's see how many pathways each database provides:

```{r}
dce::df_pathway_statistics %>%
  count(database, sort = TRUE, name = "pathway_number") %>%
  knitr::kable()
```

Next, we can see how the pathway sizes are distributed for each database:

```{r}
dce::df_pathway_statistics %>%
  ggplot(aes(x = node_num)) +
    geom_histogram(bins = 30) +
    facet_wrap(~ database, scales = "free") +
    theme_minimal()
```

# Plotting pathways

It is easily possible to plot pathways:
```{r message=FALSE}
pathways <- get_pathways(
  pathway_list = list(
    pathbank = c("Lactose Synthesis"),
    kegg = c("Fatty acid biosynthesis")
  )
)

lapply(pathways, function(x) {
  plot_network(
    as(x$graph, "matrix"),
    visualize_edge_weights = FALSE,
    arrow_size = 0.02,
    shadowtext = TRUE
  ) +
    ggtitle(x$pathway_name)
})
```

# Session information

```{r}
sessionInfo()
```

# References
