Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
366 lines (259 sloc) 13.9 KB
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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. <br/>
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) <br/>
[https://github.com/ebi-gene-expression-group/anatomogram](https://github.com/ebi-gene-expression-group/anatomogram) <br/>
```{r, eval=TRUE, echo=FALSE, AllSpeciesCellPlotValueTop, fig.width = 8, fig.height = 8, dpi = 300}
hgMale <- gganatogram(data=hgMale_key, fillOutline='#440154FF', organism='human', sex='male', fill="value") + theme_void() + scale_fill_viridis()
hgFemale <- gganatogram(data=hgFemale_key, fillOutline='#440154FF', organism='human', sex='female', fill="value") + theme_void() + scale_fill_viridis()
mmMale <- gganatogram(data=mmMale_key, fillOutline='#440154FF', organism='mouse', sex='male', fill="value") + theme_void() + scale_fill_viridis()
mmFemale <- gganatogram(data=mmFemale_key, outline = T, fillOutline='#440154FF', organism='mouse', sex='female', fill="value") +theme_void() + scale_fill_viridis()
grid.arrange(hgMale, hgFemale, mmMale, mmFemale, ncol=2)
```
```{r, eval=TRUE, echo=FALSE, CellPlotValueTop, fig.width = 8, fig.height = 4, dpi = 300}
p1 <- gganatogram(data=cell_key[['cell']], outline = T, fillOutline='steelblue', organism="cell", fill="colour") +theme_void() + coord_fixed()
p2 <- gganatogram(data=cell_key[['cell']], outline = T, fillOutline='lightgray', organism="cell", fill="value") +theme_void() + coord_fixed() + scale_fill_viridis()
grid.arrange(p1, p2, ncol=2)
```
## Citation
#### Maag JLV. gganatogram: An R package for modular visualisation of anatograms and tissues based on ggplot2 [version 1; referees: 1 approved]. F1000Research 2018, 7:1576 (doi: 10.12688/f1000research.16409.1)
https://f1000research.com/articles/7-1576/v1
```{r}
citation("gganatogram")
```
If you use the tissue plots from gganatogram please cite Expression Atlas as well. <br/>
[Petryszak et al. 2015](https://academic.oup.com/nar/article/44/D1/D746/2502589) <br/>
If you use the main cell figure, please cite The Protein Atlas. <br/>
[Thul PJ et al. 2017](http://science.sciencemag.org/content/356/6340/eaal3321) <br/>
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. <br/>
An online version can be found at shinapps.io. <br/>
[https://jespermaag.shinyapps.io/gganatogram/](https://jespermaag.shinyapps.io/gganatogram/) <br/>
Unfortunately, there is a limit of 25h per month of app activity, so if you know R/Rstudio, please run it locally. <br/>
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 <- gganatogram(data=hgMale_key, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") + theme_void()
hgFemale <- gganatogram(data=hgFemale_key, fillOutline='#a6bddb', organism='human', sex='female', fill="colour") + theme_void()
mmMale <- gganatogram(data=mmMale_key, fillOutline='#a6bddb', organism='mouse', sex='male', fill="colour") + theme_void()
mmFemale <- gganatogram(data=mmFemale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='female', fill="colour") +theme_void()
grid.arrange(hgMale, hgFemale, mmMale, mmFemale, ncol=4)
```
```{r, eval=TRUE, AllSpeciesPlotValue, fig.heigth = 6, dpi = 300}
hgMale <- gganatogram(data=hgMale_key, fillOutline='#440154FF', organism='human', sex='male', fill="value") + theme_void() + scale_fill_viridis()
hgFemale <- gganatogram(data=hgFemale_key, fillOutline='#440154FF', organism='human', sex='female', fill="value") + theme_void() + scale_fill_viridis()
mmMale <- gganatogram(data=mmMale_key, fillOutline='#440154FF', organism='mouse', sex='male', fill="value") + theme_void() + scale_fill_viridis()
mmFemale <- gganatogram(data=mmFemale_key, outline = T, fillOutline='#440154FF', organism='mouse', sex='female', fill="value") +theme_void() + scale_fill_viridis()
grid.arrange(hgMale, hgFemale, mmMale, mmFemale, ncol=2)
```
In order to use the function gganatogram, you need to have a data frame with
organ, colour, and value if you want to.
```{r, eval=TRUE}
organPlot <- data.frame(organ = c("heart", "leukocyte", "nerve", "brain", "liver", "stomach", "colon"),
type = c("circulation", "circulation", "nervous system", "nervous system", "digestion", "digestion", "digestion"),
colour = c("red", "red", "purple", "purple", "orange", "orange", "orange"),
value = c(10, 5, 1, 8, 2, 5, 5),
stringsAsFactors=F)
head(organPlot)
```
Using the function gganatogram with the filling the organs based on colour.
```{r, eval=TRUE, organPlot, fig.width = 3, dpi = 100}
gganatogram(data=organPlot, fillOutline='#a6bddb', organism='human', sex='male', fill="colour")
```
Of course, we can use the ggplot themes and functions to adjust the plots
```{r, eval=TRUE, organPlotvoid, fig.width = 3, dpi = 100}
gganatogram(data=organPlot, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +
theme_void()
```
We can also plot all tissues available using hgMale_key
```{r, eval=TRUE, organPlotAll, fig.width = 3, dpi = 100}
hgMale_key$organ
gganatogram(data=hgMale_key, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +theme_void()
```
We can also skip plotting the outline of the graph
```{r, eval=TRUE, organPlotSubset, fig.width = 3, dpi = 100}
organPlot %>%
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 <- rbind(data.frame(organ = c("heart", "leukocyte", "nerve", "brain", "liver", "stomach", "colon"),
colour = c("red", "red", "purple", "purple", "orange", "orange", "orange"),
value = c(10, 5, 1, 8, 2, 5, 5),
type = rep('Normal', 7),
stringsAsFactors=F),
data.frame(organ = c("heart", "leukocyte", "nerve", "brain", "liver", "stomach", "colon"),
colour = c("red", "red", "purple", "purple", "orange", "orange", "orange"),
value = c(5, 5, 10, 8, 2, 5, 5),
type = rep('Cancer', 7),
stringsAsFactors=F))
```
```{r, eval=TRUE, Condition, fig.width = 6, dpi = 100}
gganatogram(data=compareGroups, fillOutline='#a6bddb', organism='human', sex='male', fill="value") +
theme_void() +
facet_wrap(~type) +
scale_fill_gradient(low = "white", high = "red")
```
You can also split the tissues into types while retaining the outline
```{r, eval=TRUE, maleOrgans, fig.width = 10, fig.height = 8,dpi = 200}
gganatogram(data=hgMale_key, outline = T, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +
facet_wrap(~type, ncol=4) +
theme_void()
```
## Added female option
All female tissues
```{r, eval=TRUE, female, fig.width = 3, dpi = 200}
hgFemale_key$organ
gganatogram(data=hgFemale_key, outline = T, fillOutline='#a6bddb', organism='human', sex='female', fill="colour") +theme_void()
```
You can also split the tissues into types while retaining the outline
```{r, eval=TRUE, femaleOrgans, fig.width = 10, fig.height = 8, dpi = 200}
gganatogram(data=hgFemale_key, outline = T, fillOutline='#a6bddb', organism='human', sex='female', fill="colour") +
facet_wrap(~type, ncol=4) +
theme_void()
```
To display the female reproductive system with outline.
```{r, eval=TRUE, femaleRep, fig.width = 6, dpi = 200}
hgFemale_key %>%
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) <br/>
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 <- list()
for (i in 1:nrow(cell_key[['cell']])) {
figureList[[i]] <- gganatogram(data=cell_key[['cell']][i,], outline = T, fillOutline='steelblue', organism="cell", fill="colour") +theme_void() +ggtitle(cell_key[['cell']][i,]$organ) + theme(plot.title = element_text(hjust=0.5, size=16)) + coord_fixed()
}
do.call(grid.arrange, c(figureList[1:4], ncol=2))
do.call(grid.arrange, c(figureList[5:8], ncol=2))
do.call(grid.arrange, c(figureList[9:12], ncol=2))
do.call(grid.arrange, c(figureList[13:16], ncol=2))
do.call(grid.arrange, c(figureList[17:20], ncol=2))
do.call(grid.arrange, c(figureList[21:24], ncol=2))
```
## Other organisms i.e. tier 2 organisms
Expression atlas contains other organisms than human and mice, however, these are not as well anotated. <br/>
All the expression atlas anatograms can be found here https://ebi-gene-expression-group.github.io/anatomogram/ <br/>
Unfortunately, I won't be able to add other organs to these since I'm neither an anatomist nor artist. <br/>
If anyone would like to add more organs, I would love for you to contribute. <br/>
<br/>
To create these plots, I have added two other objects other_key and other_list. <br/>
These are lists within lists, and to plot all the organs from an organisms use other_key[["organism"]] as data, and "organism" as organism. <br/>
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 <- list()
for (organism in names(other_key)) {
plotList[[organism]] <- gganatogram(data=other_key[[organism]], outline = T, fillOutline='white', organism=organism, sex='female', fill="colour") +
theme_void() +
ggtitle(organism) +
theme(plot.title = element_text(hjust=0.5, size=9)) +
coord_fixed()
}
do.call(grid.arrange, c(plotList[1:4], ncol=2))
do.call(grid.arrange, c(plotList[5:8], ncol=2))
do.call(grid.arrange, c(plotList[9:12], ncol=2))
do.call(grid.arrange, c(plotList[13:16], ncol=2))
do.call(grid.arrange, c(plotList[17:20], ncol=2))
do.call(grid.arrange, c(plotList[21:24], ncol=2))
```
You can’t perform that action at this time.