kassambara / ggpubr

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

stat_signif() missing value where TRUE/FALSE needed #155

Closed mariaasierra closed 4 years ago

mariaasierra commented 5 years ago

Hello, After reading all the issues related to adding p-value to ggboxplot, I couldn't find any solution to my problem. I hope you can help me with this.

This is my data dataexample.txt

phylum.aldex<-read.table("dataexample.txt") #my data

Perform the test

compare_means(Actinobacteria ~ Lichen, data = phylum.aldex, method = "wilcox.test")

pairwise test afterwards

dunn.test(phylum.aldex$Actinobacteria,phylum.aldex$Lichen)

ggboxplot(phylum.aldex, x = "Lichen", y = "Actinobacteria", color = "Black", palette = "Set1", fill = "Lichen", legend = "none", size = 0.2, title = "Actinobacteria") + rotate_x_text(angle = 45)+ stat_compare_means(comparisons = list(c("Cladonia+", "Hypotrachyna")))+ geom_hline(yintercept = mean(phylum.aldex$Actinobacteria), linetype = 3)+ geom_jitter(position = "jitter", size=3, alpha=0.8,aes(colour = Lichen))

I want to be able to:

  1. add p-values from Dunn.test
  2. add the arrows in each of the groups that are significantly different. (like the image)

Thanks you!!

Maria.

rplot

xiaorenwu1111 commented 5 years ago

Hello, Have you solve this problems? I met same problems.Could you help me ? This is my code: library(ggpubr) ggboxplot( distance, x="Group", y="Distance", add = "mean_se", facet.by = "Method" ) + stat_compare_means( comparisons = list(c("A", "B"), c("B", "C"), c("C", "D")), label = "p.signif" ) This is my data structures: Group Distance Method A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance A 0 Hamming distance B 162 Hamming distance B 151 Hamming distance B 90 Hamming distance B 150 Hamming distance B 131 Hamming distance B 107 Hamming distance B 145 Hamming distance B 87 Hamming distance B 103 Hamming distance B 96 Hamming distance B 114 Hamming distance B 102 Hamming distance B 103 Hamming distance B 91 Hamming distance B 71 Hamming distance B 77 Hamming distance B 77 Hamming distance B 67 Hamming distance B 40 Hamming distance C 179 Hamming distance C 167 Hamming distance C 109 Hamming distance C 152 Hamming distance C 152 Hamming distance C 152 Hamming distance C 152 Hamming distance C 152 Hamming distance C 152 Hamming distance C 152 Hamming distance C 129 Hamming distance C 89 Hamming distance C 86 Hamming distance C 109 Hamming distance C 86 Hamming distance C 93 Hamming distance C 89 Hamming distance C 80 Hamming distance C 55 Hamming distance D 275 Hamming distance D 250 Hamming distance D 193 Hamming distance D 241 Hamming distance D 235 Hamming distance D 186 Hamming distance D 240 Hamming distance D 174 Hamming distance D 183 Hamming distance D 193 Hamming distance D 171 Hamming distance D 182 Hamming distance D 169 Hamming distance D 159 Hamming distance D 141 Hamming distance D 131 Hamming distance D 122 Hamming distance D 111 Hamming distance D 94 Hamming distance I want to draw a picture like this: 42407858-33b43f68-81c3-11e8-8668-67c916b007d3

But I used above data and code can't get similar picture. Rplot03

And I got some warning messages: Warning messages: 1: Computation failed in stat_signif(): missing value where TRUE/FALSE needed 2: Computation failed in stat_signif(): missing value where TRUE/FALSE needed 3: Computation failed in stat_signif(): missing value where TRUE/FALSE needed Could you help me ? Thank you !

kassambara commented 4 years ago

@mariaasierra For adding the Dunn test, please consider the following blog post: Kruskal-Wallis Test and Dunn Test Pairwise Comparison in R

@xiaorenwu1111: all group A values are 0; this might explain the error you have obtained