```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
dev='svg',
fig.path = "figure/"
)
```
## gganatogram
```{r, include=FALSE}
if (requireNamespace("git2r")) {
repo = git2r::repository(".")
url = git2r::remote_url(repo, remote = "origin")
gh_user = basename(dirname(url))
} else {
gh_user = "jespermaag"
}
```
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jespermaag/gganatogram?branch=master&svg=true)](https://ci.appveyor.com/project/`r gh_user`/gganatogram)
[![Travis build status](https://travis-ci.com/jespermaag/gganatogram.svg?branch=master)](https://travis-ci.com/`r gh_user`/gganatogram)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1434233.svg)](https://doi.org/10.5281/zenodo.1434233)
Create anatogram images for different organisms.
This package uses the tissue coordinates from the figure in Expression Atlas. [https://www.ebi.ac.uk/gxa/home](https://www.ebi.ac.uk/gxa/home)
[https://github.com/ebi-gene-expression-group/anatomogram](https://github.com/ebi-gene-expression-group/anatomogram)
```{r, eval=TRUE, echo=FALSE, AllSpeciesCellPlotValueTop, fig.width = 8, fig.height = 8, dpi = 300}
hgMale
[Petryszak et al. 2015](https://academic.oup.com/nar/article/44/D1/D746/2502589)
If you use the main cell figure, please cite The Protein Atlas.
[Thul PJ et al. 2017](http://science.sciencemag.org/content/356/6340/eaal3321)
More plot examples can be found at [https://jespermaag.github.io/blog/2018/gganatogram/](https://jespermaag.github.io/blog/2018/gganatogram/)
## Install
Install from github using devtools.
```{r,eval=FALSE}
## install from Github
devtools::install_github("jespermaag/gganatogram")
```
## shiny
I have now included a shiny app for gganatogram.
An online version can be found at shinapps.io.
[https://jespermaag.shinyapps.io/gganatogram/](https://jespermaag.shinyapps.io/gganatogram/)
Unfortunately, there is a limit of 25h per month of app activity, so if you know R/Rstudio, please run it locally.
To run it locally, use the following command.
```{r, eval=FALSE}
library(shiny)
runGitHub( "gganatogram", "jespermaag", subdir = "shiny")
```
## Usage
This package requires `ggplot2` and `ggpolypath` which loads when loading the package
```{r,eval=TRUE, message=FALSE}
library(gganatogram)
library(dplyr)
library(viridis)
library(gridExtra)
```
```{r, eval=TRUE, AllSpeciesPlot, fig.width = 10, dpi = 300}
hgMale %
dplyr::filter(type %in% c('circulation', 'nervous system')) %>%
gganatogram(outline=F, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +
theme_void()
```
We can fill the tissues based on the values given to each organ
```{r, eval=TRUE, organPlotValue, fig.width = 3, dpi = 100}
gganatogram(data=organPlot, fillOutline='#a6bddb', organism='human', sex='male', fill="value") +
theme_void() +
scale_fill_gradient(low = "white", high = "red")
```
We can also use facet_wrap to compare groups.
First create add two data frames together with different values and the conditions in the type column
```{r, eval=TRUE}
compareGroups %
dplyr::filter(type=='reproductive') %>%
gganatogram( outline = T, fillOutline='#a6bddb', organism='human', sex='female', fill="colour") +
theme_void() +
coord_cartesian(xlim = c(30, 75), ylim = c(-110, -80))
```
# Added mouse
## Male
```{r, eval=TRUE, maleMouse, figwidth = 3, dpi = 50}
mmMale_key$organ
gganatogram(data=mmMale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='male', fill="colour") +theme_void() +coord_fixed()
```
```{r, eval=TRUE, maleMouseOrgan, figwidth = 10, figheight = 8, dpi = 200}
gganatogram(data=mmMale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='male', fill="colour") +theme_void()+facet_wrap(~type, ncol=4)
```
## Female
```{r, eval=TRUE, femaleMouse, figwidth = 3, dpi = 50}
mmFemale_key$organ
gganatogram(data=mmFemale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='female', fill="colour") +theme_void() +coord_fixed()
```
```{r, eval=TRUE, femaleMouseOrgan, figwidth = 10, figheight = 8, dpi = 200}
gganatogram(data=mmFemale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='female', fill="colour") +theme_void()+facet_wrap(~type, ncol=4)
```
## Cellular structures
I have now included cellular substructures, using the cell.svg from the Protein Atlas.
If you use the main cell figure (hopefully more will be added), please cite [Thul PJ et al. 2017](http://science.sciencemag.org/content/356/6340/eaal3321)
The cellular data can be access using cell_key
```{r}
length(cell_key)
cell_key
```
To plot the whole cell with colours or values, use the following command.
If you want to specify a background colour, you either have to remove the cytosol or change the colour of cytosol to the desired colour.
```{r}
gganatogram(data=cell_key[['cell']], outline = T, fillOutline='steelblue', organism="cell", fill="colour") +theme_void() + coord_fixed()
gganatogram(data=cell_key[['cell']], outline = T, fillOutline='lightgray', organism="cell", fill="value") +theme_void() + coord_fixed() + scale_fill_viridis()
```
To see all the subsstructures individually, you can plot the data one at a time
```{r}
figureList
All the expression atlas anatograms can be found here https://ebi-gene-expression-group.github.io/anatomogram/
Unfortunately, I won't be able to add other organs to these since I'm neither an anatomist nor artist.
If anyone would like to add more organs, I would love for you to contribute.
To create these plots, I have added two other objects other_key and other_list.
These are lists within lists, and to plot all the organs from an organisms use other_key[["organism"]] as data, and "organism" as organism.
Also, the organ names are so far a mix of UBERON and plant ids.
```{r}
length(other_key)
names(other_key)
```
To plot bos_taurus use the following command.
Unfortunately, I have not managed to add the correct names yet.
```{r, eval=TRUE, bosTaurus}
other_key[["bos_taurus"]]
gganatogram(data=other_key[["bos_taurus"]], outline = T, fillOutline='white', organism="bos_taurus", sex='female', fill="colour") +
theme_void() +
ggtitle("bos_taurus") +
theme(plot.title = element_text(hjust=0.5)) +
coord_fixed()
```
Here is a way to loop through all the other organisms and plot their organs.
```{r, eval=TRUE, othersFirst12, figwidth = 12, figheight = 16, dpi = 200}
library(gridExtra)
plotList