Skip to content

Update utilities.R stat_pvalue_manual Positions on the plot#113

Open
ZWael wants to merge 1 commit intokassambara:masterfrom
ZWael:master
Open

Update utilities.R stat_pvalue_manual Positions on the plot#113
ZWael wants to merge 1 commit intokassambara:masterfrom
ZWael:master

Conversation

@ZWael
Copy link

@ZWael ZWael commented May 22, 2021

proposition to resolve the conflict between ggpubr plot and rstatix stat table x_y positions

the Anomalie (reproducible example)

library(ggpubr)
library(rstatix)

data2=data.frame(id =1:15 ,group=c(rep("C",5),rep("B",5),rep("A",5)),score=c(rnorm(5,0),rnorm(5,0.5),rnorm(5,2)))

head(data2)

res.kruskal = kruskal_test(data2, formula = score ~ group)
pwc = dunn_test(data2, formula = score ~ group, p.adjust.method = "BH")
pwc = pwc %>% add_xy_position(x = "group")
p <- ggboxplot(data2, x = "group", y = "score",
color = "group", palette = "jco",
add = "jitter",
title=paste("boxplot"))
y = stat_pvalue_manual(pwc, hide.ns = TRUE)

lab= labs(
subtitle = get_test_label(res.kruskal, detailed = FALSE),
caption = get_pwc_label(pwc)
)
print(p+y+lab)

pwc

proposition to resolve the conflict between ggpubr plot and rstatix stat table x_y positions

the Anomalie (reproducible example)

library(ggpubr)
library(rstatix)

data2=data.frame(id =1:15 ,group=c(rep("C",5),rep("B",5),rep("A",5)),score=c(rnorm(5,0),rnorm(5,0.5),rnorm(5,2)))

head(data2)

res.kruskal = kruskal_test(data2, formula = score~group)
pwc = dunn_test(data2, formula = score~group, p.adjust.method = "BH")
pwc = pwc %>% add_xy_position(x = "group")
p <- ggboxplot(data2, x = "group", y = "score",
          color = "group", palette = "jco",
          add = "jitter",
          title=paste("boxplot"))
y = stat_pvalue_manual(pwc, hide.ns = TRUE)

lab= labs(
    subtitle = get_test_label(res.kruskal, detailed = FALSE),
    caption = get_pwc_label(pwc)
  )
print(p+y+lab)

pwc
@ZWael
Copy link
Author

ZWael commented Aug 10, 2021

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant