Dear experts,
When using DimPlot to plot the UMAP for the combined Seurat object, say it includes two groups, the combined object after the Dimplot will become one patchwork gg ggplot structure, while how to change each group (treat/control) to treat day1 , control day1? patchwork or ggplot function title or subtitle setting only affects the whole UMAP, not the subplots?
DimPlot(combined, reduction = "umap", split.by = "orig.ident", label = T)
orig.ident are treat & control, but its better to change label to more specific names, which can include the blank
Thanks a lot!
2 answers
There are multiple ways to do that.
You can edit the ggplot object
gg_figure <- DimPlot(combined, reduction = "umap", split.by = "orig.ident", label = T)
gg_figure$data$orig.ident <- gsub("treat","treat_day1",gg_figure$data$orig.ident)
gg_figure$data$orig.ident <- gsub("control","control_day1",gg_figure$data$orig.ident)
You can change the name of the groups in the object before plotting
combined@meta.data$group <- gsub("treat",...)
# or
combined@meta.data$modified_group <- combined@meta.data$group
combined@meta.data$modified_group <- gsub("treat",...)
Plot each group individually and put them together
# split combined into 2 objects and then
p1 <- DimPlot(treat, ...) + ggtitle("trat day1)
p2 <- DimPlot(control, ...) + ggtitle("control day1)
p1 | p2
A simple trick would be to add an additional column in the metadata slot of the Seurat object. Something like this:
combined@meta.data$group <- ifelse(combined@meta.data$orig.ident == "treat","treat day1","control day1")
and then rerun a Dimplot
DimPlot(combined, reduction = "umap", split.by = "group", label = T)
Log in to answer this question.
It is so amazing!
Thank you very much for all your kind help!