Tutorials › High-Dimensional Genomic Data Analysis › Deriving Local FDR From Bayes’ Rule

Empirical Bayes and Local FDR · Tutorial 173 of 795

Deriving Local FDR From Bayes’ Rule

Learn to derive and calculate local FDR from the two-group mixture, interpret its marginal-density denominator, and verify the formula’s normalization and boundary conditions.

Advanced 10 min read

What You'll Learn

  • Derive local FDR by conditioning on the observed test statistic under a two-group mixture.
  • Explain why the marginal density is the normalizing denominator in Bayes’ formula.
  • Calculate posterior null probabilities from component densities and mixture proportions.
  • Verify the integral identity that recovers the mixture’s null proportion.
  • Recognize when posterior odds are defined and what happens at zero mixture weights.
  • Diagnose common errors involving density scales, zero denominators, and omitted mixture weights.

Why the Marginal Density Matters

In a genomic analysis, a test statistic can be compatible with either a null hypothesis or an alternative. A local false discovery rate (local FDR) answers a specific question: given the observed test statistic, what is the posterior probability that this test belongs to the null component? To answer it, the null density alone is not enough. We must compare the null contribution with the probability density of observing that statistic under the full mixture.

The two-group model represents the null or alternative status as a latent class and gives each class a distribution for the test statistic. The derivation below is Bayes’ theorem applied to those classes. Its denominator, the marginal density, is what makes the posterior class probabilities add to one. This tutorial focuses on that derivation and its normalization, rather than on estimating the mixture components.

Definition: Let \(S\) be a latent indicator, with \(S=0\) denoting the null component and \(S=1\) the alternative component. Write \(P(S=0)=\pi_0\), \(P(S=1)=\pi_1\), where \(\pi_0+\pi_1=1\). Conditional on \(S=0\), the test statistic \(X\) has density \(f_0\); conditional on \(S=1\), it has density \(f_1\). For an observed value \(x\) with positive marginal density, the local FDR is \( \operatorname{lfdr}(x)=P(S=0\mid X=x)=\frac{\pi_0 f_0(x)}{\pi_0 f_0(x)+\pi_1 f_1(x)}. \)

Deriving the Formula from Bayes’ Theorem

Assume the two latent classes are mutually exclusive and exhaustive, the component distributions are probability distributions, and both densities are defined with respect to the same underlying measure. For a continuous statistic, that measure is usually length on the real line. The mixture weights are nonnegative and sum to one. These assumptions let us compare the component density contributions at the same \(x\).

The joint density contribution from the null class and an observation near \(x\) is the prior probability of the null class multiplied by the null density. The corresponding contribution from the alternative is formed in the same way. Adding these mutually exclusive contributions gives the marginal density of \(X\):

$$ f(x)=\pi_0 f_0(x)+\pi_1 f_1(x). $$

Bayes’ theorem divides the joint contribution for the event of interest by the marginal contribution for the observed data. Thus, wherever \(f(x)>0\),

$$ P(S=0\mid X=x) =\frac{P(S=0)f_0(x)}{f(x)} =\frac{\pi_0 f_0(x)}{\pi_0 f_0(x)+\pi_1 f_1(x)}. $$

The alternative posterior probability has the same denominator and numerator \(\pi_1 f_1(x)\). The two numerators sum to \(f(x)\), so the two posterior probabilities sum to one. In a continuous model, \(P(X=x)\) is usually zero; the density-ratio expression specifies a conditional probability given the observed value, in the usual almost-everywhere sense. At points where \(f(x)=0\), the model assigns zero density to the observation and this ratio does not define a posterior there.

Key result: The marginal density \(f(x)\) is the normalizing denominator because it sums the null and alternative contributions to the observation. It ensures that the posterior probabilities of the two exhaustive classes add to one. The null contribution is \(\pi_0 f_0(x)\), not \(f_0(x)\) by itself.

Worked Calculations

Worked Example: A Normal-Mixture Observation

Suppose, hypothetically, that \(P(S=0)=0.90\) and \(P(S=1)=0.10\). Under the null, \(X\sim N(0,1)\); under the alternative, \(X\sim N(2,1)\). For an observed test statistic \(x=2\), calculate the local FDR. The model specifies continuous normal densities with the same measure, positive mixture weights, and a marginal density that is positive at \(x=2\), so the formula applies.

For a normal density with mean \(\mu\) and variance 1, the density at \(x\) is \(\frac{1}{\sqrt{2\pi}}\exp[-(x-\mu)^2/2]\). Therefore, at \(x=2\), the null density is approximately \(f_0(2)=0.0539910\), while the alternative density is \(f_1(2)=0.3989423\).

The weighted null and alternative contributions are \(0.90(0.0539910)=0.0485919\) and \(0.10(0.3989423)=0.0398942\). Their sum is the marginal density, \(f(2)=0.0884861\). Consequently,

$$ \operatorname{lfdr}(2) =\frac{0.0485919}{0.0485919+0.0398942} =\frac{0.0485919}{0.0884861} \approx 0.5491. $$

Under this specified mixture model, a test statistic of 2 has posterior null probability about 0.5491. This is a model-based probability for the latent class conditional on the observed statistic, not a probability that a null hypothesis is true in a frequentist testing framework.

Worked Example: Seeing the Denominator Normalize

Consider a hypothetical continuous statistic with \(f_0\) uniform on \([0,2]\), \(f_1\) uniform on \([1,3]\), and mixture weights \(\pi_0=0.75\) and \(\pi_1=0.25\). Each component density integrates to one, and both weights are positive and sum to one. Calculate the local FDR across the regions where the component supports overlap or differ, then check normalization.

Each component density is \(1/2\) on its support and zero outside. On \([0,1)\), only the null contributes, so \(f(x)=0.75(1/2)=0.375\) and \(\operatorname{lfdr}(x)=1\). On \([1,2]\), both contribute: the null contribution is \(0.75(1/2)=0.375\), the alternative contribution is \(0.25(1/2)=0.125\), and \(f(x)=0.500\). The local FDR there is \(0.375/0.500=0.75\). On \((2,3]\), only the alternative contributes; hence \(f(x)=0.125\) and the local FDR is zero. Endpoints do not affect the integrals.

The marginal density integrates to one: the three regions have lengths 1, 1, and 1, so its integral is \(0.375(1)+0.500(1)+0.125(1)=1\). Weighting the local FDR by that marginal density recovers the prior null proportion:

$$ \int \operatorname{lfdr}(x)f(x)\,dx =1(0.375)(1)+0.75(0.500)(1)+0(0.125)(1) =0.375+0.375=0.75=\pi_0. $$

The denominator is doing more than making the pointwise posterior probabilities sum to one: across the full distribution of observations, it makes the marginal-weighted posterior null probability average back to the mixture’s null proportion.

Normalization and Posterior Odds

The integral identity in the example follows directly from the formula. Wherever the marginal density is positive, multiply the local FDR by that density. The denominator cancels, leaving the null contribution. Integrating over all possible observations then integrates the null density to one:

$$ \int \operatorname{lfdr}(x)f(x)\,dx =\int \frac{\pi_0 f_0(x)}{f(x)}f(x)\,dx =\pi_0\int f_0(x)\,dx =\pi_0. $$

This calculation assumes the mixture model is properly specified as a probability distribution, so \(f_0\) integrates to one, \(f_1\) integrates to one, and the weights sum to one. The identity is a useful derivation and consistency check; it is not a claim that the local FDR has the same value for every observation. It says that its average under the marginal distribution of \(X\) equals the prior null proportion.

When \(\pi_0>0\), \(\pi_1>0\), \(f_0(x)>0\), and \(f_1(x)>0\), both posterior probabilities and both prior probabilities are positive. In this case, dividing the null posterior by the alternative posterior gives the posterior-odds identity:

$$ \frac{P(S=0\mid X=x)}{P(S=1\mid X=x)} =\frac{\pi_0 f_0(x)}{\pi_1 f_1(x)} =\frac{\pi_0}{\pi_1}\frac{f_0(x)}{f_1(x)}. $$

The explicit positivity conditions matter: if either prior weight is zero, the prior odds are not defined, even if both densities are positive. The local FDR formula itself remains usable at boundary weights when the marginal density is positive; only the odds form fails in those cases.

Worked Example: Odds Form and a Boundary Weight

First take hypothetical values \(\pi_0=0.60\), \(\pi_1=0.40\), \(f_0(x)=0.10\), and \(f_1(x)=0.40\). Both weights and both densities are positive, so the odds identity applies. The weighted contributions are \(0.60(0.10)=0.06\) and \(0.40(0.40)=0.16\), giving \(f(x)=0.22\). Thus the local FDR is \(0.06/0.22\approx0.2727\), and the posterior null-to-alternative odds are \(0.06/0.16=0.375\). The odds calculation agrees: \((0.60/0.40)(0.10/0.40)=1.5(0.25)=0.375\).

Now set \(\pi_0=1\), \(\pi_1=0\), and suppose \(f_0(x)>0\). The marginal density is \(f(x)=f_0(x)>0\), and the posterior null probability is \(\pi_0f_0(x)/f(x)=1\). However, \(\pi_0/\pi_1\) is undefined, so the posterior-odds identity cannot be used. The probability formula handles this boundary case correctly; the odds formula does not.

Assumptions, Diagnostics, and Limits

The derivation is short, but its inputs must be coherent. The two classes must cover the modeled possibilities, and their weights must describe the prior probability of each class. The densities must be normalized distributions on a common scale and with respect to the same measure. A density has units inverse to the units of \(X\), whereas a probability is dimensionless; the ratio of weighted densities in the local FDR is dimensionless, as a probability must be.

Several checks can reveal a mistake before interpreting results:

  • Check the weights: verify that \(\pi_0\geq0\), \(\pi_1\geq0\), and \(\pi_0+\pi_1=1\).
  • Check the denominator: calculate both weighted contributions and their sum. A zero marginal density means the model gives no density to the observed value, so the displayed ratio is undefined there.
  • Check the range: when the denominator is positive, the null contribution is nonnegative and no larger than the sum; hence \(0\leq\operatorname{lfdr}(x)\leq1\).
  • Check normalization: the marginal density should integrate to one, and the marginal-weighted local FDR should integrate to \(\pi_0\).
  • Check scales: do not combine a null density in one unit or parameterization with an alternative density in another. The two contributions must refer to the same observed statistic and measure.

The local FDR is sensitive to the specified weights and component densities. If those model ingredients poorly represent the test statistics, the resulting posterior probabilities may be poorly calibrated even though the algebra is correct. The formula also conditions on the observed value of one statistic; it is not, by itself, a procedure for selecting a rejection threshold or controlling a frequentist error rate. Its interpretation depends on the two-group model and its class definitions.

A frequent mistake is to write \(\operatorname{lfdr}(x)=f_0(x)/f(x)\), arguing that the null density is the evidence for the null. This omits the prior probability \(\pi_0\): Bayes’ theorem uses the joint null contribution \(\pi_0f_0(x)\), not just the conditional density. Another mistake is to divide by \(f_0(x)+f_1(x)\); that denominator ignores the mixture weights and is generally not the marginal density. The correction is to form both weighted contributions first and then normalize their null contribution by their sum.

Key takeaway: Local FDR is the null component’s weighted density divided by the full marginal density. The mixture denominator normalizes the class contributions at each observation; integrated against that marginal, local FDR averages to the prior null proportion.

Check Your Understanding

Answer each question using the two-group mixture definition. Short solutions follow.

  1. If \(\pi_0=0.8\), \(\pi_1=0.2\), \(f_0(x)=0.25\), and \(f_1(x)=0.50\), find \(f(x)\) and the local FDR.
  2. Why must the local FDR be multiplied by the marginal density before integrating to recover \(\pi_0\)?
  3. When are posterior null-to-alternative odds equal to prior odds times a density ratio?
  4. What does the local FDR formula give when \(\pi_0=0\) and \(\pi_1f_1(x)>0\)?
  5. A calculation gives a negative local FDR despite nonnegative mixture weights and densities. Name a likely problem.

Solutions. (1) \(f(x)=0.8(0.25)+0.2(0.50)=0.20+0.10=0.30\). Thus \(\operatorname{lfdr}(x)=0.20/0.30=0.6667\). (2) Multiplication cancels the denominator \(f(x)\), leaving \(\pi_0f_0(x)\), whose integral is \(\pi_0\) because \(f_0\) integrates to one. (3) Require \(\pi_0>0\), \(\pi_1>0\), and both component densities positive at \(x\); then posterior odds are \((\pi_0/\pi_1)(f_0(x)/f_1(x))\). (4) The numerator is zero and the denominator is positive, so the local FDR is zero. (5) With the stated nonnegative inputs and a positive denominator, the ratio cannot be negative; arithmetic, coding, or input handling is inconsistent with the formula.

Clinical Biostats