This document shows an example of making custom plots from plae data for use in your own presentations / publications. If you need assistance with making a custom figure / table and believe you are missing some data required, please contact me.
Make plot in plae.nei.nih.gov and download data
Look at source plotting code and copy out the relevant bits. The names of the functions (I think) are self-explanatory for which kind of plot they make. This example is remaking the “Expression Plot” so we will open up the make_exp_plot.R file. For all of these functions you can just go straight to the bottom and find the plotting part near there.
ggplot(aes(x=!!as.symbol(input$exp_plot_facet),
y = !!as.symbol(input$exp_plot_ylab),
color = !!as.symbol(grouping_features))) +
geom_boxplot(color = 'black', outlier.shape = NA) +
::geom_quasirandom(aes(size = `Total Cells`), groupOnX = TRUE) +
ggbeeswarm::theme_cowplot() +
cowplottheme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
scale_radius(range=c(2, 6)) +
scale_colour_manual(values = rep(c(pals::alphabet() %>% unname()), 20)) +
theme(legend.position="bottom") +
facet_wrap(ncol = as.numeric(input$exp_plot_col_num), scales = 'free_y', ~Gene)
Load in the downloaded data into R
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.6 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.4 ✓ stringr 1.4.0
## ✓ readr 2.0.2 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggbeeswarm)
library(cowplot)
library(pals)
<- read_csv("~/Downloads/plae_exp_2023-02-16.csv") plae_exp_data
## New names:
## * `` -> ...1
## Rows: 1732 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): CellType_predict, Gene, study_accession
## dbl (5): ...1, Cell # Detected, Total Cells, % of Cells Detected, Mean log2(...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
plae_exp_data
## # A tibble: 1,732 × 8
## ...1 CellType_predict Gene study_accession `Cell # Detecte… `Total Cells`
## <dbl> <chr> <chr> <chr> <dbl> <dbl>
## 1 1 Retinal Ganglion… PAX6 … SRP186396 555 557
## 2 2 Retinal Ganglion… PAX6 … SRP238409 111 112
## 3 3 Amacrine Cell PAX6 … SRP257758 8936 9477
## 4 4 Retinal Ganglion… PAX6 … SRP200599 1039 1081
## 5 5 Retinal Ganglion… PAX6 … SRP255195 6459 7013
## 6 6 AC/HC Precursor PAX6 … SRP200599 149 152
## 7 7 Horizontal Cell PAX6 … SRP200599 92 97
## 8 8 Amacrine Cell PAX6 … SRP200599 153 164
## 9 9 Amacrine Cell PAX6 … E-MTAB-7316 195 222
## 10 10 Corneal Epitheli… PAX6 … SRP251245 7787 8619
## # … with 1,722 more rows, and 2 more variables: % of Cells Detected <dbl>,
## # Mean log2(Counts + 1) <dbl>
Adjust the code chunk above and make a plot
%>%
plae_exp_data ggplot(aes(x = CellType_predict,
y = `Mean log2(Counts + 1)`,
color = study_accession)) +
geom_boxplot(color = 'black', outlier.shape = NA) +
geom_quasirandom(aes(size = `Total Cells`), groupOnX = TRUE) +
theme_cowplot() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
scale_radius(range=c(2, 6)) +
scale_colour_manual(values = rep(c(alphabet() %>% unname()), 20)) +
theme(legend.position="bottom") +
facet_wrap(ncol = 2, scales = 'free_y', ~Gene)