plotUMAP Gene Set Faceted
2
0
Entering edit mode
Dario Strbenac ★ 1.5k
@dario-strbenac-5916
Last seen 1 day ago
Australia

How could one produce a set of faceted-by-gene plots of UMAPs, each one showing a gene's abundance as the colour scale? colour_by accepts a single gene synbol but not a gene set.

scater • 343 views
ADD COMMENT
2
Entering edit mode
@alanocallaghan-14291
Last seen 4 weeks ago
United Kingdom

I'd be inclined to use makePerCellDf if you want to make a more complex set of plots. Ultimately the code will probably be simpler.

library("scater")

example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)
example_sce <- runUMAP(example_sce)

df <- makePerCellDF(example_sce, features=rownames(example_sce)[1:9])
long_df <- pivot_longer(df, cols = starts_with("Gene_"))

ggplot(long_df) + geom_point(aes(UMAP.1, UMAP.2, colour=value)) + facet_wrap(~name) + scale_colour_viridis()

ADD COMMENT
1
Entering edit mode
Peter Hickey ▴ 740
@petehaitch
Last seen 9 days ago
WEHI, Melbourne, Australia

I'd usually loop over the genes, make a plot for each gene, and then use patchwork/cowplot/gridExtra to stitch them together. Something like the following:

library(scater)
library(patchwork)

set.seed(666)
sce <- mockSCE() 
sce <- logNormCounts(sce)
sce <- runUMAP(sce)
p <- lapply(head(rownames(sce), 9), function(f) {
  plotUMAP(sce, colour_by = f)
})
wrap_plots(p, ncol = 3)

ADD COMMENT
0
Entering edit mode

That is what I have now, but I thought there might be a more elegant solution.

ADD REPLY

Login before adding your answer.

Traffic: 593 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6