Tutorials › Statistical Genetics › Worked Comparisons of D, D-Prime, and R-Squared

Haplotypes and Linkage Disequilibrium · Tutorial 126 of 989

Worked Comparisons of D, D-Prime, and R-Squared

Learn to calculate and interpret D, D-prime, and r-squared from two-locus haplotype frequencies, and see how allele frequencies affect their comparisons.

Intermediate 9 min read

What You'll Learn

  • Define D from two-locus haplotype and allele frequencies
  • Calculate the feasible positive and negative bounds on D
  • Compute D-prime and r-squared for biallelic loci
  • Compare examples with identical D but different allele frequencies
  • Explain why D-prime and r-squared describe different features of linkage disequilibrium
  • Avoid interpreting either normalized measure as a substitute for the others

Why Compare Three Measures?

Linkage disequilibrium (LD) describes non-independence between alleles at different loci in a population. For two biallelic loci, \(D\), \(D'\) (D-prime), and \(r^2\) summarize that non-independence in related but distinct ways. \(D\) expresses an absolute difference between observed and independence-expected haplotype frequencies. \(D'\) scales that difference by the largest magnitude allowed by the allele frequencies. \(r^2\) expresses the squared correlation between the two allele indicators.

The distinction matters because allele frequencies constrain the possible haplotype frequencies. The same \(D\) can therefore be a small fraction of the available range in one population and a much larger fraction in another. Meanwhile, \(r^2\) also depends on the variation of each allele indicator, so equal values of \(D\) need not imply equal correlations.

Definitions for Two Biallelic Loci

Call the alleles at the first locus \(A\) and \(a\), and those at the second locus \(B\) and \(b\). Let \(h_{AB}\), \(h_{Ab}\), \(h_{aB}\), and \(h_{ab}\) be the frequencies of the four haplotypes among chromosomes in the population. These frequencies are nonnegative and sum to 1. The allele frequencies are \(p_A=h_{AB}+h_{Ab}\) and \(p_B=h_{AB}+h_{aB}\).

Definition: The signed linkage disequilibrium coefficient is \(D=h_{AB}-p_Ap_B\). Equivalently, \(D=h_{AB}h_{ab}-h_{Ab}h_{aB}\). Independence of the two alleles corresponds to \(D=0\); positive \(D\) means \(AB\) occurs more often than expected under independence, and negative \(D\) means it occurs less often.

The two expressions for \(D\) are equivalent because \(h_{AB}-p_Ap_B=h_{AB}(1-h_{AB}-h_{Ab}-h_{aB})-h_{Ab}h_{aB}=h_{AB}h_{ab}-h_{Ab}h_{aB}\). \(D\) is measured in frequency units: it is a difference between proportions of chromosomes, not a physical distance or a probability of recombination.

Because haplotype frequencies cannot be negative, the possible values of \(D\) depend on \(p_A\) and \(p_B\). For positive \(D\), the frequencies \(h_{Ab}=p_A(1-p_B)-D\) and \(h_{aB}=(1-p_A)p_B-D\) must be nonnegative. For negative \(D\), \(h_{AB}=p_Ap_B+D\) and \(h_{ab}=(1-p_A)(1-p_B)+D\) must be nonnegative. These constraints give the attainable bounds:

$$ D_{\max}=\min\{p_A(1-p_B),(1-p_A)p_B\},\qquad D_{\min}=-\min\{p_Ap_B,(1-p_A)(1-p_B)\}. $$

D-prime divides \(D\) by the appropriate bound in the direction of its sign. The sign is retained, while the magnitude is scaled to the range from 0 to 1. By contrast, \(r^2\) is the square of the correlation between allele indicators. If each indicator is coded 1 for \(A\) or \(B\), respectively, and 0 otherwise, their covariance is \(D\), and their variances are \(p_A(1-p_A)\) and \(p_B(1-p_B)\).

Definition: For \(D>0\), \(D'=D/D_{\max}\); for \(D<0\), \(D'=D/|D_{\min}|\); and for \(D=0\), \(D'=0\). The squared allelic correlation is \(r^2=D^2/\{p_A(1-p_A)p_B(1-p_B)\}\), provided both allele frequencies are strictly between 0 and 1. Both \(D'\) and \(r^2\) are dimensionless; \(D'\) retains the sign of \(D\), whereas \(r^2\) does not.

Worked Comparisons

Worked Example: Identical D with Balanced Allele Frequencies

Suppose a hypothetical population has haplotype frequencies \(h_{AB}=0.35\), \(h_{Ab}=0.15\), \(h_{aB}=0.15\), and \(h_{ab}=0.35\). They sum to 1. The allele frequencies are \(p_A=0.35+0.15=0.50\) and \(p_B=0.35+0.15=0.50\).

First calculate the signed difference:

$$ D=h_{AB}-p_Ap_B=0.35-(0.50)(0.50)=0.10. $$

The positive bound is \(D_{\max}=\min\{(0.50)(0.50),(0.50)(0.50)\}=0.25\). Thus \(D'=0.10/0.25=0.400\). The denominator for \(r^2\) is \((0.50)(0.50)(0.50)(0.50)=0.0625\), so \(r^2=(0.10)^2/0.0625=0.160\).

Here \(AB\) occurs at a frequency 0.10 above its independence expectation of 0.25. The observed \(D\) is 40.0% of the largest positive value allowed by these allele frequencies. The allelic correlation is positive, with \(r=\sqrt{0.160}=0.400\); its square is 0.160.

Worked Example: The Same D with Different Allele Frequencies

Now consider a second hypothetical population with \(p_A=0.20\), \(p_B=0.30\), and haplotype frequencies \(h_{AB}=0.16\), \(h_{Ab}=0.04\), \(h_{aB}=0.14\), and \(h_{ab}=0.66\). The frequencies sum to 1, and they give \(p_A=0.16+0.04=0.20\) and \(p_B=0.16+0.14=0.30\).

The signed difference is again \(D=0.16-(0.20)(0.30)=0.10\). However, the positive bound is now \(D_{\max}=\min\{(0.20)(0.70),(0.80)(0.30)\}=\min\{0.14,0.24\}=0.14\). Therefore \(D'=0.10/0.14=0.714\), to three significant figures.

For \(r^2\), the denominator is \((0.20)(0.80)(0.30)(0.70)=0.0336\). Hence \(r^2=(0.10)^2/0.0336=0.2976\), or 0.298 to three significant figures.

Both populations have \(D=0.10\): in each, the frequency of \(AB\) is 0.10 above the product of the marginal allele frequencies. But the second population's \(D\) is a larger fraction of its feasible positive range, so its \(D'\) is larger. Its \(r^2\) is also larger because the allele-frequency variances in its denominator differ. Equal \(D\) does not mean equal \(D'\) or equal \(r^2\).

Worked Example: Negative D and the Sign of Association

In a third hypothetical population, let \(p_A=0.40\), \(p_B=0.60\), and haplotype frequencies be \(h_{AB}=0.12\), \(h_{Ab}=0.28\), \(h_{aB}=0.48\), and \(h_{ab}=0.12\). These sum to 1 and yield the stated allele frequencies.

The coefficient is \(D=0.12-(0.40)(0.60)=0.12-0.24=-0.12\). The negative bound is \(D_{\min}=-\min\{(0.40)(0.60),(0.60)(0.40)\}=-0.24\), so \(D'=(-0.12)/0.24=-0.500\). For \(r^2\), the denominator is \((0.40)(0.60)(0.60)(0.40)=0.0576\), giving \(r^2=(-0.12)^2/0.0576=0.250\).

The negative sign means that \(AB\) is less frequent than its independence expectation; correspondingly, the alleles \(A\) and \(B\) have a negative correlation. The value \(r^2=0.250\) records the squared strength of that correlation but does not show its direction. The sign remains available in \(D\) and \(D'\).

Why the Measures Differ

The formula for \(r^2\) follows directly from the correlation definition. Let \(X\) indicate the presence of allele \(A\) on a randomly selected chromosome, and let \(Y\) indicate the presence of \(B\). Then \(E(X)=p_A\), \(E(Y)=p_B\), and \(E(XY)=h_{AB}\). Therefore \(\operatorname{Cov}(X,Y)=E(XY)-E(X)E(Y)=D\), while \(\operatorname{Var}(X)=p_A(1-p_A)\) and \(\operatorname{Var}(Y)=p_B(1-p_B)\). Squaring the correlation gives:

$$ \operatorname{Corr}(X,Y)^2 =\frac{\operatorname{Cov}(X,Y)^2}{\operatorname{Var}(X)\operatorname{Var}(Y)} =\frac{D^2}{p_A(1-p_A)p_B(1-p_B)} =r^2. $$

This establishes why \(r^2\) is not simply another scale for the absolute value of \(D\): its denominator is determined by the marginal allele-frequency variances. D-prime instead compares \(D\) with the largest feasible value in its direction. In particular, \(|D'|=1\) means that the observed \(D\) reaches its allele-frequency-specific bound. It does not, by itself, mean that \(r^2=1\).

MeasureWhat it describesSign and scale
\(D\)Absolute departure of a haplotype frequency from its independence expectationSigned; measured in frequency units
\(D'\)Departure relative to the largest feasible \(D\) in that directionSigned; ranges from -1 to 1
\(r^2\)Squared correlation between the two allele indicatorsUnsigned; ranges from 0 to 1

Interpretation and a Common Pitfall

These quantities describe features of a two-locus population distribution, not causal effects. \(D\) answers an absolute frequency-difference question; \(D'\) gives that difference relative to allele-frequency constraints; and \(r^2\) summarizes the squared allelic correlation. To compare populations or locus pairs, state which quantity is being compared and report the allele frequencies or haplotype frequencies that give the comparison context. The three values should not be treated as interchangeable labels for a single scale of LD.

A frequent mistake is to reason, “The two pairs have the same \(D\), so they have the same LD strength.” The examples show why that is incomplete: the shared value \(D=0.10\) produced \(D'=0.400\) and \(0.714\), and \(r^2=0.160\) and \(0.298\). The correction is to specify what “strength” means for the question: absolute departure, fraction of the feasible bound, or squared correlation. Also, a high \(D'\) should not be read as a high \(r^2\); the measures use different denominators and answer different questions.

Key takeaway: Always calculate and interpret \(D\), \(D'\), and \(r^2\) from the same allele and haplotype frequencies. \(D\) retains the signed frequency departure, \(D'\) scales it by its frequency-dependent bound, and \(r^2\) measures squared allelic correlation without its direction.

Check Your Understanding

Use the definitions and distinctions above to answer these questions.

  1. If \(p_A=0.50\), \(p_B=0.50\), and \(D=0.10\), what is the positive bound \(D_{\max}\), and what is \(D'\)?
  2. Two populations have the same positive \(D\), but one has a smaller \(D_{\max}\). Which population has the larger \(D'\), assuming both bounds are positive?
  3. Why can \(r^2\) differ between two populations that have the same \(D\)?
  4. What feature of the association is not conveyed by \(r^2\), and which measures retain it?
  5. Does \(D'=1\) necessarily imply \(r^2=1\)? Explain in terms of what each measure compares.
Clinical Biostats