Entering edit mode
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.
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.
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()
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)
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
That is what I have now, but I thought there might be a more elegant solution.