Skip to content

Instantly share code, notes, and snippets.

@tomsing1
Last active May 18, 2025 17:41
Show Gist options
  • Save tomsing1/896def900a7fcd217702fc5883da19db to your computer and use it in GitHub Desktop.
Save tomsing1/896def900a7fcd217702fc5883da19db to your computer and use it in GitHub Desktop.
R script to create a plot highlighting that large (p > 0.05) p-values don't just have one interpretation
library(emo)
library(ggplot2)
library(ragg)
theme_set(theme_linedraw(14) + theme(panel.grid = element_blank()))
types <- c("Confidently > 20%\ndown-regulated",
paste("Don't know", as.character(emo::ji("shrug"))),
"Confidently < 20%\ndown-regulated")
fc <- data.frame(
example = factor(types, levels = rev(types)),
p = c("p < 0.05", "p > 0.05", "p > 0.05"),
mean = c(0.6, 0.85, 0.95),
xmin = c(0.5, 0.6, 0.85),
xmax = c(0.7, 1.1, 1.05)
)
fc |>
ggplot() +
aes(x = mean, y = example, xmin = xmin, xmax = xmax) +
geom_errorbar(width = 0.2, aes(color = p), show.legend = FALSE) +
geom_point(size = 3, aes(color = p), show.legend = FALSE) +
geom_text(aes(x = xmin, label = p), nudge_y = 0.25, nudge_x = 0.075) +
geom_vline(xintercept = 1, linewidth = 0.5, linetype = "solid") +
geom_vline(xintercept = c(0.8), linewidth = 0.5, linetype = "dashed") +
scale_x_continuous(labels = scales::percent_format(),
limits = c(0.5, 1.3),
breaks = c(0.2, 0.4, 0.6, 0.8, 1, 1.2))+
scale_color_manual(values = c("p < 0.05" = "darkorange",
"p > 0.05" = "grey20")) +
labs(x = "Remaing expression (compared to control)",
y = element_blank())
ggsave(filename = "~/Desktop/result_types.png", width = 7, height = 3)
@tomsing1
Copy link
Author

result_types

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