Visualizing Seurat Objects with ggplot2

library(rlang)
library(ggseurat)
#> Loading required package: ggplot2
#> Loading required package: SeuratObject
#> Loading required package: sp
#> 
#> Attaching package: 'SeuratObject'
#> The following objects are masked from 'package:base':
#> 
#>     intersect, t
library(patchwork)
data("pbmc_small")
p <- ggplot(data = pbmc_small, mapping = aes(x = tSNE_1, y = tSNE_2)) +
  cowplot::theme_cowplot()

Dimensional Reduction Plots

p + geom_point(aes(color = ident))

Feature Plots

# features <- c("LYZ", "CCL5", "IL32", "PTPRCAP", "FCGR3A", "PF4")
features <- c("LYZ", "CCL5", "IL32", "FCGR3A", "PF4")
plots <- vector("list", length = length(features))
for (i in seq_along(plots)) {
  var <- sym(features[i])
  plots[[i]] <- p +
    geom_point(aes(color = !!var)) +
    scale_color_gradientn(colors = c("lightgrey", "purple"))
}
wrap_plots(plots)

var <- sym("MS4A1")
p +
  geom_point(aes(color = !!var)) +
  scale_color_gradientn(colors = c("lightgrey", "purple")) +
  facet_wrap(facets = "groups")