Estimate Kinship and \(F_{\text{ST}}\) under Arbitrary Population Structure with popkin

Alejandro Ochoa and John D. Storey

2019-12-17

\[ \newcommand{\Fst}{F_{\text{ST}}} \newcommand{\ft}[1][j]{f_{#1}^T} \newcommand{\kt}[1][k]{\varphi_{j#1}^T} \]

Introduction

The popkin (“population kinship”) package estimates the kinship matrix of individuals and \(\Fst\) from their biallelic genotypes. Our estimation framework is the first to be practically unbiased under arbitrary population structures (Ochoa and Storey 2016a, 2016b). Here we briefly summarize the notation and intuition behind the key parameters.

Kinship and inbreeding coefficients

Kinship and inbreeding coefficients are probabilities of “identity by descent” (IBD) carefully defined elsewhere (Ochoa and Storey 2016a, 2016b). The reference ancestral population \(T\) sets the level of relatedness treated as zero (as demonstrated in the sample usage section below). \(\ft\) is the inbreeding coefficient of individual \(j\) when \(T\) is the ancestral population, and \(\kt\) is the kinship coefficient of the pair individuals \(j,k\) when \(T\) is the ancestral population. In a structured population we expect most \(\ft,\kt >0\). If \(j,k\) are the parents of \(l\) then \(\ft[l] = \kt\), so within a panmictic subpopulation we expect \(\ft \approx \kt\) for \(j \ne k\). The “self-kinship” \(j=k\) case equals \(\kt[j] = \frac{1}{2}\left( 1+\ft \right)\) rather than \(\ft\).

Let \(\Phi^T = (\kt)\) be the \(n \times n\) matrix that contains all kinship coefficients of all individuals in a dataset. The ancestral population \(T\) is the most recent common ancestor (MRCA) population if and only if \(\min \kt = 0\), assuming such unrelated pairs of individuals exist in the dataset. Thus, the only role \(T\) plays in our estimates is determining the level of relatedness that is treated as zero.

Note that the diagonal of our estimated \(\Phi^T\) contains \(\kt[j]\) values rather than \(\ft\), which is required for statistical modeling applications; however, \(\kt[j]\) tends to take on much greater values than \(\kt\) for \(j \ne k\), while \(\ft \approx \kt\) for \(j \ne k\) within panmictic subpopulations (see above), so for visualization we strongly recommend replacing the diagonal of \(\Phi^T\) with \(\ft\) values.

The generalized \(\Fst\)

\(\Fst\) is also an IBD probability that equals the mean inbreeding coefficients in a population partitioned into homogeneous subpopulations. We recently generalized the \(\Fst\) definition to arbitrary population structures—dropping the need for subpopulations—and generalized the partition of “total” inbreeding into “local” inbreeding (due to having unusually closely related parents) and “structural” inbreeding (due to the population structure) (Ochoa and Storey 2016a). The current popkin estimates the total kinship matrix \(\Phi^T\) only; in the future, popkin will also extract the structural kinship matrix. However, when all individuals are “locally outbred”—the most common case in population data—\(\Fst\) is simply the weighted mean inbreeding coefficient: \[ \Fst = \sum_{j=1}^n w_j \ft, \] where \(0 < w_j < 1, \sum_{j=1}^n w_j = 1\) are weights for individuals intended to help users balance skewed samples (i.e. if there are subpopulations with much greater sample sizes than others). The current popkin version assumes all individuals are locally outbred in estimating \(\Fst\).

The individual-level pairwise \(\Fst\)

Another quantity of interest is the individual-level pairwise \(\Fst\), which generalize the \(\Fst\) between two populations to pairs of individuals. Here each comparison between two individuals has a different ancestral population, namely the MRCA population of the two individuals. When individuals are again locally outbred and also locally unrelated, the pairwise \(\Fst\) is given in terms of the inbreeding and kinship coefficients (Ochoa and Storey 2016a): \[ F_{jk} = \frac{\frac{\ft+\ft[k]}{2}-\kt}{1-\kt}. \] The popkin package also provides an estimator of the pairwise \(\Fst\) matrix (containing \(F_{jk}\) estimates between every pair of individuals).

Sample usage

Input genotype data

The popkin function accepts biallelic genotype matrices in three forms:

  1. A genotype matrix X with values in c(0,1,2,NA) only. It is preferable, though not necessary, for X to be an integer matrix (with values in c(0L,1L,2L,NA) only, see ?storage.mode). This standard encoding for biallelic SNPs counts reference alleles: 2 is homozygous for the reference allele, 0 is homozygous for the alternative allele, 1 is heterozygous, and NA is missing data. Which allele is the reference does not matter: popkin estimates the same kinship and \(\Fst\) for X and 2-X. By default popkin expects loci along rows and individuals along columns (an \(m \times n\) matrix); a transposed X is handled best by also setting loci_on_cols = TRUE.

  2. BED-formatted data loaded with the BEDMatrix package, which popkin uses to keep memory usage low. For example, load myData.bed, myData.bim, myData.fam using:

This BEDMatrix object is not a regular matrix but popkin handles it correctly. Other genotype formats can be converted into BED using plink2 or other software.

  1. A function X(m) that when called loads the next \(m\) SNPs of the data, returning an \(m \times n\) matrix in the format of Case 1 above. This option allows direct and memory-efficient processing of large non-BED data, but should be the last resort since users must write their own functions X(m) for their custom formats. Try first converting your data to BED and loading with BEDMatrix.

Load and clean sample data

For illustration, let’s load the real human data worldwide sample (“HGDP subset”) contained in the lfa package:

This data has \(m=5000\) loci and \(n=159\) individuals, and is oriented as popkin expects by default. These samples have labels grouping them by continental subpopulation in colnames(X). To make visualizations easier later on, let’s shorten these labels and reorder to have nice blocks:

Here’s a quick view of the top left corner of the matrix X with values in 0, 1, 2, and NA (this example has no missing values, but popkin handles them too). This matrix does not preserve the identity of the reference or alternative alleles, but this distinction does not matter for estimating kinship and \(\Fst\).

Now we’re ready to analyze this data with popkin!

Estimate and visualize kinship using genotypes and subpopulations

Estimating a kinship matrix requires the genotype matrix X and subpopulation levels used only to estimate the minimum level of kinship. Using the lfa sample data we cleaned in the last subsection, obtaining the estimate is simple:

Now let’s visualize the raw kinship matrix estimate:

Ignoring the overlapping labels for a moment, this plot shows that self-kinship (the diagonal) is much greater than kinship between different individuals (min \(\kt[j] \ge 0.5\)). It makes more sense to plot inbreeding (\(\ft\)) values on the diagonal (they are on the same scale as \(\kt\) for \(j \ne k\)), which is achieved using inbr_diag:

Now let’s tweak the plot. We improve the labeling by setting labs_even = TRUE, which arranges the subpopulation labels with equal spacing and adds lines that map to their blocks. To see these new lines, we must move these labels further from the heatmap by setting labs_line = 1. We shrink the labels with labs_cex = 0.7.

This figure clearly shows the population structure of these worldwide samples, with block patterns that are coherent with serial founder effects in the dispersal of humans out of Africa. Since only \(m = 5000\) SNPs are included in this sample, the estimates are noisier than in more complete data (datasets routinely have over 300K SNPs).

This figure also illustrates how subpopulations are used to estimate kinship by popkin: they only set the zero kinship as the mean kinship between the two most distant populations, which in this case are AFR and AMR.

Estimate \(\Fst\) and individual inbreeding from a kinship matrix

Since \(\Fst\) is the weighted mean of the inbreeding coefficients, and since some subpopulations are overrepresented in this data (EAS is much larger than the rest), it makes sense to use weights that balance these subpopulations:

If you compare these estimates to those we obtained for Human Origins (Ochoa and Storey 2016a), you’ll notice things look a bit different: here \(\Fst\) is smaller and the kinship within AFR is relatively much higher than within EUR or EAS. Besides containing many fewer SNPs, the SNPs in this HGDP sample were likely biased for common variants in Europeans, which might explain the difference.

We can also extract the vector of inbreeding coefficients from the kinship matrix using inbr:

Estimate individual-level pairwise \(\Fst\) matrix from a kinship matrix

We calculate individual-level pairwise \(\Fst\) estimates from the previous kinship estimates using pwfst. Note that the pairwise \(\Fst\) is a distance between pairs of individuals: approximately zero for individuals in the same population, and increasing for more distant pairs of individuals.

Rescale kinship matrix in a subset of the data

Suppose now you’re interested in one subpopulation, say AFR:

Removing populations changes the MRCA population \(T\), drastically in this case (the reason the minimum kinship is so large and the within-AFR \(\Fst\) above is wrong). To ensure the minimum kinship is zero, instead of re-estimate the kinship matrix from the subset genotypes, it suffices to rescale the given kinship matrix with rescale_popkin!

There is clear substructure within Sub-Saharan Africa, but this sample data does not have more detailed labels that could help us interpret further.

Plot multiple kinship matrices together

As a final example, we plot the global kinship and the rescaled AFR subset kinship_AFR side-by-side, illustrating how more than one kinship matrix can be plotted with a shared legend.

Plot kinship matrices with multiple levels of labels

The plot_popkin function has advanced options for plotting more than one level of labels. For this example, we will highlight the three “blocks” that represent the first two splits in the human migration out of Africa:

Now we add a second panel to what we have above, showing how options must be passed when labels differ per panel and there are multiple levels:

Each panel can also have its own scale:

References

Ochoa, Alejandro, and John D. Storey. 2016a. “\(F_{\text{ST}}\) And Kinship for Arbitrary Population Structures I: Generalized Definitions.” bioRxiv doi:10.1101/083915. https://doi.org/10.1101/083915.

———. 2016b. “\(F_{\text{ST}}\) And Kinship for Arbitrary Population Structures II: Method of Moments Estimators.” bioRxiv doi:10.1101/083923. https://doi.org/10.1101/083923.