Following the logic answered here I should be able to add p-value comparisons to the plot. Woudl really appreciate any help feedback as to what I'm doing wrong with my solution.
library(magrittr)
library(ggsignif)
library(ggpubr)
value<-c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.000273200055869626,
0, 0, 0, 0, 0, 0.000391899951754252, 7.79999691577276e-06, 0,
0, 0.000341800044604173, 0, 0.000160399989889521, 0, 0, 0.00014739991923847,
0, 0, 0.000200399960107021, 0, 0, 0, 0, 6.35000054462966e-05)
condition<-c("E","E","E","E","E","E","E","E","E","E","E","E","E",
"R","R","R","R","R","R","R","R","R","R","R","R","R",
"S","S","S","S","S","S","S","S","S","S","S")
species<-rep('B_theta',length(condition))
df <- data.frame(value,condition,species)
bact <- compare_means(value~condition, data = df,method = 't.test') %>%
bact <- bact %>% mutate(y_pos = c(-3.5, -3.25, -3),labels = ifelse(p < 0.1, p.format, p.signif))
bact
.y. group1 group2 p p.adj p.format p.signif method y_pos labels
value E R 0.04859346 0.15 0.049 * T-test 3.50 0.049
value E S 0.11168959 0.22 0.112 ns T-test 3.25 ns
value R S 0.26876159 0.27 0.269 ns T-test 3.00 ns
p <- ggboxplot(df, x = "condition", y = "value",
color = "condition",
palette = "jco",add = "jitter")+
geom_signif(textsize=6, tip_length = 0.01, xmin=bact$group1,
xmax=bact$group2, annotations=bact$labels, y_position=bact$y_pos)+
scale_y_log10(limits=c(NA,0.001))+annotation_logticks(sides = "l")
Warning message:
"Transformation introduced infinite values in continuous y-axis"Warning message:
"Transformation introduced infinite values in continuous y-axis"Warning message:
"Transformation introduced infinite values in continuous y-axis"Warning message:
"Removed 29 rows containing non-finite values (stat_boxplot)."Warning message:
"Removed 29 rows containing non-finite values (stat_signif)."

