Description Usage Arguments Details Note See Also Examples
Quantile-quantile plot to compare the p-values of a GWAS to a uniform distribution.
1 2 3 4 5 6 7 | stat_gwas_qq(mapping = NULL, data = NULL, geom = "point",
position = "identity", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, y.thresh = NULL, ...)
geom_gwas_qq(mapping = NULL, data = NULL, geom = "point",
position = "identity", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, y.thresh = NULL, ...)
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
|
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
y.thresh |
same scale as y (e.g. 0.05), y <= y.thresh AFTER computing expected |
... |
Other arguments passed on to |
Alternatively, use stat_qq
, that works for
all kinds of distributions, together with mlog_trans
.
Plotting several thousand points might take time. If you want to speed
things up use stat_gwas_qq_hex
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | require(ggplot2)
n.sample <- 10000
df <- data.frame(P = runif(n.sample), GWAS = sample(c("a", "b"), n.sample,
replace = TRUE
))
theme_set(theme_bw())
## default
(qp <- ggplot(df, aes(y = P)) +
stat_gwas_qq() +
geom_abline(intercept = 0, slope = 1))
## use geom instead of qq
ggplot(df, aes(y = P)) +
geom_gwas_qq()
## show only p-values above a cerain threshold
ggplot(df, aes(y = P)) +
stat_gwas_qq(y.thresh = 0.05) +
geom_abline(intercept = 0, slope = 1) +
xlim(0, NA) + ylim(0, NA)
## plot a line instead
ggplot(df, aes(y = P)) +
stat_gwas_qq(geom = "line", size = 1.5) +
geom_abline(intercept = 0, slope = 1, linetype = 2)
## plot efficiently
ggplot(df, aes(y = P)) +
stat_gwas_qq(geom = ggrastr:::GeomPointRast) +
geom_abline(intercept = 0, slope = 1)
## Group and color points according to GWAS
(qp <- ggplot(df, aes(y = P)) + stat_gwas_qq(aes(
group = GWAS, color = GWAS
)))
## facet
ggplot(df, aes(y = P)) +
facet_wrap(~GWAS) +
stat_gwas_qq() +
geom_abline(intercept = 0, slope = 1) +
theme(aspect.ratio = 1)
## adding nice labels, square shape
## identical limits (meaning truely square)
qp +
theme(aspect.ratio = 1) + ## square shaped
expand_limits(x = -log10(max(df$P)), y = -log10(max(df$P))) +
ggtitle("QQplot") +
xlab("Expected -log10(P)") +
ylab("y -log10(P)")
## group
library(GWAS.utils) ## devtools::install_github("sinarueeger/GWAS.utils")
data("giant")
?giant
## generate two groups
giant <- giant %>%
dplyr::mutate(gr = dplyr::case_when(
BETA <= 0 ~ "Neg effect size",
BETA > 0 ~ "Pos effect size"
))
ggplot(data = giant, aes(y = P, group = gr, color = gr)) +
stat_gwas_qq() +
geom_abline(intercept = 0, slope = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.