Tutorials › Statistical Genetics › Label Switching in Ancestry Models

Ancestry and Population Structure · Tutorial 147 of 989

Label Switching in Ancestry Models

Learn to distinguish label switching from genuine model differences and to match ancestry components across runs using explicit, reproducible criteria.

Intermediate 9 min read

What You'll Learn

  • Explain why permuting component labels leaves an ancestry model’s fit unchanged
  • Distinguish label switching from changes in estimated ancestry proportions or allele frequencies
  • Align components across runs by minimizing allele-frequency distance to a reference
  • Align components by comparing ancestry profiles for the same individuals
  • Interpret aligned results without treating arbitrary labels as biological identities

Why Ancestry Labels Can Change

An ancestry-clustering model may estimate several components, each described by allele frequencies and by proportions assigned to those components for each individual. The components are often numbered or given names for display. But those labels are not inherently attached to particular genetic populations. A run that calls a component “1” may be statistically equivalent to another run that calls the same component “3.”

This is called label switching. It is a consequence of the model’s symmetry: if the component labels are permuted consistently in both the ancestry proportions and the allele frequencies, the fitted genetic probabilities do not change. Label switching matters when comparing runs, because a component-by-component comparison made before alignment can make identical results look different. It also matters when summarizing repeated estimates: averages of unaligned component-specific estimates can be misleading.

Definition: In an ancestry model with \(K\) components, label switching occurs when the component labels are permuted while the underlying fitted model remains unchanged. The labels identify positions in a representation, not intrinsically named populations.

The Model Symmetry

Consider a simplified admixture model for diploid genotypes. Let \(Q_{ik}\) be the estimated ancestry proportion of individual \(i\) assigned to component \(k\), and let \(f_{kj}\) be the frequency of a chosen allele at locus \(j\) in component \(k\). The proportions are nonnegative and sum to one for each individual; allele frequencies lie between zero and one. Under this model, the allele probability for an allele copy from individual \(i\) at locus \(j\) is

$$ p_{ij}=\sum_{k=1}^{K} Q_{ik}f_{kj}. $$

For a genotype \(G_{ij}\), coded as the number of copies of the chosen allele (0, 1, or 2), the simplified model treats the count as binomial with two trials and success probability \(p_{ij}\). This representation assumes the two allele copies have the same probability \(p_{ij}\), and models the genotype conditional on the estimated mixture and allele frequencies. It is a useful way to show the label symmetry; particular ancestry methods may use more detailed genotype or haplotype models.

Let \(\pi\) be any permutation of the component indices. Relabel the ancestry proportions and allele frequencies together, setting \(Q'_{ik}=Q_{i,\pi(k)}\) and \(f'_{kj}=f_{\pi(k),j}\). The allele probability under the relabelled parameters is

$$ p'_{ij} =\sum_{k=1}^{K}Q'_{ik}f'_{kj} =\sum_{k=1}^{K}Q_{i,\pi(k)}f_{\pi(k),j} =\sum_{\ell=1}^{K}Q_{i\ell}f_{\ell j} =p_{ij}. $$

The third expression is the same sum, with its terms reordered. Thus every model probability for the observed genotypes is unchanged. Any fit criterion based only on those probabilities, such as the genotype likelihood, is unchanged as well. The model can identify a fitted set of components without identifying a unique ordering of them.

Worked Example: A Two-Component Relabelling

Suppose, for one hypothetical individual at one hypothetical locus, the ancestry proportions are \(Q_{i1}=0.7\) and \(Q_{i2}=0.3\). The allele frequencies are \(f_{11}=0.2\) and \(f_{21}=0.8\). The observed genotype has one copy of the chosen allele, so \(G_{i1}=1\).

The allele probability is \(p_{i1}=0.7(0.2)+0.3(0.8)=0.14+0.24=0.38\). Under the stated binomial genotype model, the probability of observing one copy is \(P(G_{i1}=1)=\binom{2}{1}(0.38)(1-0.38)=2(0.38)(0.62)=0.4712\).

Now swap the component labels in both parameter sets. The new ancestry proportions are \(0.3,0.7\), and the new frequencies are \(0.8,0.2\). The allele probability is \(0.3(0.8)+0.7(0.2)=0.24+0.14=0.38\). The genotype probability remains \(0.4712\). This calculation checks the symmetry for the example: the same individual and locus, the same model, and a consistent swap of both sets of component parameters give exactly the same fitted probability.

Aligning Components Across Runs

To compare two runs, choose one run as a reference and find the permutation of the other run that gives the best match. Alignment changes only the ordering of a run’s components. It does not change its estimated ancestry proportions, allele frequencies, or fit. The matching rule should be stated clearly, because different rules can be appropriate for different comparisons.

One option is to compare estimated allele frequencies at the same set of loci. Write \(f^{(r)}_{kj}\) for component \(k\) in the reference run and \(f^{(s)}_{\ell j}\) for component \(\ell\) in the run to be aligned. A basic squared-distance cost for pairing them is

$$ d_{k\ell}=\sum_{j=1}^{m} w_j\left(f^{(r)}_{kj}-f^{(s)}_{\ell j}\right)^2, $$

where \(m\) is the number of loci included and \(w_j\) are nonnegative weights chosen in advance (equal weights are one option). For each possible permutation \(\pi\), calculate the total cost \(\sum_{k=1}^{K}d_{k,\pi(k)}\), then choose the permutation with the smallest total. With many components, the minimum-cost one-to-one matching can be found using a standard assignment algorithm. This procedure assumes the frequency estimates are comparable: the same allele is counted at each matched locus, and the loci and any weights are defined consistently across runs.

Worked Example: Matching Components by Allele Frequencies

Suppose two hypothetical runs estimate allele frequencies at three shared loci. The reference run has components A, B, and C. The other run has components X, Y, and Z. In each vector, entries are frequencies of the same chosen allele at loci 1, 2, and 3.

Reference A is \((0.10,0.20,0.30)\), B is \((0.80,0.70,0.60)\), and C is \((0.40,0.50,0.60)\). The second run estimates X as \((0.42,0.48,0.58)\), Y as \((0.12,0.18,0.32)\), and Z as \((0.78,0.72,0.62)\). Use equal weights and squared Euclidean distance.

For example, the cost of pairing A with Y is \(d_{AY}=(0.10-0.12)^2+(0.20-0.18)^2+(0.30-0.32)^2=0.0004+0.0004+0.0004=0.0012\). The analogous pairwise costs are:

Reference componentCost to XCost to YCost to Z
A0.25920.00120.8352
B0.19320.81120.0012
C0.00120.25920.1932

The pairing A–Y, B–Z, C–X has total cost \(0.0012+0.0012+0.0012=0.0036\). It matches each reference component to the frequency vector closest to it in the other run. For comparison, pairing A–X, B–Y, C–Z costs \(0.2592+0.8112+0.1932=1.2636\), which is much larger. After alignment, report Y as matching A, Z as matching B, and X as matching C. The numerical labels X, Y, and Z have not acquired biological meanings; they have only been mapped to the chosen reference run.

A second option is to compare ancestry profiles across individuals. This is useful when both runs include the same individuals in the same order. Each component is then represented by a column of ancestry proportions across those individuals. For a reference component \(k\) and a component \(\ell\) in the other run, one can use a distance such as

$$ d_{k\ell}=\sum_{i=1}^{n}\left(Q^{(r)}_{ik}-Q^{(s)}_{i\ell}\right)^2. $$

As with allele-frequency matching, choose the one-to-one permutation with the smallest total distance. Other profile similarity measures, such as correlation, may be useful when the comparison should emphasize pattern rather than absolute values. The measure and matching rule should be reported. Profile matching requires the same individuals in both runs; if the samples differ, the columns do not refer to directly comparable sets of observations.

Worked Example: Matching Components by Ancestry Profiles

Suppose two hypothetical runs include the same four individuals and estimate two components. In the reference run, component A has profile \((0.90,0.80,0.20,0.10)\) and B has profile \((0.10,0.20,0.80,0.90)\). In the second run, U has profile \((0.12,0.18,0.82,0.88)\) and V has profile \((0.88,0.82,0.18,0.12)\). Each row of each run’s ancestry-proportion matrix sums to one, as required.

Using squared profile distance, the cost of matching A to V is \(d_{AV}=(0.90-0.88)^2+(0.80-0.82)^2+(0.20-0.18)^2+(0.10-0.12)^2=4(0.0004)=0.0016\). The cost of matching B to U is also \(0.0016\). Their combined cost is \(0.0032\).

For comparison, the cost of matching A to U is \(0.78^2+0.62^2+(-0.62)^2+(-0.78)^2=1.9856\). The cost of matching B to V is also \(1.9856\), giving a total of \(3.9712\). The lower-cost alignment is therefore A–V and B–U. The calculation is appropriate here because the runs contain the same four individuals and their profiles use the same component definition; it compares like with like.

What Alignment Does—and Does Not—Establish

Alignment removes a purely representational difference. If two runs have the same component estimates in a different order, relabelling them makes the estimates directly comparable. If their frequency vectors or ancestry profiles remain substantially different after the best matching, label switching alone does not explain the discrepancy. Differences may reflect sampling variation, different local solutions, changes in model settings, or other sources of instability. Alignment is not a test that determines which run is correct.

A reference must also be interpreted carefully. Aligning to a run that has named components can preserve those names across later runs, but it does not prove that the names correspond to distinct biological populations. Component labels become substantively interpretable only when their meaning is supported by the design and evidence used to define them. The mechanics of selecting appropriate reference samples are a separate question.

For repeated fits, an arbitrary label order can also corrupt component-specific summaries. For example, averaging the first component’s frequency in each run is not meaningful if “component 1” refers to different fitted components in different runs. Align first, then calculate component-specific summaries. When components are nearly indistinguishable, or when several matchings have similarly low costs, the alignment itself may be ambiguous; report that ambiguity rather than presenting a forced match as definitive.

Common Mistake

  • Wrong reasoning: “The first component has different allele frequencies in the two runs, so the model produced different results.” This conclusion compares labels that may refer to different components.
  • Correction: Compare the full sets of components, find the permutation that best aligns them using a stated criterion, and then inspect the matched estimates. A changed ordering is label switching; differences that remain after alignment are not explained by label switching alone.
Key takeaway: Component labels are exchangeable when a consistent permutation leaves the model probabilities unchanged. Align runs before comparing component-specific estimates, and treat the matching rule—and any ambiguity in it—as part of the analysis.

Check Your Understanding

Try these questions without looking back.

  1. Why must ancestry proportions and component allele frequencies be permuted together for a relabelling to preserve fitted allele probabilities?
  2. Two runs use the same components in different orders. What should you do before comparing component-specific frequencies?
  3. What data are required for ancestry-profile alignment, and why?
  4. If the best alignment still leaves large differences between matched components, can label switching by itself explain those differences? Explain.
  5. Why can averaging a component’s estimated frequency across unaligned runs produce a misleading summary?
Clinical Biostats