#' DimPlots of cell stage and cluster identities
#'
#' This function plots UMAPs for cell stage and cluster identities
#'
#' @param seurat_object Seurat object
#' @param cluster_col seurat_object@meta.data column containing cell clusters
#' @param stage_col seurat_object@meta.data column containing cell stage
#' @param label_clusters boolean whether to plot labels ontop of clusters
#' @param plot_legend boolean whether to plot legend when label_clusters == TRUE
#' @return plot generated by grid extra
#' @export
ClustStagePlot <- function(seurat_object, cluster_col = "seurat_clusters", stage_col = "orig.ident", label_clusters = FALSE, plot_legend = TRUE)
{
clust_plot <- DimPlot(seurat_object, group.by = cluster_col) +
ggtitle(paste("Clusters")) + theme(plot.title = element_text(hjust = 0.5))
stage_plot <- DimPlot(seurat_object, group.by = stage_col) +
ggtitle("Developmental Stage") + theme(plot.title = element_text(hjust = 0.5))
if(label_clusters){
if(!plot_legend){
clust_plot <- clust_plot + NoLegend()
}
clust_plot <- LabelClusters(plot = clust_plot, id = cluster_col)
}
gridExtra::grid.arrange(stage_plot, clust_plot, nrow = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.