Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(Seurat)
- library(ggplot2)
- library(ggthemes)
- library(ggpubr)
- make_expression_plots <- function(seuset, feature, reduction = NULL) {
- stopifnot(length(feature) == 1)
- if (!feature %in% rownames(seuset)) {
- warning(paste("Feature", feature, "not found"), call. = FALSE)
- return(NULL)
- }
- # define base theme
- base_theme <- theme(
- aspect.ratio = 1,
- plot.margin = unit(c(5, 5, 5, 5), "mm"),
- plot.title = element_blank()
- )
- dr_idents <- DimPlot(seuset, group.by = "ident", reduction = reduction) +
- scale_color_tableau(palette = "Tableau 20") +
- theme_void() +
- base_theme
- dr_feature <- FeaturePlot(seuset, features = feature, reduction = reduction, min.cutoff = "q10") +
- scale_color_viridis_c(option = "inferno") +
- theme_void() +
- base_theme
- vln <- VlnPlot(seuset, features = feature, pt.size = 0.3, sort = TRUE) +
- scale_fill_viridis_d(direction = -1) +
- base_theme +
- theme(
- legend.position = "none",
- axis.title.x = element_blank(),
- panel.grid.major.y = element_line(colour = "grey75")
- )
- ridge <- RidgePlot(seuset, features = feature, sort = TRUE) +
- scale_fill_viridis_d(direction = -1) +
- base_theme +
- theme(
- legend.position = "none",
- axis.title.y = element_blank(),
- axis.title.x = element_text(hjust = 0.5),
- panel.grid.major.y = element_line(colour = "grey75")
- )
- # combine plots and add global title
- CombinePlots(
- list(dr_idents, dr_feature, vln, ridge),
- ncol = 2, axis = "tb"
- ) %>%
- ggpubr::annotate_figure(
- top = text_grob(feature, face = "bold", size = 18)
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement