Tutorials › Statistical Genetics › Unequal Sample Sizes and Dominant Principal Components

Ancestry and Population Structure · Tutorial 155 of 989

Unequal Sample Sizes and Dominant Principal Components

See how sample proportions shape genotype covariance and PCA, then calculate and compare balanced-subsample and weighted analyses.

Intermediate 11 min read

What You'll Learn

  • Decompose genotype covariance into within-population and between-population components
  • Explain how sample proportions change the size of between-population covariance
  • Distinguish changes in component strength from changes in component direction
  • Calculate a weighted covariance for a specified target population mixture
  • Use balanced subsampling and weighting as complementary PCA sensitivity checks

Why Sample Balance Can Matter for PCA

PCA finds directions of greatest variation in the genotype data it is given. If one ancestry group contributes many more sampled individuals than another, the covariance matrix reflects the sample’s group proportions. It does not automatically give each population equal influence. Consequently, a leading principal component can emphasize differences that are prominent under the sampled mixture, rather than differences that would be prominent under a different target mixture.

This is a feature of the analysis, not necessarily a data error. Unequal group sizes may arise from study design, recruitment, or the available reference samples. The important question is what mixture the analysis is intended to describe. A component’s direction and strength depend on both genetic differences among groups and their representation in the analyzed sample. Imbalance does not always change the direction: with two groups and only between-group variation, it changes the amount of variance in their separation but not the separation’s direction. With several groups, or with within-group variation, it can also change which direction leads.

Covariance Under a Sampled Population Mixture

Let \(G_{ij}\) be the genotype dosage for individual \(i\) at marker \(j\), coded as 0, 1, or 2 copies of a specified allele. Let \(Z\) denote the individual’s population group, and let \(q_g=P(Z=g)\) be the proportion of group \(g\) in the mixture being analyzed. These proportions refer to the sampled mixture unless a different target mixture is explicitly specified. For now, treat genotype dosages as unscaled; centering and scaling choices also affect PCA and should be held fixed when comparing analyses.

Definition: The covariance of two genotype dosages in a population mixture decomposes into a within-group part and a between-group part. For markers \(j\) and \(k\), with group-specific means \(\mu_{gj}=E(G_j\mid Z=g)\) and overall means \(\mu_j=E(G_j)\), $$ \operatorname{Cov}(G_j,G_k) = \sum_g q_g\operatorname{Cov}(G_j,G_k\mid Z=g) + \sum_g q_g(\mu_{gj}-\mu_j)(\mu_{gk}-\mu_k). $$

The first term averages covariance within groups. The second term is covariance among the group means, with each group weighted by its mixture proportion. Thus, even if markers have no covariance within any group, their dosages can covary in the pooled data because their group means differ together. Changing the \(q_g\) values changes that between-group term.

For two groups with proportions \(q\) and \(1-q\), write the group-mean differences as \(\Delta_j=\mu_{1j}-\mu_{2j}\) and \(\Delta_k=\mu_{1k}-\mu_{2k}\). The between-group covariance is $$ q(1-q)\Delta_j\Delta_k. $$ This expression makes two points clear. The contribution is largest at \(q=1/2\) for a fixed difference in means, and it becomes smaller as one group becomes rare. The sign depends on whether the two markers’ group means move in the same direction or in opposite directions. The formula does not say that every individual marker’s variance must fall with imbalance: within-group variance also contributes, and standardization can change the relative influence of markers.

Worked Example: Computing the Between-Group Covariance

Consider a hypothetical sample with two groups. Group 1 makes up 80% of the sample and group 2 makes up 20%. At two dosage-coded markers, suppose the group mean dosages are \((1.6, 1.0)\) and \((0.4, 0.8)\), respectively. Assume, for this calculation, that within-group covariance between the two markers is zero.

The differences between group means are \(\Delta_1=1.6-0.4=1.2\) and \(\Delta_2=1.0-0.8=0.2\). The pooled between-group covariance is therefore $$ 0.8(1-0.8)(1.2)(0.2) = (0.16)(0.24) = 0.0384 $$ in squared dosage units. The overall mean dosages are \(0.8(1.6)+0.2(0.4)=1.36\) at the first marker and \(0.8(1.0)+0.2(0.8)=0.96\) at the second, consistent with both group means being above or below their overall means together.

If the same two group means were combined with equal proportions, the between-group covariance would instead be $$ 0.5(1-0.5)(1.2)(0.2) = (0.25)(0.24) = 0.0600. $$ The genetic differences have not changed; only their weighting in the mixture has changed. These calculations isolate the between-group term and are not a claim that real within-group covariance is zero.

How the Mixture Influences Principal Components

For centered genotype data, PCA finds eigenvectors of the covariance matrix; equivalently, its first component is the direction with greatest variance among the analyzed individuals. If a group is overrepresented, the pooled mean is pulled toward that group, and deviations from that mean are weighted according to the observed group counts. The resulting covariance matrix can give a different amount of importance to contrasts among groups than a matrix formed under another mixture.

It is useful to distinguish component strength from component direction. Under a two-group model in which all relevant covariance comes from the difference between the two group means, the between-group covariance matrix is proportional to the outer product of the mean-difference vector with itself. Changing the group proportions changes the proportionality factor \(q(1-q)\), but not the vector’s direction. With three or more group means, however, different contrasts can be weighted differently as proportions change. The leading eigenvector can rotate, and the order of leading components can change. Within-group covariance can also affect both the direction and ordering.

Worked Example: A Leading Component Rotates With Group Proportions

Consider a hypothetical two-marker data set with three groups. Suppose every individual in group A has dosage vector \((0,0)\), in group B has \((2,0)\), and in group C has \((0,1)\). These deliberately simple data have no within-group variation, so the covariance comes entirely from differences among group means. Use covariance with divisor \(n\); using \(n-1\) instead would multiply the matrix by a common positive constant and leave the PCA directions unchanged.

First take sample proportions \(0.8, 0.1, 0.1\) for A, B, and C. The pooled mean is \((0.2,0.1)\). The weighted second-moment matrix about zero is \(\begin{pmatrix}0.4&0\\0&0.1\end{pmatrix}\), so subtracting the outer product of the mean gives $$ \begin{pmatrix}0.4&0\\0&0.1\end{pmatrix} - \begin{pmatrix}0.2\\0.1\end{pmatrix} \begin{pmatrix}0.2&0.1\end{pmatrix} = \begin{pmatrix}0.36&-0.02\\-0.02&0.09\end{pmatrix}. $$

For a symmetric matrix with entries \(a,b;b,d\), the leading eigenvector’s angle \(\theta\) to the first marker axis satisfies \(2\theta=\operatorname{atan2}(2b,a-d)\). Here, \(\theta=\tfrac12\operatorname{atan2}(-0.04,0.27)\), approximately \(-4.2^\circ\). The leading eigenvalue is approximately \(0.3615\) squared dosage units.

Now give each group equal weight. The pooled mean is \((2/3,1/3)\), and the covariance becomes $$ \begin{pmatrix}4/3&0\\0&1/3\end{pmatrix} - \begin{pmatrix}2/3\\1/3\end{pmatrix} \begin{pmatrix}2/3&1/3\end{pmatrix} = \begin{pmatrix}8/9&-2/9\\-2/9&2/9\end{pmatrix}. $$ The leading angle is \(\tfrac12\operatorname{atan2}(-4/9,2/3)\), approximately \(-16.8^\circ\), and the leading eigenvalue is approximately \(0.9562\) squared dosage units. Both the strength and direction differ from the unequal-mixture result. This change occurs because the three group means create more than one possible contrast, and their contributions are weighted differently.

Balanced Subsampling and Weighting

Two practical sensitivity checks ask how the PCA would look under a more balanced representation. Balanced subsampling repeatedly draws the same number of individuals from each group, then recomputes PCA using the same marker set and preprocessing. This directly shows how component results vary across balanced draws. It discards some observations from larger groups in each draw, so it may be less precise than an analysis using all individuals. Repeating the draws helps reveal whether apparent changes are consistent or depend strongly on which individuals were selected.

Weighting retains all sampled individuals but changes each individual’s contribution to the covariance. Choose target proportions \(r_g\) that sum to one. If the observed group counts are \(n_g\), assign each individual in group \(g\) weight \(w_i=r_g/n_g\). The weights sum to one within the target mixture. Form the weighted mean and covariance as $$ \boldsymbol{\mu}_w=\sum_i w_i\mathbf{G}_i, \qquad \mathbf{C}_w=\sum_i w_i(\mathbf{G}_i-\boldsymbol{\mu}_w)(\mathbf{G}_i-\boldsymbol{\mu}_w)^\mathsf{T}. $$ Here \(\mathbf{G}_i\) is the vector of an individual’s marker dosages. PCA of \(\mathbf{C}_w\) describes variation under the specified target mixture. Multiplying every weight by the same positive constant would only multiply the covariance by that constant, not change its eigenvectors.

Weighting and balanced subsampling are related but not identical checks. Weighting uses all available individuals and imposes the chosen mixture directly. Subsampling creates data sets with balanced group counts, so its results can vary from draw to draw. Agreement between them can support the conclusion that a feature is not driven solely by the original imbalance; disagreement may reflect sampling variability, influential individuals, or differences in the effective analysis. Neither procedure establishes that equal group proportions are the scientifically correct target. The target should match the question, and the original unweighted result should be reported when it describes the actual sampled cohort.

Worked Example: Weighting Three Unequal Groups Equally

Suppose the hypothetical groups in the preceding example have \(n_A=80\), \(n_B=10\), and \(n_C=10\) sampled individuals. To give each group one-third of the total weight, assign each person in A weight \((1/3)/80=1/240\), and each person in B or C weight \((1/3)/10=1/30\). The group weights sum to \(80/240=1/3\), \(10/30=1/3\), and \(10/30=1/3\).

With group dosages \((0,0)\), \((2,0)\), and \((0,1)\), the weighted mean is $$ \boldsymbol{\mu}_w = \frac13(0,0)+\frac13(2,0)+\frac13(0,1) = (2/3,1/3). $$ The weighted second moment about zero is \(\begin{pmatrix}4/3&0\\0&1/3\end{pmatrix}\). Subtracting the mean’s outer product gives $$ \mathbf{C}_w = \begin{pmatrix}4/3&0\\0&1/3\end{pmatrix} - \begin{pmatrix}4/9&2/9\\2/9&1/9\end{pmatrix} = \begin{pmatrix}8/9&-2/9\\-2/9&2/9\end{pmatrix}. $$

This is the equal-mixture covariance from the preceding calculation. In this constructed example, every person within a group has the same genotype vector, so balanced subsampling also gives exactly that covariance. In real data, individuals within a group differ; balanced subsampling can therefore produce different estimates from draw to draw, while weighting gives one covariance for the selected target weights.

Assumptions and Interpretation in Practice

These comparisons are meaningful only if the analyses are otherwise comparable. Use the same marker set, genotype coding, missing-data handling, centering, and scaling choices when contrasting the original, subsampled, and weighted PCAs. In particular, changing allele-frequency estimates or marker scaling at the same time as changing group weights can make it unclear which choice caused a difference. If markers are scaled, the intended scaling rule should be applied consistently and stated; scaling can change which markers contribute most to covariance.

The group labels must also be appropriate for the sensitivity question. The covariance calculation conditions on the groups used to define \(q_g\) or \(r_g\); it does not discover the groups or prove that they are discrete biological populations. In continuous geographic structure, bins or labels may be an approximation, and results can depend on how they were defined. Furthermore, weighting can correct unequal representation only for the specified target mixture and measured groups. It cannot repair unmeasured structure, incorrect labels, or other sources of bias by itself.

Interpret the result as a sensitivity analysis, not as a rule that the balanced PCA is necessarily more valid. If the leading directions remain similar under balanced subsampling and reasonable target weights, that is evidence that they are not highly dependent on the original sample proportions. If they change substantially, describe which directions, group contrasts, or variance rankings change, and explain the target mixture behind each analysis. PCA is an unsupervised summary of variation in the analyzed data; a component is not automatically a causal effect or a definitive ancestry label.

Common Mistakes

  • Wrong: “The largest group must determine the first PC.” Correction: The leading component maximizes total variance. Group size affects the covariance, but genetic differences, within-group variation, marker scaling, and the geometry of all group means also matter.
  • Wrong: “Unequal group sizes always rotate the PCs.” Correction: In the two-group, between-group-only case, imbalance changes the size of the covariance contribution but not the direction of the group-mean contrast. Rotation is possible, not inevitable.
  • Wrong: “Equal weighting is unbiased.” Correction: Weighting estimates variation under the target proportions chosen by the analyst. Equal proportions are a sensitivity target, not automatically the correct population mixture.
  • Wrong: “If weighted and subsampled PCs differ, one method must be wrong.” Correction: Subsampling varies across draws and loses observations; weighting retains observations but changes their influence. Differences can be informative about sensitivity and sampling variability.
Key takeaway: The proportions of sampled groups enter the genotype covariance that PCA analyzes. Balanced subsampling and explicit weighting can test how much PCA results depend on those proportions, provided the target mixture and all other analysis choices are made clear.

Check Your Understanding

Answer these questions using the covariance decomposition and sensitivity checks.

  1. For two groups with proportions \(q\) and \(1-q\), what happens to the between-group covariance when the groups’ mean dosages differ but \(q\) becomes very small?
  2. Why can imbalance change the leading component’s direction with three groups, even though it does not necessarily do so in the two-group, between-group-only case?
  3. A study has 60 individuals in group A and 20 in group B. What weight should each individual receive if the target mixture gives the groups equal total weight?
  4. Why should marker scaling and the marker set be held fixed when comparing unweighted and weighted PCA?
  5. Give one reason balanced subsampling and weighting might produce different PCA results in a real data set.
Clinical Biostats