Purpose and Construction
A GWAS quantile-quantile (Q-Q) plot places ranked observed SNP p-values against the values expected from a uniform null distribution. It compresses a large collection of tests into a single comparison: if the tests are calibrated under their null hypotheses, the observed p-values should broadly follow the uniform reference. The plot is especially useful for displaying the most extreme p-values, which may be difficult to inspect in a table.
This tutorial specifies one consistent plotting convention. For \(m\) tested SNPs, sort the p-values from smallest to largest. At rank \(i\), pair the observed p-value \(p_{(i)}\) with the expected uniform plotting position \(q_i=i/(m+1)\). Plot expected \(-\log_{10}(q_i)\) on the horizontal axis and observed \(-\log_{10}(p_{(i)})\) on the vertical axis. Both axes therefore increase toward stronger evidence. With this rank convention, the smallest p-values appear at the upper right of the plot.
Assumptions and Expected Quantiles
For a correctly specified test of a true null hypothesis, a continuous test statistic with a continuous null distribution gives a p-value that is Uniform(0,1) under the null. More generally, a valid p-value satisfies \(P(P\leq t)\leq t\) for \(0\leq t\leq1\); discrete tests can therefore produce conservative, non-uniform p-values. A Q-Q plot against the uniform reference is most directly motivated when the null p-values are continuous and uniform, or approximately so.
The expected order-statistic calculation also assumes that the \(m\) p-values behave as independent Uniform(0,1) random variables under the global null. In GWAS, nearby SNPs can be correlated through linkage disequilibrium, so the p-values are generally dependent. This does not by itself make each marginal null p-value invalid, but it means the independent-order-statistic calculation is a reference convention rather than a complete description of the joint distribution. Use one clearly defined set of tests and p-values; do not combine different test types, selectively retained results, or adjusted p-values with raw p-values in the same uniform-null plot.
The plotting position \(i/(m+1)\) has a useful exact property under independent uniform null p-values: it is the expected value of the \(i\)th ordered p-value. It is a plotting convention, not a claim that the transformed coordinate is the exact expected value of \(-\log_{10}(p_{(i)})\). Other conventions, such as midpoint plotting positions, are also used. The important construction choices are to state the convention and pair each observed rank with the corresponding expected quantile.
Why the Diagonal Is the Reference
If an observed p-value equals its expected plotting position, then its two plotted coordinates are equal. Thus the reference is the 45-degree line through the origin, \(y=x\). Points close to this line have observed values close to their corresponding reference quantiles. The line is not a fitted regression line and is not calculated from the data; it is the equality reference built into the axis definitions.
The rank order matters. Pair the smallest observed p-value with the smallest expected p-value, the second smallest with the second smallest, and so on. Since \(-\log_{10}(p)\) reverses the numerical order of p-values, the smallest p-value has the largest plotted value. Reversing only one of the coordinate sequences would pair mismatched ranks and produce a misleading plot.
Worked Example: A Five-SNP Q-Q Plot
Suppose a hypothetical scan reports raw p-values \(0.80, 0.20, 0.04, 0.50,\) and \(0.01\). Assume the tests are intended to be calibrated under their null hypotheses. Sort the five values: \(p_{(1)}=0.01\), \(p_{(2)}=0.04\), \(p_{(3)}=0.20\), \(p_{(4)}=0.50\), and \(p_{(5)}=0.80\). Here \(m=5\), so \(q_i=i/(5+1)=i/6\).
At rank 1, the expected p-value is \(q_1=1/6=0.1667\). The expected coordinate is \(-\log_{10}(0.1667)\approx0.7782\), and the observed coordinate is \(-\log_{10}(0.01)=2.000\). The plotted point is approximately \((0.7782,2.000)\).
At rank 2, \(q_2=2/6=0.3333\), giving expected coordinate \(-\log_{10}(0.3333)\approx0.4771\). The observed coordinate is \(-\log_{10}(0.04)\approx1.3979\), so the point is approximately \((0.4771,1.3979)\).
At rank 3, \(q_3=3/6=0.5000\), giving expected coordinate \(0.3010\). The observed coordinate is \(-\log_{10}(0.20)\approx0.6990\). At rank 4, \(q_4=4/6=0.6667\), giving expected coordinate \(0.1761\), while \(-\log_{10}(0.50)=0.3010\). At rank 5, \(q_5=5/6=0.8333\), giving expected coordinate \(0.07918\), while \(-\log_{10}(0.80)=0.09691\).
Plot each expected coordinate horizontally and its observed coordinate vertically, then draw \(y=x\). The first two ranks illustrate why the upper end is important: they pair the most extreme observed p-values with the most extreme expected null quantiles.
Derivation of the Plotting Position
The order-statistic result explains the chosen expected p-value positions. Let \(P_1,\ldots,P_m\) be independent Uniform(0,1) null p-values, and let \(P_{(i)}\) be the \(i\)th smallest. The event \(P_{(i)}\leq u\) occurs when at least \(i\) of the \(m\) values are at most \(u\). Equivalently, its density is
Integrating \(u\) against this density gives the mean of the ordered p-value. Using the beta integral, \(\int_0^1 u^{a-1}(1-u)^{b-1}\,du=(a-1)!(b-1)!/(a+b-1)!\) for positive integers \(a,b\), yields
Consequently, \(q_i=i/(m+1)\) is the exact mean of the \(i\)th ordered p-value under the independent uniform model. Transforming that plotting position gives the horizontal coordinate. The expectation of a transformed random variable is not generally the transform of its expectation, so \(-\log_{10}(q_i)\) should be understood as the chosen expected-quantile coordinate, not as \(E[-\log_{10}(P_{(i)})]\).
Working with Large Scans and Extreme Values
In a scan of many SNPs, the smallest expected p-value is \(1/(m+1)\). Its expected horizontal coordinate is therefore \(\log_{10}(m+1)\). This makes the plot's resolution at the extreme end depend on the number of tests: a scan with more SNPs has smaller expected tail probabilities and a longer horizontal range. Extreme points should be paired by rank just like all other points; they are not omitted merely because their values are small.
Worked Example: Expected Tail Coordinates in a Million Tests
Consider a hypothetical scan with \(m=1{,}000{,}000\) tested SNPs. At rank 1, the expected p-value is \(q_1=1/1{,}000{,}001\approx9.99999\times10^{-7}\). Its horizontal coordinate is \(-\log_{10}(q_1)\approx6.0000\). If the observed smallest p-value is \(2.0\times10^{-8}\), its vertical coordinate is \(-\log_{10}(2.0\times10^{-8})=7.699\). The point is approximately \((6.0000,7.699)\).
At rank 10, \(q_{10}=10/1{,}000{,}001\approx9.99999\times10^{-6}\), so its expected coordinate is approximately \(5.0000\). If the tenth-smallest observed p-value is \(3.0\times10^{-6}\), its observed coordinate is \(-\log_{10}(3.0\times10^{-6})\approx5.523\). The point is approximately \((5.0000,5.523)\).
These calculations show why retaining the most extreme ranks matters: the tail occupies a distinct part of the plot, and one omitted or mispaired value changes the plotted rank positions. The example gives coordinates for construction; it does not by itself establish why an observed value is extreme.
Ties, Rounded Values, and Zeros
Tied p-values are possible, particularly with discrete tests or rounded output. Keep tied observations at their corresponding ranks; they share an observed vertical coordinate but can have different expected horizontal coordinates. Record the p-value precision and plotting convention so that ties are not mistaken for separate numerical evidence.
Do not apply \(-\log_{10}\) directly to a p-value of zero, because the logarithm is undefined there. Under a continuous null, a p-value is strictly between 0 and 1 almost surely when data are generated under that null. However, exact zero can occur for an observation outside the null distribution's support, which has probability zero under the null but may occur under an alternative. In practice, a displayed zero often reflects rounding or numerical underflow. In each case, the plotted value needs special treatment: obtain a more precise log-p-value if available, recompute with adequate numerical precision, or mark the observation at an explicitly stated censoring limit. A zero should not silently be replaced with an arbitrary small number.
Worked Example: A Zero-Reported P-Value
Suppose a hypothetical set of four p-values is reported as \(0\), \(10^{-8}\), \(0.02\), and \(0.40\). Assume the analysis documentation says that values below \(10^{-300}\) are reported as zero. Sort the values using this information: the first value is known only to satisfy \(p_{(1)}<10^{-300}\), followed by \(p_{(2)}=10^{-8}\), \(p_{(3)}=0.02\), and \(p_{(4)}=0.40\).
For rank 1, \(q_1=1/(4+1)=0.20\), so the expected coordinate is \(-\log_{10}(0.20)=0.6990\). The true observed coordinate is greater than \(300\), because \(p_{(1)}<10^{-300}\). It can be displayed at the stated censoring boundary \(y=300\) with a note or symbol indicating that the point is censored, not equal to 300.
For rank 2, \(q_2=0.40\), so the expected coordinate is \(0.3979\), and the observed coordinate is \(-\log_{10}(10^{-8})=8.000\). For rank 3, \(q_3=0.60\) gives expected coordinate \(0.2218\), while \(-\log_{10}(0.02)=1.699\). For rank 4, \(q_4=0.80\) gives expected coordinate \(0.09691\), while \(-\log_{10}(0.40)=0.3979\). If the zero had no documented reporting threshold, the value 300 could not be justified; precision would need to be recovered or the limitation reported.
Practical Checks and Alternatives
Count the \(m\) SNP p-values that belong to the plot, and confirm they use a consistent testing and filtering rule.
Sort p-values from smallest to largest and retain their ranks, handling ties without changing the order convention.
For each rank \(i\), calculate \(q_i=i/(m+1)\), \(x_i=-\log_{10}(q_i)\), and \(y_i=-\log_{10}(p_{(i)})\), treating reported zeros separately.
Label the horizontal axis “Expected \(-\log_{10}(p)\) under Uniform(0,1)” and the vertical axis “Observed \(-\log_{10}(p)\)”; draw \(y=x\).
Before relying on the construction, check that no rank was dropped, the axes are not swapped or reversed, and the same p-value scale was used throughout. A change in filtering can alter \(m\) and every expected rank coordinate. If p-values are rounded, many ties at the extreme end may conceal their ordering; retain higher precision when possible. If tests are dependent, the diagonal remains the marginal uniform reference, but independent uniform order statistics are not a complete model for variation around that line.
A histogram of p-values is an alternative summary of the overall distribution, but it discards the rank-by-rank pairing and makes the extreme tail hard to inspect. A Manhattan plot locates results by genomic position, which the Q-Q plot does not; it answers a different construction question. Neither replaces the Q-Q plot's comparison of ranked p-values to a specified null reference. The plot is also limited: it cannot identify which modeling assumption failed, distinguish all sources of unusual p-values, or show where a SNP lies in the genome.
Common Mistake
A common error is to sort observed p-values from smallest to largest, but assign the smallest expected quantile to the largest observed p-value. That pairs opposite ranks, so points no longer represent a Q-Q comparison. The correction is to pair rank \(i\) with \(q_i=i/(m+1)\) when ranks are counted from the smallest p-value upward. Another error is to plot an observed p-value of zero at an invented finite value; instead recover precision or state and mark a justified censoring limit.
Check Your Understanding
Answer each question, then compare with the solutions.
- For \(m=9\), what expected p-value and expected \(-\log_{10}\) coordinate are assigned to rank 1?
- Three sorted p-values are \(0.01, 0.10,\) and \(0.50\). With \(m=3\), calculate the plotted coordinates for rank 2.
- Why does linkage disequilibrium matter to the independent-uniform order-statistic reference, even when individual null p-values are valid?
- A program reports a p-value of zero and documents no rounding threshold. What can and cannot be plotted from that report?
Solutions. (1) \(q_1=1/(9+1)=0.10\), so the expected coordinate is \(-\log_{10}(0.10)=1.000\). (2) For rank 2, \(q_2=2/(3+1)=0.50\), giving \(x=-\log_{10}(0.50)=0.3010\); the observed coordinate is \(y=-\log_{10}(0.10)=1.000\). The point is \((0.3010,1.000)\). (3) Linkage disequilibrium induces dependence among SNP tests, so the joint distribution of ordered p-values need not match the independent uniform order-statistic distribution, although marginal null p-values can still be valid. (4) The zero cannot be transformed by \(-\log_{10}\), and no finite censoring coordinate is justified without a threshold. Recover a precise log-p-value or report the observation as unplottable at a known finite coordinate until the numerical limitation is resolved.