kassambara / ggpubr

'ggplot2' Based Publication Ready Plots
https://rpkgs.datanovia.com/ggpubr/
1.12k stars 165 forks source link

Does not plot adjusted p-values #59

Closed mathykathy26 closed 6 years ago

mathykathy26 commented 6 years ago

When using stat_compare_means() for multiple comparisons, the plot will not reflect the adjusted p-values. I imagine that any asterisks for significance are also based on the original p-value, not the adjusted. How can I specify which p-value I'd like to use to denote significance?

library(ggpubr)

data("ToothGrowth")
head(ToothGrowth)

my_comparisons <- list( c("0.5", "1"), c("1", "2"), c("0.5", "2") )
ggboxplot(ToothGrowth, x = "dose", y = "len",
          color = "dose", palette = "npg")+
  stat_compare_means(comparisons = my_comparisons, label.y = c(29, 35, 40))+
  stat_compare_means(label.y = 45)     # Add global Anova p-value

# The plot only prints what p.format says, which does not reflect p.adj
compare_means(len~dose,comparisons = my_comparisons,p.adjust.method = "bonferroni",data = ToothGrowth)
grst commented 6 years ago

same issue here! You can use

stat_compare_means(aes(label=..p.adj..))

to display the adjusted p-value.

However I could not figure out how to use that value for the asterisk-representation.

kassambara commented 6 years ago

I will push update soon, thanks

bandrasmedik commented 6 years ago

Hi there, I'm facing the same issue, and to the stat_compare_means(aes(label="..p.adj..")) I got an error message:

"Error in .update_mapping(mapping, label): Allowed values for label are: p.signif, ..p.signif.., p.format, ..p.format.., p, ..p.."

Is there a solution to that?

atakanekiz commented 6 years ago

Has there been a development in this issue? Any insights on how we can plot adjusted p values for plots involving multiple comparisons?

Thanks!

kassambara commented 6 years ago

issue fixed at https://github.com/kassambara/ggpubr/issues/65#issuecomment-407211245

roni-fultheim commented 5 years ago

I am currently using this command: stat_compare_means(comparisons = comparisons_todo , method = "wilcox.test", p.adjust.methods = "fdr") but to no avail. Please help

diegopujoni commented 5 years ago

I'm not completely sure if this is correct, but if one wants "Bonferroni" correction, he can use:

N = 3 #Number of comparisons symnum.args <- list( cutpoints = c(0, 0.0001/N, 0.001/N, 0.01/N, 0.05/N, 1), symbols = c("<0.0001", "<0.001", "<0.01", "<0.05", "ns") )

or

symnum.args <- list( cutpoints = c(0, 0.0001/N, 0.001/N, 0.01/N, 0.05/N, 1), symbols = c("*", "", "*", "", "ns") )

And then apply on stat_compare_means(label = "p.signif",symnum.args = symnum.args)

Cecilia-Wang commented 5 years ago

I am having the same issue. Due to large number of groups, use asterisks for significance based on p.adj is the only option. If I use the adjusted p-value, it will be just a mess on the figure. I thought about change the font size of p-value to avoid overlapping but would be too small to read. Just wondering if there is any update on this?