rtidyverseggpubrrstatix

ggpubr missing significance annotations


I would like to get a barplot with significance annotations. I am using the following three libraries: tidyverse, ggpubr, rstatix, and reprex.

I am using the dataset and code in this gist, just copy and paste and you have all you need: https://gist.github.com/drfalco/9402b52e1fee4c64ed3f1ca622344b99

Only the significance level in line 2 of 'stat.test.melt.dfi3.agree' is present in the final plot. Instead, the three significance levels in line 3, 4, 5 of 'stat.test.melt.dfi3.agree' are absent in the final plot. I get the following "Warning message: Removed 3 rows containing non-finite values (stat_bracket())."

Do you see anything wrong in 'stat.test.melt.dfi3.agree’? How could I get the three missing annotations on the plot?


Solution

  • You have set your limits to c(0, 5) in scale_y_continuous but stat_pvalue_manual is trying to draw the brackets higher than 5. When you set y axis limits in ggplot, you remove any geoms that are not within that range, and you get a warning about missing rows.

    All you need to do is to remove the limits argument, or set it to include all the brackets. The value c(0, 5.45) seems pretty good:

    melt.dfi3.agree %>%
      ggplot(aes(DPType, Judgment))+
      stat_summary(fun = "mean",
                   geom = "bar")+
      stat_summary(fun.data = mean_se,
                   geom = "errorbar",
                   width = .5)+ 
      scale_x_discrete("Position and agreement")+
      scale_y_continuous("Judgement / Acceptabilty",
                         expand = expansion(mult = c(0, 0.1)), 
                         limits = c(0, 5.45))+
      ggtitle("Agreement effects in Italian: 'La metà' and 'Metà'") +
      stat_pvalue_manual(stat.test.melt.dfi3.agree, 
                         hide.ns = TRUE, tip.length = 0.01)
    

    enter image description here