qq_plot: Downsampled QQ-plot

View source: R/qqplot.r

qq_plotR Documentation

Downsampled QQ-plot

Description

Downsampling reduces the number of points to be plotted. Since QQ-plots are on a logarithmic scale, near the origin (approaching 1) is very dense and most points are plotted over each other. However, the end of the distribution (approaching 0) is sparse. In order to make plotting more efficient by not plotting redundant points and also not lose information, there are two parameters needed for downsampling. The first is the proportion of points to randomly remove (-downsample). The second is the threshold (-pdown) for which points will be downsampled. For example, the options "-downsample 0.01 -pdown 10e-3" would random choose 1 p-values < 0.001 would be plotted. For one million tests, this reduces the number of points plotted to 10990 ((1,000,000*(1-0.001)*.01)+ (1,000,000*0.001)).

Usage

qq_plot(p, pdown = 3, downsample = 0.01, pch = 1, col = "grey20",
  cex = 0.1, qpoints = FALSE, ci.level = 0.9, ci.color = "grey70",
  highlight = NULL, cex.highlight = 1.2, max.axis = NULL)

Arguments

p

vector of p-values

pdown

p-value threshold (on a log10 scale) for plot downsampling

downsample

proportion of points to plot

pch

plotting 'character' (i.e., symbol) to use. See points for possible values.

col

color code or name, see par

cex

character (or symbol) expansion: a numerical vector. This works as a multiple of par("cex").

qpoints

logical, should the points be added to an existing plot?

ci.level

confidence level between 0 and 1. Set ci.level = NULL to avoid plotting confidence intervals (ignored if qpoints = TRUE)

ci.color

color of confidence interval band

highlight

p-values above this (log10) threshold will be plotted with points whose size is determined by cex.highlight, useful for highlighting strong associations of interest

cex.highlight

the magnification applied to points above the highlight threshold

max.axis

maximum range (on a log10 scale) of the X and Y axes

Examples

qq_plot(runif(1e5))

if (requireNamespace("pgcxd")) {
  data("scz", package = "pgcxd")
  qq_plot(scz$pval, highlight = 6)
}

aaronwolen/gqq documentation built on Feb. 17, 2024, 11:27 a.m.