Hello,
I would like to change the transparency of my violin plots in Seurat. It should be simple yet it seems there isn't a function for this? This is the original code:
VlnPlot(object = obj, features = 'features', split.by = "Group")
and then I tried to use ggplot as I normally do with my sce object:
gg<-VlnPlot(object = obj, features = 'features', split.by = "Group")
gg + geom_violin(aes(fill = "gray", alpha = 0.5)) +
theme_minimal() +
ylab("text1") +
xlab("text2")
But it just added a third violin that was indeed transparent over the top of the other two plots. Surely there is a 'alpha = ' equivalent in Seurat?
Thank you for your help!
You can not just add a geom_violin() to the previous VlnPlot object and expect it to change. You have two options, one is to go find the source code for the VlnPlot (on GitHub here) and then copy the function (and other functions it depends on like ExIplot()) and then add your alpha argument to its geom_violin and run it on your local session; OR you can just do a simple violin plot yourself by exporting the data you want from Seurat object into a dataframe format readable by ggplot. To export the data you must know which subset of the obj you are interested in see here as a example.
Thank you, yes that's what I'v done in the end and have it working now. Strange seurat vlnPlot doesn't have that as an option already!