# Plotting multiple UMAPs

**URL:** <https://help.c-moor.org/t/plotting-multiple-umaps/213>\
**Category:** Code Cookbook\
**Created:** [March 7, 2022, 3:12pm UTC](https://help.c-moor.org/t/plotting-multiple-umaps/213 "2022-03-07T15:12:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LindsayHayes](https://yyz1.discourse-cdn.com/flex027/user_avatar/help.c-moor.org/lindsayhayes/32/14_2.png) [@LindsayHayes](https://help.c-moor.org/u/LindsayHayes)\
**Post date:** [March 7, 2022, 3:12pm UTC](https://help.c-moor.org/t/plotting-multiple-umaps/213/1 "2022-03-07T15:12:25Z")

</div>

Here is a trick to plotting multiple UMAPS in a tile. It uses the function `plot_grid()` from the `cowplot` package. There are several ways of doing this but cowplot is my personal favorite. 🐄

```auto
library(cowplot)
gene_name <- "Sox17"
gene_id <- rowData(sce)[which(rowData(sce)[,2] %in% gene_name),1]
a <- plotReducedDim(object = sce, dimred="umap", colour_by=gene_id) + labs(title = gene_name) + theme(legend.title = element_blank(), legend.position="top")

gene_name <- "Sox9"
gene_id <- rowData(sce)[which(rowData(sce)[,2] %in% gene_name),1]
b <- plotReducedDim(object = sce, dimred="umap", colour_by=gene_id) + labs(title = gene_name) + theme(legend.title = element_blank(), legend.position="top")

gene_name <- "Sox2"
gene_id <- rowData(sce)[which(rowData(sce)[,2] %in% gene_name),1]
c <- plotReducedDim(object = sce, dimred="umap", colour_by=gene_id) + labs(title = gene_name) + theme(legend.title = element_blank(), legend.position="top")

gene_name <- "Sox3"
gene_id <- rowData(sce)[which(rowData(sce)[,2] %in% gene_name),1]
d <- plotReducedDim(object = sce, dimred="umap", colour_by=gene_id) + labs(title = gene_name) + theme(legend.title = element_blank(), legend.position="top")

plot_grid(a,b,c,d)

```

How it works:

1. I define the `gene_name` I want to plot
2. I look up the ensemble id for that gene and call it `gene_id`
3. I do plotReducedDim for the umap of that gene and instead of plotting it I assign the plot to a variable `a`, `b`, `c`, …
4. Then once I’ve defined all my plots `plot_grid` will tile each of those plots. You could call them anything. for example, I could have done `plot1 <-`, `plot2 <-`, … instead of `a`, `b`, `c`, …
