qqPlotFast {ramwas} | R Documentation

## Fast QQ-plot for Large Number of P-values

### Description

Function `qqPlotFast` creates a QQ-plot with a confidence band and an estimate of inflation factor lambda. It optimized to work quickly even for tens of millions of p-values.

### Usage

    qqPlotPrepare(
            pvalues,
            ntests = NULL,
            ismlog10 = FALSE)
    qqPlotFast(
            x,
            ntests = NULL,
            ismlog10 = FALSE,
            ci.level = 0.05,
            ylim = NULL,
            newplot = TRUE,
            col = "#D94D4C",
            cex = 0.5,
            yaxmax = NULL,
            lwd = 3,
            axistep = 2,
            col.band = "#ECA538",
            makelegend = TRUE,
            xlab = expression(
                paste("\u2013", " log"[10]*"(", italic("P"), "), null")),
            ylab = expression(
                paste("\u2013", " log"[10]*"(", italic("P"), "), observed")))

### Arguments

`pvalues` | Vector of p-values. As is (if `ismlog10 = FALSE`) or minus log10 transformed (if `ismlog10 = TRUE`).
`ntests` | If only significant p-values are provided, the total number of tests performed. By default `ntests` is equal to the length of `pvalues`.
`ismlog10` | Specifies whether the provides p-values (`pvalues` parameter) are minus log10 transformed (`- log10(pv)`)
`x` | Either a vector of p-values, as in `qqPlotPrepare`, or the object returned by `qqPlotPrepare`.
`ci.level` | Significance level of the confidence band. Set to `NULL` avoid plotting the confidence band.
`ylim` | Numeric vectors of length 2, giving the y coordinate range. Exactly as in Plotting Parameters.
`newplot` | If `TRUE`, the function creates a new plot window.
`col` | The QQ-plot curve color.
`col.band` | Confidence band curve color.
`cex` | The size of QQ-plot points. As in Graphics Parameters.
`lwd` | The line width. As in Graphics Parameters.
`axistep` | Distance between axis label ticks for both axis.
`yaxmax` | Maximum reach of the y axis.
`makelegend` | If true, add legend to the plot.
`xlab, ylab` | Axis labels. As in plot function.

### Details

The function `qqPlotFast` creates a QQ-plot.
The function `qqPlotPrepare` extracts the necessary information from a vector of p-values sufficient for creating QQ-plot.
The resulting object is many times smaller than the vector of p-values.

### Value

The function `qqPlotPrepare` returns an object with the necessary information from a vector of p-values sufficient for creating QQ-plot.

### Note

The plot has no title. To add a title use `title`.

### Note

The function works faster if the p-values are sorted.

### Author(s)

Andrey A Shabalin andrey.shabalin@gmail.com

### See Also

See vignettes: `browseVignettes("ramwas")`.

### Examples

    # Million p-values
    n = 1e6

    # Null p-values
    pv = runif(n)

    # QQ-plot should be nearly diagonal
    qqPlotFast(pv)
    title("QQ-plot")

    # Size of p-values before extraction of QQ-plot info
    object.size(pv)

    # Extract the QQ-plot info
    qq = qqPlotPrepare(pv)

    # Size of the QQ-plot info object
    object.size(qq)

    # Create QQ-plot, it is the same
    qqPlotFast(qq)

    # Create QQ-plot with plotting parameters
    qqPlotFast(qq, ylim = c(0,10), yaxmax = 9, axistep = 3, lwd = 3, cex = 1)

[Package ramwas version 1.4.0 Index]