scieee AI-readable full text Open interactive document viewer

Unsupervised clustering for ancestry inference with neural networks

Dominguez Mantes, Albert

Abstract

Caracteritzar les estructures genètiques de poblacions ha esdevingut cada cop més important donat que els estudis d'associació genètica i predictius s'han estès a cohorts cada cop més diversos. ADMIXTURE i STRUCTURE són algorismes d'agrupament no supervisats àmpliament utilitzats per caracteritzar aquestes estructures. Aquests mètodes descomposen genomes individuals en assignacions de grups fraccionals, on cada grup és representat per un vector de freqüencies de marcadors de l'ADN. Aquestes assignacions i grups poden ser interpretats per geneticistes com a la descripció de l'estructura de la població a nivell d'individu. Tanmateix, el nombre creixent de variants seqüenciades per individu i la mida en constant augment dels biobancs fa que aquests mètodes tradicionals siguin intractables computacionalment. A més a més, múltiples execucions amb diversos hiperparàmetres solen ser necessàries per trobar una solució que descrigui bé els grups de les poblacions, fet que contribueix a necessitar, potencialment, dies de càlcul. En aquest projecte explorem un nou model, \textit{Neural ADMIXTURE}, una xarxa neuronal de tipus "autoencoder" que, basat en les mateixes hipòtesis que ADMIXTURE, subministra agrupaments similars (fins i tot millors) que ADMIXTURE a la vegada que redueix el temps d'execució diversos ordres de magnitud. A més a més, la xarxa pot ser fàcilment modificada per calcular diversos agrupaments a la vegada, fet que equival a executar l'ADMIXTURE original múltiples vegades amb un nombre diferent de grups. Els models es poden emmagatzemar fàcilment, permetent assignar grups a dades noves amb complexitat lineal en el nombre de dades d'entrada.

Full text

Data Science and Engineering Unsupervised Clustering for Ancestry Inference with Neural Networks Bachelor’s Degree Final Thesis ·June 2021 Author Albert Dominguez Mantes Directors Alexander G. Ioannidis Department of Biomedical Data Science Stanford University Daniel Mas Montserrat Department of Biomedical Data Science Stanford University Xavier Giró-i-Nieto Signal Theory and Communications Department Universitat Politècnica de Catalunya Escola Tècnica Superior d’Enginyeria de les Telecomunicacions Facultat de Matemàtiques i Estadística Facultat d’Informàtica de Barcelona Unsupervised Clustering for Ancestry Inference with Neural Networks 1 Abstract Characterizing the genetic structure of populations has become increasingly important as genetic association and prediction studies are extended to increasingly diverse cohorts. ADMIXTURE and STRUCTURE are unsupervised clustering algorithms widely used to characterize such ancestral genetic structure. These methods decompose individual genomes into fractional cluster assignments with each cluster representing a vector of DNA marker frequencies. These assignments and clusters provide an interpretable representation for geneticists to describe population structure at the sample level. However, with the rapidly increasing size of population biobanks and the growing numbers of variants genotyped (or sequenced) per sample, such traditional methods become computationally intractable. Furthermore, multiple runs with different hyperparameters are required to properly depict the population clusters using these traditional methods, leading to days of compute. In this project we explore a novel way to calculate such assignments, Neural ADMIXTURE, a neural network autoencoder that follows the same modeling assumptions as ADMIXTURE, providing similar (or even better) clustering, while reducing the compute time by orders of magnitude. In addition, the network can be tweaked to compute several assignments at once, providing the equivalent results as running the original ADMIXTURE algorithm multiple times with different numbers of clusters. The models can easily be stored, allowing later cluster assignment to be performed with a linear computational time on the number of samples. Unsupervised Clustering for Ancestry Inference with Neural Networks 2 Resum Caracteritzar les estructures genètiques de poblacions ha esdevingut cada cop més important donat que els estudis d’associació genètica i predictius s’han estès a cohorts cada cop més diversos. ADMIXTURE i STRUCTURE són algorismes d’agrupament no supervisats àmpliament utilitzats per caracteritzar aquestes estructures. Aquests mètodes descomposen genomes individuals en assignacions de grups fraccionals, on cada grup és representat per un vector de freqüencies de marcadors de l’ADN. Aquestes assignacions i grups poden ser interpretats per geneticistes com a la descripció de l’estructura de la població a nivell d’individu. Tanmateix, el nombre creixent de variants seqüenciades per individu i la mida en constant augment dels biobancs fa que aquests mètodes tradicionals siguin intractables computacionalment. A més a més, múltiples execucions amb diversos hiperparàmetres solen ser necessàries per trobar una solució que descrigui bé els grups de les poblacions, fet que contribueix a necessitar, potencialment, dies de càlcul. En aquest projecte explorem un nou model, Neural ADMIXTURE, una xarxa neuronal de tipus "autoencoder" que, basat en les mateixes hipòtesis que ADMIXTURE, subministra agrupaments similars (fins i tot millors) que ADMIXTURE a la vegada que redueix el temps d’execució diversos ordres de magnitud. A més a més, la xarxa pot ser fàcilment modificada per calcular diversos agrupaments a la vegada, fet que equival a executar l’ADMIXTURE original múltiples vegades amb un nombre diferent de grups. Els models es poden emmagatzemar fàcilment, permetent assignar grups a dades noves amb complexitat lineal en el nombre de dades d’entrada. Unsupervised Clustering for Ancestry Inference with Neural Networks 3 Resumen Caracterizar las estructuras genéticas de las poblaciones ha devenido cada vez más importante dado que los estudios de asociación genética y predicción se han extendido a cohortes cada vez más variados. ADMIXTURE y STRUCTURE son algoritmos de agrupamiento no supervisados ámpliamente usados para caracterizar estas estructuras. Estos métodos descomponen genomas individuales en asignaciones fraccionales de varios grupos, donde cada grupo es representado por un vector de frecuencias de marcadores del ADN. Estas asignaciones y grupos pueden ser interpretados por geneticistas como la descripción de la estructura de la población a nivel de individuo. Sin embargo, el número creciente de variantes secuenciadas por individuo y el tamaño en constante aumento de los biobancos hace que estos métodos tradicionales sean intratables computacionalmente. Además, múltiples ejecuciones con distintos hiperparámetros suelen ser necesarias para encontrar una solución que describa bien a los grupos de las poblaciones, hecho que contribuye a necesitar, potencialmente, dias de cálculo. En este proyecto exploramos un nuevo modelo, Neural ADMIXTURE, una red neuronal de tipo "autoencoder" que, basado en las mismas hipótesis que ADMIXTURE, proporciona agrupamientos similares (incluso mejores) que ADMIXTURE a la vez que reduce el tiempo de ejecución varios órdenes de magnitud. Además, la red puede ser fácilmente modificada para calcular distintos agrupamientos a la vez, hecho equivalente a ejecutar el ADMIXTURE original múltiples veces con un número distinto de grupos. Los modelos pueden almacenarse fácilmente, permitiendo asignar grupos a datos nuevos con complejidad lineal en el número de datos de entrada. Unsupervised Clustering for Ancestry Inference with Neural Networks 4 Acknowledgements I would like to thank my directors Xavi, Alex and Daniel for their helpful advice and guidance during the development of the project. Being able to work with them has been a pleasure, and I am sure that the experience and knowledge I have acquired with them will be very useful in the future. I would also like to thank my parents and brother for always being so supportive and helping me achieve my goals. Finally, I want to acknowledge my friends for the countless nights spent discussing and doing our respective projects, and keeping each other company. Contents 1 Introduction 6 1.1 Goalsoftheproject............................... 7 1.2 Specifications .................................. 8 2 The human genome and ancestry inference 9 2.1 Humangenome................................. 9 2.1.1 Single-nucleotide polymorphisms . . . . . . . . . . . . . . . . . . 9 2.2 Genetic ancestry estimation . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3 Related work 11 4 Background 13 4.1 ADMIXTURE .................................. 13 4.1.1 Modelling assumptions . . . . . . . . . . . . . . . . . . . . . . . . 13 4.1.2 Problem formulation . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.1.3 Optimization .............................. 15 4.1.3.1 Block relaxation . . . . . . . . . . . . . . . . . . . . . . . 15 4.1.3.2 Sequential quadratic programming . . . . . . . . . . . . 15 4.1.4 Supervisedmode............................ 16 4.1.5 Projective analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.2 Autoencoders .................................. 16 5 Neural ADMIXTURE 18 5.1 Networkarchitecture.............................. 18 5.2 Decoderinitialization.............................. 20 5.3 Multi-head architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 5.4 Supervisedtraining............................... 22 5.5 Pretrained Neural ADMIXTURE . . . . . . . . . . . . . . . . . . . . . . . 23 6 Experiments 25 6.1 Datasets ..................................... 25 6.2 Benchmarksetup ................................ 27 6.3 Single-headresults ............................... 29 6.4 Multi-headresults................................ 31 7 Conclusions 36 8 Future work 37 Bibliography 38 Appendix A: Results 41 5 Unsupervised Clustering for Ancestry Inference with Neural Networks 6 1 Introduction The rapid growth in numbers of sequenced human genomes and the proliferation of population-scale biobanks have enabled the creation of increasingly accurate models to predict traits and disease risk based on an individual’s genome. However, different predictive models can be required depending on an individual’s genetic ancestry, and this requires accurately characterizing an individual’s genetic ancestry composition at the individual level [23]. Such characterization is also an essential part of most modern population genetic studies and national biobanking projects. However, many existing algorithms for genetic analyses struggle to keep up with next generation sequencing data sets, where both the number of samples and the number of sequenced positions along the genome, are much larger. This has created an intense need for more computationally efficient and accessible methods for detailed large-scale structure analyses. To date, the vast majority of association studies, such as genome-wide association studies (GWAS), which look for correlations between genomics sequences and phenotypes (expressed genes), and predictive models, such as polygenic risk scores (PRS), which indicate genetic predisposition to phenotypes, still rely on samples from individuals with European descent excluding most of the world’s population and creating a new divide in healthcare [25]. The inclusion of fast, interpretable algorithms that characterize the ancestry makeup of genetic sequences is an essential part of facilitating the creation of diverse association studies, and thus plays a key role in the expansion of personalized genomic medicine to all populations. A common approach for resolving the population structure within a genetic dataset is to describe each sample by a set of proportional cluster assignments obtained through an unsupervised clustering algorithm. Such methods take as input each individual’s sequence of single nucleotide polymorphisms (SNPs), that is, those positions along the genome known to vary between individuals. There are over 10 million known SNPs in the human genome with most of the remainder of the human DNA sequence shared in common among all humans. Such positions are commonly encoded with a binary value, where 0 is used to encode the most common variant at that SNP position on the genome, and 1 is used to encode the minority (or sometimes called “alternate”) variant. This binary (biallelic) encoding works, because the vast majority of such variable positions have only one alternative to the common variant. The frequency distribution of these variants, and the correlations (linkage disequilibrium) between neighboring SNPs, will vary between populations due to different founder events, migration histories, and genetic drift experienced by those different populations. These differences can lead to predictive models trained on one population failing when faced with sequences from an unseen population. In addition, differing variant frequencies between populations can provide valuable historical and demographic information such as divergence times between populations, migration events between populations, and population size histories [26]. In this project we present an autoencoder that implements one of the most widely used Unsupervised Clustering for Ancestry Inference with Neural Networks 7 clustering methods for population genetics applications: ADMIXTURE [3, 2]. The network, which we have named Neural ADMIXTURE, follows the same modeling assumptions as ADMIXTURE but re-frames the task as a neural network-based autoencoder, while providing much faster computational times, both on GPU and CPU, and similar (even higher) quality cluster assignments. The proposed method is fully compatible with the original ADMIXTURE framework, allowing use of ADMIXTURE results as initialization for Neural ADMIXTURE parameters, and vice-versa. Moreover, a supervised version is also included, which aids the learning of the autoencoder by adding a regular classification loss to the bottleneck. Additionally, we introduce Multi-head Neural ADMIXTURE, an extension to Neural ADMIXTURE which combines multiple decoders to obtain clustering results equivalent to running the original ADMIXTURE repeatedly for different numbers of clusters. In this report, we will first briefly describe some basic genetics background required to understand the rest of the work (Section 2). We will then introduce the related work (Section 3), followed by an in-depth explanation of ADMIXTURE and a general description of autoencoders (Section 4). In Section 5 we will introduce Neural ADMIXTURE along with some theoretical results as well as all the modifications to the network. We will present and discuss the results obtained by the network, mainly comparing them to results given by ADMIXTURE, in Section 6. Finally, the last sections will contain the main conclusions of the project, as well as specific future work which should be performed to extend the network. 1.1 Goals of the project The main goal of the project is to design and implement Neural ADMIXTURE, the neural network version of ADMIXTURE, and test its performance in both terms of clustering quality and speed compared to the classical ADMIXTURE algorithm in more that one dataset. Our objective is to make Neural ADMIXTURE achieve better clustering and performance results to its classical counterpart, both qualitatively and quantitatively. An architecture which is able to compute more than one cluster assignment, which we call the multi-head version of Neural ADMIXTURE, will also be implemented. The results of this architecture will be analyzed, albeit not in a comparative way. Finally, apart from actually implementing the network, our goal is to deliver a productionready open-source software for researchers to freely use at their will. While the ADMIXTURE software is free to use, its code has not been made public. By making our work public, we want people to contribute their ideas and expand the project in several directions. The delivered CLI software must be easy to use, with an interface more or less resembling ADMIXTURE’s. Moreover, the code must be easily readable and maintainable, as we want to allow the community to modify and extend the code (under our supervision) if deemed appropriate. Unsupervised Clustering for Ancestry Inference with Neural Networks 14 P(C, C) =  X k qik(1 −fkj)  2 P(C, A) =  X k qik(1 −fkj)  X k qikfkj  P(A, C) =  X k qikfkj  X k qik(1 −fkj)  P(A, A) =  X k qikfkj  2 . (1) We observe that P(C,A) = P(A,C). Note that in terms of counts, then P(nij = 0) = P(C, C) P(nij = 1) = 2P(C, A)=2P(A, C) P(nij = 2) = P(A, A). (2) Using this result along with the fact that Pkqik = 1, we conclude that nij ∼Bin(2, pij ), where pij =Pkqikfkj. 4.1.2 Problem formulation Let Q= (qik)and F= (fkj). We want to maximize the log-likelihood on the training data, which is equivalent to minimizing the negative log-likelihood. As samples are independent, the negative log-likelihood is LC(Q, F) = −X i,j   nij log  X k qikfkj + (2 −nij) log  1−X k qikfkj   .(3) However, as seen in the assumptions, some restrictions must be enforced. ADMIXTURE optimizes the following problem: min Q,F LC(Q, F) s. to 0≤fkj ≤1 X k qik = 1 qik ≥0 (4) Unsupervised Clustering for Ancestry Inference with Neural Networks 15 where the restrictions on Qnaturally arise from the fact that qik are positive fractions, while the restrictions on Fare due to fkj being frequencies. Note that the negative loglikelihood is convex on Qif fixing F, and vice-versa. Furthermore, as populations can be freely permuted, the function should have at least K!global minima. This does not appear to affect convergence [3]. 4.1.3 Optimization While FRAPPE uses an expectation-maximization (EM) algorithm [10], the authors of ADMIXTURE claim that this method is slow, and also yields inaccurate solutions if not left to run until convergence, which can take hours of computation for a mediumsized dataset [3]. Instead, ADMIXTURE uses a block relaxation approach to minimize the negative log-likelihood, while exploiting the fact that the negative log-likelihood is convex on a set of parameters if fixing the others. 4.1.3.1 Block relaxation Block relaxation algorithms are fixed point methods which are used to optimize a given multivariate function fiteratively. Assuming fis defined on χ1×χ2× · · · × χp, the general method is described in Algorithm 1. Algorithm 1: Block relaxation Result: Minimizer x∈χ Input : Function f, tolerance  x(0) = some x∈χ k=0 while ||x(k)−x(k−1)|| >  do x(k+1) 1= argmin x1∈χ1 f(x1, x(k) 2, . . . , x(k) p) x(k+1) 2= argmin x2∈χ2 f(x(k+1) 1, x2, . . . , x(k) p) . . . x(k+1) p= argmin xp∈χp f(x(k+1) 1, x(k+1) 2, . . . , xp) k = k+1 end Return: x(k) In the case of ADMIXTURE, Qand Fare optimized iteratively. Q(0) and F(0) are computed by running 5 iterations of FRAPPE’s EM by default, in order to accelerate convergence. Moreover, a quasi-Newton method [40] is also used to accelerate convergence. 4.1.3.2 Sequential quadratic programming The block updates for ADMIXTURE are performed using a sequential quadratic programming (SQP) approach. In SQP, one computes the dkminimizing the following quadratic approximation: Unsupervised Clustering for Ancestry Inference with Neural Networks 16 f(x)≈f(x(k)) + ∇f(x(k))Tdk+dT k∇2f(x(k))dk(5) where ∇fdenotes the gradient of fand ∇2fis the Hessian matrix. The x(k)are then updated as x(k+1) =x(k)+dk[27]. This method is equivalent to Newton’s method when the problem is unconstrained. In [3], it is shown that the computations involving both the gradient and the Hessian matrix can be simplified, especially in the latter case, causing a fair relative speedup to other methods. Furthermore, the software allows a multi-threaded mode [2], which greatly boosts execution time. However, the software still struggles with large datasets, both in terms of number of SNPs and number of samples. 4.1.4 Supervised mode While ADMIXTURE is formulated as an unsupervised problem, it is possible to know some information about the ancestries of the samples in the training data. In the supervised mode, the known rows of the Qmatrix are set according to the population and are not updated during training. This will aid the learning of the Fmatrix, as well as the unknown rows of Q, and make convergence much easier to achieve. 4.1.5 Projective analysis Commonly, one will want to compute the ancestry fractions (qik)for out-of-training data samples using a previously computed solution, especially for small datasets or if the population structure learnt by ADMIXTURE is believed to be robust. The software allows this in the projective analysis mode. In this mode, the Fmatrix corresponding to an already computed solution is fixed, and LC(Q)is minimized to compute the estimations per sample. Although convergence happens much faster in this mode, as the negative log-likelihood is convex on Q, the optimization process could be avoided by, for example, learning a function fθwhich, given the input sequence, is able to estimate the ancestry assignments. 4.2 Autoencoders An autoencoder is a neural network architecture commonly used to unsupervisedly learn low-dimensional representations of data. It consists of an encoder module, that can be composed of several feed-forward layers, which computes the bottleneck (code). The code is then fed through the decoder module, which tries to reconstruct the original input sequence from the bottleneck. A general autoencoder architecture is depicted in Figure 2 (extracted from [11]). Unsupervised Clustering for Ancestry Inference with Neural Networks 17 Figure 2: Autoencoder architecture. [11] To train an autoencoder, the training data is fed to the network and the loss is computed between the original input and the reconstruction, so no ground truth labels are needed, making this architecture self-supervised, often considered a subset of unsupervised learning. We should remark that while most autoencoders are symmetric, that is, they have the same number of layers and parameters in the decoder and the encoder, this is not a requirement and, in fact, our proposal consists of an asymmetric autoencoder architecture. While autoencoders were conceived as non-linear dimensionality reduction techniques [14], variations of the vanilla autoencoder architecture have found success in several disciplines. Some applications of autoencoders include compression and transmission, where data is encoded and fed through a channel, to be then reconstructed by the receiver using the decoder; machine translation, where the bottleneck is a meaningful representation of text sequences [8], or image denoising [7]. Unsupervised Clustering for Ancestry Inference with Neural Networks 18 5 Neural ADMIXTURE The main contribution of this thesis is proposing an alternative formulation of ADMIXTURE based on neural networks. ADMIXTURE can be formulated as a non-negative matrix factorization problem. Let Xdenote the training samples, where the features are the alternate allele counts per SNP. Then, X≈QF , where Qare the ancestry assignments (or cluster assignments), Fare the alternate variant frequencies per SNP and population, and the negative loglikelihood in Equation 4 is the distance metric between Xand QF . This can be naturally translated into the neural network world as a vanilla autoencoder. Let Q=fθ(X)represent the bottleneck, which is computed as a function of the input. To then reconstruct the input, we multiply the bottleneck by the decoder weights matrix, which will take the role of F. The fact that Qis estimated at every forward pass and not learnt per se for the training data means that, at inference time for out-of-training data samples, we will not have to run the optimization process again, as in ADMIXTURE’s projective analysis, but instead perform a simple forward pass consisting on a few multiplications. Moreover, as the network can be trained using stochastic gradient descent or any of its variants. Taking into account the speed boost not only of these techniques, but also of a GPU-friendly architecture and computations, the network could potentially be trained some orders of magnitude faster than regular ADMIXTURE. 5.1 Network architecture The constraints in the optimization problem (Equation 4) impose restrictions in the architecture. Those relating to Q(Pkqik = 1 and qik ≥0) can be enforced by applying a softmax activation at the encoder output, making the bottleneck equivalent to the population estimates. Furthermore, while the decoder restriction (0≤fkj ≤1) could also be enforced in the architecture itself (e.g. applying the sigmoid function to the decoder weights), we have found that it suffices to simply project the weights of the decoder to the interval [0,1] after every optimization step, which is one of the most common forms of projected gradient descent [21]. Figure 3 (extracted from [20]) depicts an iteration of the algorithm. Unsupervised Clustering for Ancestry Inference with Neural Networks 19 Figure 3: Projected gradient descent iteration. [20] χdenotes the feasible set. We note that, critically, the decoder must be linear and cannot be followed by a nonlinearity, as it would break the interpretability of the Fmatrix and the equivalence between the decoder weights and the cluster centroids (frequencies per SNP and per cluster) would be lost. On the other hand, the encoder architecture is free from constraints, and it may be composed of several neural layers with its corresponding non-linearities, if deemed appropriate. As a matter of fact, the proposed Neural ADMIXTURE includes a 512-dimensional nonlinear intermediate layer with a ReLU activation before the bottleneck, as well as a batch normalization layer that acts directly on the input. The architecture is depicted in Figure 4. Figure 4: Neural ADMIXTURE architecture. The batch-normalized input sequence is projected into 512 dimensions and processed by a ReLU non-linearity. The bottleneck, which is an estimation of Q, is computed by feeding the 512-dimensional sequence to a K-neuron layer activated with a Softmax. Finally, the decoder reconstructs the input using a linear layer with weights F. Note that the decoder is restricted to have this architecture to ensure interpretability. In fact, the ADMIXTURE model does not exactly reconstruct the input data as a regular autoencoder would do, as the input SNP count sequences, nij ∈ {0,1,2}, and the Unsupervised Clustering for Ancestry Inference with Neural Networks 20 reconstructions pij ∈[0,1], do not have matching ranges. This can easily be achieved by dividing the allele counts by 2, so that now the input data are n0 ij =nij 2∈ {0,0.5,1}. Therefore, Neural ADMIXTURE’s input is the same as ADMIXTURE’s but multiplied by a factor of 1 2. Moreover, instead of minimizing the same function as ADMIXTURE, LC(Equation 4), we propose that the binary cross-entropy is minimized instead, with a penalty term to the Frobenius norm of the first non-linear layer weights, W1: LN(Q, F) = −X i,j n0 ij log  X k qikfkj + (1 −n0 ij) log  1−X k qikfkj +λ||W1||2 F,(6) where the Frobenius norm for real matrices is defined as ||A||F=pTr(AAT)[13], and it is equivalent to computing the sum of the squared norms of the column vectors of A. The regularization term avoids hard assignments in the bottleneck, which helps during the training process and reduces overfitting. In Equation 7 we show that the proposed optimization problem and the ADMIXTURE one are equivalent (excluding the regularization term), by using n0 ij =nij 2, as well as Equations 4 and 6 with λ= 0: Lλ=0 N(Q, F) = −X i,j n0 ij log(pij) + (1 −n0 ij) log(1 −pij) =−X i,j nij 2log(pij) + 1−nij 2log(1 −pij) = =−1 2X i,j nij log(pij) + (2 −nij) log(1 −pij) = =1 2LC(Q, F) (7) where pij =Pkqikfkj. As the proposed loss, Lλ=0 n, is simply a multiple of ADMIXTURE’s loss, LC, the minimizers of the two functions are equivalent, and thus the optimizations problems are also equivalent. Note that a perfect reconstruction can be obtained by setting the number of clusters (ancestries) equal to the number of training samples or to the input dimensions. However, we are interested in the bottleneck capturing elementary information of the population structure of the given sequences, therefore we make use of low-dimensional bottlenecks. 5.2 Decoder initialization Due to the restriction that non-linearities cannot be used in the decoder as well as the fairly large number of parameters for a single layer, the decoder weights (and thus, the Unsupervised Clustering for Ancestry Inference with Neural Networks 21 overall performance of the model) are quite sensitive to the initialization. Common initializations, such as Xavier [12], do not work successfully in this architecture. However, the fact that the decoder is interpretable can be exploited in our favour, as we can try to insert information about the population structure in an unsupervised manner. As the entries of (fkj )are, theoretically, the frequencies of the alternate variant of SNP j and population k,fkshould coincide with the centroid of the samples in population k. This suggests that clustering can be performed and can be used to initialize the decoder weights. In the high dimensional space that we work (typically 104-106markers will be used), even fast clustering algorithms such as K-Means would yield high execution times. Instead of clustering in the original feature space, we propose to project the data using Principal Components Analysis (PCA) onto a few (2 to 6) principal components and then perform K-Means. PCA is widely used in genomic analyses, as a small number of principal components often explain most of the structure of the sequences [28, 31, 33] such as ancestry, which is what we are interested in. Hence, to initialize the decoder weights, we propose Algorithm 2: Algorithm 2: PCK-Means Initialization Result: Initialization weights W0 Input : Training data X, Number of populations K Compute first two principal components on X XP= projection of Xonto first two principal components C = partition of XPgiven by K-Means for every cluster Cido Wi= centroid of cluter Ci end Return: Inverse PCA transform of W 5.3 Multi-head architecture In ADMIXTURE, cross-validation must be performed in order to choose the number of population clusters (K), unless specific prior information about the population distribution is known. Furthermore, in many applications, practitioners desire to observe how cluster assignments change as the number of clusters increases. With the number of both sequenced individuals and variants increasing, the feasible number of different trials of cross-validation rapidly decreases due to its computational cost. As a solution, we propose a variation to Neural ADMIXTURE: the Multi-head Neural ADMIXTURE (MNA), which takes advantage of the 512-dimensional latent representation (from now on, shared bottleneck) computed by the encoder. In MNA, the shared bottleneck is jointly learnt for different values of K,{K1. . . KH}. Figure 5 shows how the shared bottleneck of the multi-head structure is split into H different heads. The i-th head consists of a non-linear projection to a Ki-dimensional Unsupervised Clustering for Ancestry Inference with Neural Networks 22 vector, which corresponds to an assignment assuming there are Kidifferent populations in the data. While every head could be combined and fed through a decoder, this would cause the decoder weights Fnot to be interpretable. Therefore, every head needs to have its own decoder and, thus, Hdifferent reconstructions of the input are performed in every forward pass during training. Figure 5: Multi-head Neural ADMIXTURE architecture (H= 3). As we have Hreconstructions, we will now have Hdifferent loss values. We can train this architecture by minimizing LMNA(Q0, F 0) = H X h=1 LN(Q0 h, F0 h),(8) where Q0 hand F0 hare, respectively, the cluster assignments and the SNP frequencies per population for the h-th head. The restrictions of the ADMIXTURE optimization problem (Equation 4) must be satisfied by Q0 hand F0 h∀h∈ {1, . . . , H}. The multi-head architecture allows computation of Hdifferent cluster assignments, for different values of K, efficiently in a single forward pass. Results can then be both quantitatively and qualitatively analysed in order to decide which value of Kis the most suitable for the data, and studying the different assignments as the value of K increases/decreases can give useful insights on the population structure, as we will discuss in Section 6.4 when analyzing some results of this architecture. 5.4 Supervised training ADMIXTURE allows for supervised training by fixing some (or all) entries in the Q matrix. The same approach cannot be applied to the neural network architecture be- Unsupervised Clustering for Ancestry Inference with Neural Networks 23 cause the assignments (Q) are not learnt parameters (like F) but are estimated by the encoder (Q=fθ(x)) at every forward pass. As a solution, we propose to add a classification loss to the bottleneck entries. Let Y= (yik)denote the ground truth ancestries LCE(Q, Y )denote the cross-entropy loss. Recall that the cross-entropy loss is an error function widely used for classification problems, and (with our parameters) it is defined as: LCE(Q, Y ) = − N X i=1 K X k=1 yik log(qik)(9) In the supervised version, the optimization problem (assuming the single-head architecture is used) is formulated as min Q,F µLN(Q, F) + ηLCE(Q, Y ) s. to 0≤fkj ≤1 X k qik = 1 qik ≥0. (10) Note that unsupervised Neural ADMIXTURE can be seen as a particular case by setting η= 0. Furthermore, having both losses allows for semi-supervised training where only part of the training samples have ground truth labels. In the supervised learning setting, instead of initializing the decoder weights using PCK-Means (Algorithm 2), we can exploit the fact that we know to which population each sample belongs: the decoder weights can simply be initialized as the centroid of each ground truth population, a straightforward computation. Moreover, this initialization will avoid permutation issues (i.e. cluster "i" found by PCK-Means may not correspond to population encoded as "i") which would make convergence slower, or even have a negative impact on performance. 5.5 Pretrained Neural ADMIXTURE As a last contribution, we propose a training scheme which allows reusing the results of a previously optimized ADMIXTURE to speedup inference on a new dataset. This is especially useful when many ADMIXTURE runs have already been computed, so that retraining, which is computationally expensive with large datasets, can be avoided. Let FAdenote the Fmatrix estimated by ADMIXTURE. This matrix can be used in Neural ADMIXTURE so the Qestimates will be similar to those given by ADMIXTURE. This can be trained similarly to a pre-train & fine-tune architecture (transfer learning) [39]: Unsupervised Clustering for Ancestry Inference with Neural Networks 30 We remark that, as the two algorithm executions are independent and initialized differently, cluster iof ADMIXTURE does not have to correspond to cluster iof Neural ADMIXTURE. In order to make differences more easily spottable, the cluster labels themselves have been permuted in every model to try to match as much as possible with the other one. For example, cluster "0", which is mainly the West Asian ancestry in Neural ADMIXTURE, was originally labelled as cluster "4" in ADMIXTURE. So, cluster "4" has been permuted to be "0" in ADMIXTURE so that West Asia is also the majority ancestry of that cluster. The SNP frequencies (that is, the entries in the Fmatrix) from both models can be observed (projected onto the first two principal components of the training data) in Figure 7b. The colours of the square and triangle markers match with the colours of the ancestries of the barplot (Figure 7a). As expected, the projected entries of the F matrices appear to be the weighted centroids of the samples assigned to every cluster in both ADMIXTURE and Neural ADMIXTURE. Qualitatively, Neural ADMIXTURE estimates tend to be more polarized, with many samples being assigned only to a single population, while ADMIXTURE appears to be more conservative. Moreover, ADMIXTURE does not split Native Americans (AMR) and East Asians (EAS), and instead partitions Africans (AFR) into two different populations. Neural ADMIXTURE is able to split EAS and AMR populations. This can be seen in both the Q estimates (Figure 7a) and in the projected entries of the Fmatrices (Figure 7b). More qualitative examples for the other datasets are shown in Appendix A. Unsupervised Clustering for Ancestry Inference with Neural Networks 31 (a) Visualization of Qestimates. (b) Projected training data along with the Fmatrix. Figure 7: Results from both ADMIXTURE and Neural ADMIXTURE trained on Chm-22-SIM. Such qualitative results are on par with the AMI and ∆values in both train and validation (Table 2), and supervised and unsupervised, indicating that the Neural ADMIXTURE provide estimates which are closer to the ground truth labels as compared to classic ADMIXTURE. Moreover, ADMIXTURE’s and Neural ADMIXTURE’s loss values are very similar, and the difference is probably induced by the regularization term in Neural ADMIXTURE’s loss during training. Having seen the performance metrics and the relative speedup, we can conclude that, indeed, Neural ADMIXTURE achieves competitive results with greatly reduced training time, even on CPU, while a massive speedup is achieved to perform inference on out-of-training data, that is, to assign ancestry fractions for new data. 6.4 Multi-head results The main advantage of the Multi-head Neural ADMIXTURE (MNA) architecture is that it can perform simultaneous clustering and inference for multiple values of K (assumed number of different ancestries). Running different values for Kallows researchers to obtain a more complete picture of the variation within populations. Figure 8 and 9 shows examples of the output of MNA for different clustering results under values of K ranging from 3 to 10. In Figure 8a (K=3) we can observe that EUR, WAS and SAS are combined within the Unsupervised Clustering for Ancestry Inference with Neural Networks 32 same cluster, while OCE and EAS are clustered together, and AFR has its own cluster. These results reflect the genetic similarity between the respective groups due to their Out-of-Africa migration patterns. After adding a new cluster (Figure 8b) OCE obtains its own cluster, reflecting the ancient divergence of that population from the others. As more clusters are incorporated, AMR and EAS obtain their own clusters and OCE is divided between a component found predominantly in OCE and a component characteristic of EAS. The latter reflects later migration of Austronesian speakers from East Asia out into the Pacific Islands, where they contributed some of their ancestral genetic component. A shared component between EUR, SAS and WAS is maintained, independent of the cluster number K, which can be linked to early farmer expansions out of West Asia and into both Europe and South Asia following the birth of agriculture, as well as the much later expansion of the Indo-European language family across all of these regions. With a sufficiently high number of clusters (Figure 9d) a shared component between AFR and WAS appears, which might reflect the genetic similarity between North African populations and West Asian populations. Unsupervised Clustering for Ancestry Inference with Neural Networks 33 (a) K= 3. (b) K= 4. (c) K= 5. (d) K= 6. Figure 8: Validation results from Multi-head Neural ADMIXTURE trained on Chm-22-SIM (Kfrom 3 to 6). Unsupervised Clustering for Ancestry Inference with Neural Networks 34 (a) K= 7. (b) K= 8. (c) K= 9. (d) K= 10. Figure 9: Validation results from Multi-head Neural ADMIXTURE trained on Chm-22-SIM (Kfrom 7 to 10). Unsupervised Clustering for Ancestry Inference with Neural Networks 35 (a) K∈ {3,4,5,6}. (b) K∈ {7,8,9,10}. Figure 10: Projected training data along with the decoders of Multi-head Neural ADMIXTURE trained on Chm-22-SIM (Kfrom 3 to 10). Unsupervised Clustering for Ancestry Inference with Neural Networks 36 7 Conclusions In this project, we have studied and discussed the ADMIXTURE algorithm, and also designed and implemented Neural ADMIXTURE, a neural network version of the former. In the experiments, we have seen the training of Neural ADMIXTURE is a couple of orders of magnitude faster using GPUs, and an order or magnitude faster using CPU, compared to its classical counterpart. Moreover, unsupervised Neural ADMIXTURE achieves competitive results, compared to ADMIXTURE, in three different datasets. While in the supervised case the neural network version is a little bit slower, the quantitative metrics achieved by the network are still very competitive. Moreover, Neural ADMIXTURE is consistently more than a hundred times faster than ADMIXTURE when performing ancestry inference on unseen data, both on GPU and CPU. Moreover, with the pretrained version Neural ADMIXTURE, which uses a previously computed Fmatrix from ADMIXTURE as initialization, the results on unseen data are similar to the ones provided by ADMIXTURE, but are obtained with much less computation time. Finally, we have introduced and discussed Multi-head Neural ADMIXTURE, which allows computing ancestry assignments for different values of Kon a single forwardpass. In the experiments section, we have seen that results from the multi-head version of the network can be very useful to have additional insights on the evolution of the population that is to be studied. Having said this, we believe that, overall, Neural ADMIXTURE is a good alternative to ADMIXTURE, as cluster assignments are on par with ADMIXTURE’s in terms of quality, while much less computation resources are needed and interpretability is maintained. Moreover, with Multi-head Neural ADMIXTURE, researchers may not only be able to choose the best value of K(number of populations) without the need of running a cross-validation procedure, but by studying and analyzing the outputs of the network they might get more information than they would get running the algorithm for just one value of K. The code has been made public for researchers to use at their will, and can be found at https://github.com/AI-sandbox/neural-admixture. Unsupervised Clustering for Ancestry Inference with Neural Networks 37 8 Future work On this project we have focused on maintaining ADMIXTURE’s interpretability, which is core in many related studies. However, one of the most immediate steps will be to study the impact of removing the restrictions related to F(the decoder weights). That is, swapping the single-layer linear decoder for a deep non-linear one. This obviously makes the decoder weights no longer the frequencies of the SNPs per population, but may yield better population assignments overall, which may be desired in some specific applications. While we have already started working on this, results are still preliminary and no conclusions have been drawn yet. Moreover, we have been discussing a global ancestry inference technique throughout the report, but the method may be extended to act as a local ancestry inference technique, by feeding overlapping windows of SNPs instead of the whole sequence. Converting Neural ADMIXTURE into a local ancestry inference technique will be challenging, due to having to deal with variable window sizes and making the population labels constant throughout the different bottlenecks computed per window. Furthermore, running Neural ADMIXTURE on admixed individuals and comparing the results should be the next experiment to be performed, to ensure the network also has the capacity to correctly detect these admixed individuals. We believe this should be the case, as in the experiments we have seen that some individuals whose origin lay between different classically defined ancestries have been properly depicted by the network. Finally, several versions of the network may be trained separately on individuals assigned to every cluster. That is, assuming cluster iis linked to the European ancestry, one could train a Neural ADMIXTURE network using the individuals assigned as cluster i, so that the assignment can be "refined". In other words, we would expect these new assignments to be linked to different populations in Europe. We would like to integrate this scheme in one end-to-end pipeline, and the final results would look similar to the results produced by a hierarchical clustering algorithm. Unsupervised Clustering for Ancestry Inference with Neural Networks 38 Bibliography [1] 1000 Genomes Project Consortium. A global reference for human genetic variation. Nature, 526(7571):68, 2015. [2] David H Alexander and Kenneth Lange. Enhancements to the admixture algorithm for individual ancestry estimation. BMC bioinformatics, 12:246, 2011. doi: 10.1186/1471-2105-12-246. [3] David H Alexander, John Novembre, and Kenneth Lange. Fast model-based estimation of ancestry in unrelated individuals. Genome research, 19(9):1655–64, Sep 2009. doi: 10.1101/gr.094052.109. [4] Kristiina Ausmees and Carl Nettelblad. A deep learning framework for characterization of genotype data. bioRxiv, 2020. [5] Christopher J Battey, Peter L Ralph, and Andrew D Kern. Predicting geographic location from genetic variation with deep neural networks. ELife, 9:e54507, 2020. [6] Anders Bergström, Shane A McCarthy, Ruoyun Hui, Mohamed A Almarri, Qasim Ayub, Petr Danecek, Yuan Chen, Sabine Felkel, Pille Hallast, Jack Kamm, et al. Insights into human genetic variation and population history from 929 diverse genomes. Science, 367(6484), 2020. [7] A Buades, B Coll, and JM Morel. A review of image denoising algorithms, with a new one. Multiscale Modeling & Simulation, 4(2):490–530, 2005. [8] KyungHyun Cho, Bart van Merrienboer, Dzmitry Bahdanau, and Yoshua Bengio. On the properties of neural machine translation: Encoder-decoder approaches. CoRR, abs/1409.1259, 2014. URL http://arxiv.org/abs/1409.1259. [9] S.K. Cordovado, M. Hendrix, C.N. Greene, S. Mochal, M.C. Earley, P.M. Farrell, M. Kharrazi, W.H. Hannon, and P.W. Mueller. Cftr mutation analysis and haplotype associations in cf patients. Molecular Genetics and Metabolism, 105(2):249–254, 2012. ISSN 1096-7192. doi: https://doi.org/10.1016/j.ymgme.2011.10.013. URL https://www.sciencedirect.com/science/article/pii/S1096719211003829. [10] A.P. Dempster, N.M. Laird, and D.B. Rubin. Maximum likelihood from incomplete data via the em algorithm. Journal of the Royal Statistical Society (B), 39:1–38, 1977. [11] Arden Dertat. Applied deep learning - part 3: Autoencoders, 2017. URL https://towardsdatascience.com/ applied-deep-learning-part-3-autoencoders-1c083af4d798. [Online; Accessed June 2021]. [12] X. Glorot and Y. Bengio. Understanding the difficulty of training deep feedforward neural networks. In Proceedings of the International Conference on Artificial Intelligence and Statistics (AISTATS’10). Society for Artificial Intelligence and Statistics, 2010. [13] Gene H. Golub and Charles F. Van Loan. Matrix Computations. The Johns Hopkins University Press, third edition, 1996. Unsupervised Clustering for Ancestry Inference with Neural Networks 39 [14] Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016. http://www.deeplearningbook.org. [15] Weonyoung Joo, Wonsung Lee, Sungrae Park, and Il-Chul Moon. Dirichlet variational autoencoder. Pattern Recognition, 107:107514, 2020. [16] Sebastian Mathias Keller, Maxim Samarin, Fabricio Arend Torres, Mario Wieser, and Volker Roth. Learning extremal representations with deep archetypal analysis. International Journal of Computer Vision, 129(4):805–820, 2021. [17] Debbie Kennett. Single-nucleotide polymorphisms, 2010. URL https://isogg. org/wiki/File:SNP_diagram.png. [Online; Accessed June 2021]. [18] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun, editors, 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.org/abs/1412.6980. [19] Arvind Kumar, Daniel Mas Montserrat, Carlos Bustamante, and Alexander Ioannidis. Xgmix: Local-ancestry inference with stacked xgboost. bioRxiv, 2020. [20] J. Langr and V. Bok. GANs in Action: Deep learning with Generative Adversarial Networks. Manning Publications, 2019. ISBN 9781617295560. URL https: //books.google.es/books?id=HojvugEACAAJ. [21] Chih-Jen Lin. Projected gradient methods for nonnegative matrix factorization. Neural Computation, 19:2756–2779, oct 2007. ISSN 0899-7667, 1530-888X. doi: 10. 1162/neco.2007.19.10.2756. [22] Swapan Mallick, Heng Li, Mark Lipson, Iain Mathieson, Melissa Gymrek, Fernando Racimo, Mengyao Zhao, Niru Chennagiri, Susanne Nordenfelt, Arti Tandon, et al. The simons genome diversity project: 300 genomes from 142 diverse populations. Nature, 538(7624):201–206, 2016. [23] Alicia R Martin, Masahiro Kanai, Yoichiro Kamatani, Yukinori Okada, Benjamin M Neale, and Mark J Daly. Clinical use of current polygenic risk scores may exacerbate health disparities. Nature genetics, 51(4):584–591, 2019. [24] Daniel Mas Montserrat, Carlos Bustamante, and Alexander Ioannidis. Lai-net: Local-ancestry inference with neural networks. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 1314–1318. IEEE, 2020. [25] Joannella Morales, Danielle Welter, Emily H Bowler, Maria Cerezo, Laura W Harris, Aoife C McMahon, Peggy Hall, Heather A Junkins, Annalisa Milano, Emma Hastings, et al. A standardized framework for representation of ancestry data in genomics studies, with application to the nhgri-ebi gwas catalog. Genome biology, 19(1):1–10, 2018. [26] Rasmus Nielsen, Joshua M Akey, Mattias Jakobsson, Jonathan K Pritchard, Sarah Tishkoff, and Eske Willerslev. Tracing the peopling of the world through genomics. Nature, 541(7637):302–310, 2017.