Trying to plot significance value for multiple boxplots
Rohit-Satyam opened this issue · 1 comments
. The file has been attached here
brain.zip
I was trying to add significance bar for each EP pair in every tissue type using the following code
I used the following code:
library(ggplot2)
library(reshape2)
library(ggsignif)
df<- read.table(brain.csv,header = FALSE, col.names = c("Tissuetype", "E", "P"), sep = "\t")
df.m <- melt(brain)
ggplot(data = df.m, aes(x=value, y=Tissuetype)) + geom_boxplot(aes(fill=variable))+geom_signif(comparisons = list(c("E", "P")),map_signif_level = TRUE)
However it throws the following warnings:
Warning messages:
1: In f(..., self = self) : NAs introduced by coercion
2: Computation failed in `stat_signif()`:
missing value where TRUE/FALSE needed
Can someone help me understand what's wrong with defining the function?
Hey Rohit,
unfortunately it is difficult to calculate the exact positions of boxplots with position = "dodge"
. Please see the second example here.
The function fails because geom_signif()
searches for "E"
and "P"
on the x-axis, but cannot find them.
You could set aes(x = paste0(Tissuetype, "_", variable), y = value)
and then making a list with the correct comparison: eg. geom_signif(comparisons = list(c("insua_E", "insula_P"))
.
Btw. ggsignif does not support rotated boxplots, so you will need to put the continuous variable on the y axis and the discrete ones on the x-axis.
I hope this is helpful. I will close this issue, but feel free to comment or re-open if I missed something.
Best, Constantin