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.
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:
- I define the
gene_name
I want to plot - I look up the ensemble id for that gene and call it
gene_id
- I do plotReducedDim for the umap of that gene and instead of plotting it I assign the plot to a variable
a
,b
,c
, … - 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 doneplot1 <-
,plot2 <-
, … instead ofa
,b
,c
, …