Quantile-quantile plot to compare the p-values of a GWAS to a uniform distribution.

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, ...)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data. A function can be created from a formula (e.g. ~ head(.x, 10)).

geom

"point" by default, "ggrastr:::GeomPointRast" for a rasterized version.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders().

y.thresh

same scale as y (e.g. 0.05), y <= y.thresh AFTER computing expected

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

Details

Alternatively, use stat_qq, that works for all kinds of distributions, together with mlog_trans.

Note

Plotting several thousand points might take time. If you want to speed things up use stat_gwas_qq_hex.

See also

Examples

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)