Last active
October 17, 2020 17:12
-
-
Save liangyy/4c647634fe00b3f042ebd1599dda65c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qqplot_by_group <- function(pval, group, ...) { | |
n <- length(pval) | |
pexp <- rank(pval) / n | |
df <- data.frame(p.val = pval, grp = group) %>% group_by(grp) %>% mutate(p.exp = rank(p.val) / (n() + 1)) %>% ungroup() | |
p <- ggplot(df) + | |
geom_point(aes(x = -log10(p.exp), y = -log10(p.val), color = grp), ...) + | |
geom_hline(yintercept = -log10(0.05 / n)) + | |
geom_abline(slope = 1, intercept = 0, linetype = 2) | |
return(p) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment