Seurat rookie here. I am using Seurat 3.1.2 and I want to use the argument "split.by" in the VlnPlot() function to visualize QC metrics for samples which are or are not fluorescent.
My code is
VlnPlot(object,
features = c("nFeature_RNA",
"nCount_RNA",
"percent.mt"),
ncol = 3,
log = TRUE,
pt = 0.1,
split.by = "fluorescence",
group.by = "construct")
and gives this as output

Questions
plot_runid <- VlnPlot(EF1a_object,
features = c("nFeature_RNA",
"nCount_RNA",
"percent.mt"),
ncol = 3,
log = TRUE,
pt = 0.1,
split.by = "fluorescence",
group.by = "construct") + theme(legend.position = 'right')
VlnPlot(object,
features = c("nFeature_RNA",
"nCount_RNA",
"percent.mt"),
ncol = 3,
log = TRUE,
pt = 0.1,
split.by = "fluorescence",
group.by = "construct") + stat_summary(fun.y = median, fun.ymin = median, fun.ymax = median, geom = "crossbar", width = 0.5)
Many thanks!
Hi,
Not member of the Dev team but hopefully this can be helpful (and is correct). I believe that both of the issues that you are having are related to the fact that when you provide multiple features to VlnPlot it is actually using CombinePlots() under the hood and theming doesn't work with combine plots in Seurat. You should be able to manually get around the issues by creating individual plots saved to the environment:
p1 <- VlnPlot(object, "nCount_RNA", pt.size = 0.1, split.by = "fluorescence", group.by = "construct")) + stat_summary(fun.y = median, fun.ymin = median, fun.ymax = median, geom = "crossbar", width = 0.5)
p2 <- VlnPlot(object, "nFeature_RNA", pt.size = 0.1, split.by = "fluorescence", group.by = "construct")) + stat_summary(fun.y = median, fun.ymin = median, fun.ymax = median, geom = "crossbar", width = 0.5)
Then combine with cowplot package
plot_grid(p1, p2)
Hope that helps and solves the issue. Also Dev team or others please correct me if I'm wrong.
Best,
Sam
Hi Sam,
I tested it, and it works! I get the legend and the median.
Many thanks, it was torturing me the whole day!
Best,
Corina
Most helpful comment
Hi,
Not member of the Dev team but hopefully this can be helpful (and is correct). I believe that both of the issues that you are having are related to the fact that when you provide multiple features to
VlnPlotit is actually usingCombinePlots()under the hood and theming doesn't work with combine plots in Seurat. You should be able to manually get around the issues by creating individual plots saved to the environment:p1 <- VlnPlot(object, "nCount_RNA", pt.size = 0.1, split.by = "fluorescence", group.by = "construct")) + stat_summary(fun.y = median, fun.ymin = median, fun.ymax = median, geom = "crossbar", width = 0.5)p2 <- VlnPlot(object, "nFeature_RNA", pt.size = 0.1, split.by = "fluorescence", group.by = "construct")) + stat_summary(fun.y = median, fun.ymin = median, fun.ymax = median, geom = "crossbar", width = 0.5)Then combine with cowplot package
plot_grid(p1, p2)Hope that helps and solves the issue. Also Dev team or others please correct me if I'm wrong.
Best,
Sam