const-ae/ggsignif

comparison by group in legend

rysterzhu opened this issue · 1 comments

data:
condition Sample percentage
A early 0.5
A late 0.4
B early 0.2
B late 0.1
...

ggplot(data, aes(x=condition,y=Percentage,fill=Sample)) +
geom_boxplot(alpha=0.5,position = position_dodge2(),outlier.shape = NA) +
ggsignif::geom_signif(comparisons = list(c("early", "late")),
y_position = 8,test = "wilcox.test", map_signif_level=TRUE)

Is possible compare "early" and "late" in each condition?
Thanks

No, sorry. At the moment there is no easy way to compare between different groups.

In the README, I give an example how to do it manually

# Calculate annotation
anno <- t.test(iris[iris$Petal.Width > 1 & iris$Species == "versicolor", "Sepal.Width"], 
               iris[iris$Species == "virginica", "Sepal.Width"])$p.value

# Make plot with custom x and y position of the bracket
ggplot(iris, aes(x=Species, y=Sepal.Width, fill=Petal.Width > 1)) +
  geom_boxplot(position="dodge") +
  geom_signif(annotation=formatC(anno, digits=1),
              y_position=4.05, xmin=2.2, xmax=3, 
              tip_length = c(0.2, 0.04))

dodge_comparison-1