This is a test version of Biostars. For the public version, visit https://www.biostars.org.
P-value calculation between groups in split violin plot

Hi All,

I'd like to create a Violin plot of my single cell data split by experimental group with pvalues calculated between each group. Like this example here enter image description here

So far I have the following plot using this code

VlnPlot(seurat_obj,features = "Seurat_module_Score1", group.by = "celltype",split.by = "exp_group",pt.size = 0,split.plot = T,cols=brewer.pal(n=8,name = "Accent"))

enter image description here

I've tried stat_comapare_means and the ggsignif package, but they give me pvalues between the groups in the x-axis and not between the splits. Appreciate any help here.

Thanks

violinplot ggplot singlecellrnaseq

1 answer

Can you not just do a set of t-tests between the groups you are plotting and label the adjusted p-values? Or is your question specifically related to looking for a ggplot2-type function which will plot and label the data all in one? Because I'm not aware of one that will do everything you would like.

If it was me, I would precalculate the stats and add an annotation to the plot.

That's what i did. Do a ttest and add that as a label. But I was just wondering if there is a ggplot function to do the same like ggpubr or ggsignif does.

I usually just add it in as another geom, via

gp <- gp + geom_label(aes(x=celltype, y=ypos, label=signif), data=signif_df)

where signif.df might look like

celltype,ypos,signif
"Plasma B cells",0.4,"***"
"Naive B cells",0.4,""
...

Log in to answer this question.