-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
geom_pwc label = "p.adj" breaks with faceting #522
Comments
New function ggadjust_pvalue: Adjust p-values Displayed on a GGPlot #522
When using the ggplot facet functions, the p-values are computed and adjusted by panel, without taking into account the other panels. This is by design in ggplot2. This means that, when there is only one computed p-value by panel, then using One might want to adjust the p-values of all the facet panels together. There are two solutions for that:
The following example shows how to use suppressPackageStartupMessages(library(ggpubr))
y <- tibble::tibble(value = c(seq(10), seq(10, 100, 10), seq(100, 1000, 100), seq(1000, 10000, 1000)),
variable = c(rep("a", 10), rep("b", 10), rep("a", 10), rep("b", 10)),
facet_variable = c(rep("test1", 20), rep("test2", 20)))
p <- y %>%
ggplot(aes(x = variable, y = value)) +
geom_boxplot() +
geom_pwc(label = "p.adj") +
facet_grid(. ~ facet_variable)
# Adjust all panels p-values together
ggadjust_pvalue(p, label = "p.adj") |
With non-faceted data, geom_pwc reads label = "p.adj" and appends the adjusted p-value to the plot. When faceting by a variable, label = "p.adj" is ignored and the unadjusted p-value is used instead.
No facet
Facet
Changing the label to any of the other "p.adj.*" types does not fix the issue.
The text was updated successfully, but these errors were encountered: