Performance of subflattening matrices for phylogenetic tree reconstruction
Abstract
En aquest projecte s'estudia a fons la definició de matrius "subflattening", i es proporcionen detalls addicionals que faltaven a la demostració del Teorema d'en Jeremy G. Sumner. Concretament, s'estudia en detall el cas del model de Kimura de 3 paràmetres. A més a més, s'implementa un mètode de reconstrucció filogenètica basat en aquestes matrius "subflattening" i es contrasta el seu rendiment amb altres mètodes basats en àlgebra lineal numèrica.
Full text
Title: Performance of subflattening matrices for phylogenetic tree reconstruction Author: Aïda Cunill i Carreras Advisor: Marta Casanellas Rius and Jesús Fernández Sánchez Department: Mathematics Academic Year: 2022-2023 Degree in Mathematics
Universitat Polit`ecnica de Catalunya Facultat de Matem` atiques i Estad´ ıstica Performance of subflattening matrices for phylogenetic tree reconstruction Author: A¨ıda Cunill i Carreras Advisors: Marta Casanellas Rius and Jes´us Fern´andez S´anchez June, 2023
Acknowledgments I would like to express my deepest gratitude to my advisors Marta Casanellas and Jes´us Fern´andez. Their guidance, expertise, constructive feedback, and encouragement have been instrumental in shaping this work. I would also like to extend my appreciation to the FME faculty members and teachers for their dedication to education and for providing me with a solid academic foundation. And finally, I am profoundly grateful to my family and friends for their unwavering support and their constant encouragement although not fully understand the purpose of my work. Their belief in my abilities, especially during times when I lacked confidence in myself, and words of motivation have provided me with the strength and determination to overcome challenges and complete this final project.
Abstract In this project we have deeply study the definition of subflattening matrices, introduced in [20], and provide additional details that were missing in the proof of Theorem 2.22. We study with full detail the case of the Kimura 3-parameter model. Moreover, we implement a method based on this subflattening matrices and contrast its performance with other methods based on numerical linear algebra. Keywords Evolutionary model, phylogenetic tree, phylogenetic inference, Kimura 3-parameter and flattening.
Contents Introduction 2 1 Preliminaries 4 1.1 PhylogeneticTrees ................................ 4 1.2 Alignments of DNA Sequences . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3 Probabilistic substitution models . . . . . . . . . . . . . . . . . . . . . . . . 6 1.4 Phylogenetic Invariants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.5 The Kimura 3-parameter model . . . . . . . . . . . . . . . . . . . . . . . . . 10 2 Flattenings and subflattenings 12 2.1 Flatteningmatrices................................ 12 2.2 Subflatteningmatrices.............................. 16 3 The Kimura 3-parameter model 28 3.1 Subflattenings of the K81 model . . . . . . . . . . . . . . . . . . . . . . . . 29 3.2 Marginalization of distributions . . . . . . . . . . . . . . . . . . . . . . . . . 32 4 Phylogenetic reconstruction methods 35 4.1 Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.2 Reconstruction based on the Subflattening matrices . . . . . . . . . . . . . 36 4.3 ThemethodErik+2 ............................... 36 4.4 Fouriernormalization .............................. 37 5 Results on simulated data 39 5.1 Performance on representative trees . . . . . . . . . . . . . . . . . . . . . . 39 5.2 Performance on trees with random branches . . . . . . . . . . . . . . . . . . 44 6 Discussion and conclusions 46 Bibliography 49 Appendix 50 1
Introduction Evolution has long been a popular topic for contemplation. The idea that one organism could descend from another dates back to some of the first pre-Socratic Greek philosophers. Over time, these proposals have evolved until Charles Darwin formalized the theory of evolution through natural selection in his 1859 book, On the Origin of Species [9]. But how does biology intersect with mathematics in the study of evolution? In this project, we explore multilinear algebra and phylogenetics as the meeting point between the biological world and mathematical structures and tools. Since the contributions of Hitchcock and Darwin, the evolution of species is usually represented by some tree graphs (called phylogenetic trees, see Figure 1). These trees are widely used tools to visualize and establish phylogenies between species. The leaves of the tree represent living organisms, the interior nodes represent their common ancestors, and the branches represent evolutionary processes. Figure 1: Phylogenetic tree on the set of species Homo Sapiens, Pan Troglodytes, Gorilla Gorilla and Macaca Mulatta. Today, the study of the evolutionary history of a group of species is carried out using molecular data, including deoxyribonucleic acid (DNA), amino acid sequences, codons, and proteins associated with the living species. Phylogenetics aims to generate the most plausible phylogenetic tree representing the evolution of several present-day species, given a collection of DNA sequences associated with their respective organisms. There are several algorithms to reconstruct phylogenetic trees, but the challenge lies in creating more complex models to fit the vast amount of available data and to solve the impossibility of exploring the space of phylogenetic trees exhaustively. One usual approach involves modeling 2
Definition 1.12. Given transition matrices Mealong the edges E(T), let φTbe the polynomial map that sends each set of parameters to the joint distribution (px1,...,xL)x1,...,xLof nucleotides at the leaves: φT:Rd−→ R4L θ= (πr,(Me)e∈E(T))7−→ P= (pAA...AA, pAA...AC, ..., pT T...T T ) Example 1.13. For instance, the Kimura 3-parameters model on the tree topology T12|34 corresponds to the following polynomial map: φT:R15 −→ R256 θ= (b1, ..., b5, c1, ..., c5, d1, ..., d5)7−→ P= (pAAAA, pAAAC , ..., pT T T T ) since we have 3 free parameters (bi, ci, di) per each transition matrix. Although parameters represent probabilities and therefore lie in the interval [0,1], algebraic geometry tools often require polynomial maps defined over Cdto define the map in a more general setting. The set ImφTcontains all joint distributions of nucleotides at the leaves that have been generated from some collection of parameters in the model Mand the tree topology T. However, ImφTdoes not usually form an algebraic variety by itself, so we consider its Zariski closure VT=Im(φT), that is the smallest algebraic variety containing ImφT. The set of polynomials I(Im(φT)) that vanish on all the point of Im(φT) forms an ideal. If g∈I(ImφT), gis a polynomial such that if P∈ImφT, then g(P) = 0. Because of this, ggives a relation between the joint probabilities px1,...,xL, regardless of the parameters of the model that produced them. Therefore, gcan be seen as an invariant. Invariants were introduced by Lake and Cavender and Felsenstein in their parallel work in 1987 , see [17] and [6]. Given a tree topology Ton Lleaves and an evolutionary model M, the polynomials in I(ImφT) are usually called invariants of those. We are interested in invariants that characterize a tree topology, but not in those that are invariants to all tree topologies, as these do not provide any information about the tree topology and are a consequence of the chosen evolutionary model. Atopology invariant of Tis a polynomial in I(ImφT) that does not belong to I(ImφT′) for any other tree topology T′on Lleaves. The set of phylogenetic invariants is different for each tree topology, making them a useful tool to recover the tree topology from an alignment on Lspecies. Recall from section 1.2 that our input data are DNA sequences of length Ngiven in the form of an alignment. An alignment can be seen as Nindependent samples of a multinomial distribution P= (pAA...A, ..., pT T...T ). This distribution can be estimated by the relative frequencies f= (fAA...A, ..., fT T...T ) of each column in the alignment, where fapproximates Pas Ntends to infinity. Therefore, if the DNA sequences have evolved through a Markov process on the tree T, then P∈ImφTand fwould be close to VT. Using phylogenetic invariants, g(P) = 0 and g(f) would be close to zero. But how can we find phylogenetic invariants? Providing a set of generators of the ideal I(ImφT) has become a challenge for the phylogenetics community. In theory, one should be able to calculate the phylogenetic invariants as generators of the ideal using computational algebra software. However, computational algebra requires a significant amount of memory capacity, and it is still infeasible with current technology. A common alternative approach for obtaining phylogenetic invariants is to study flattenings. 9
1.5 The Kimura 3-parameter model The Kimura 3-parameter model, also known as K81, is a substitution model that is of interest to both biologists and mathematicians due to its various symmetries in transition matrices. It was introduced in [16].These symmetries are based on the chemical properties of nucleotides, which can be classified into two broad groups: purines and pyrimidines. Definition 1.14. Apurine is an organic compound that is heterocyclic and aromatic, consisting of an imidazole ring fused to a pyrimidine ring.. Its nucleobases are adenine and guanine (A, G). On the other hand, a pyrimidine is also an organic compound that is heterocyclic and aromatic, similar in structure to benzene and pyridine, and containing two nitrogen atoms at positions 1 and 3 of the six-membered ring. It is isomeric with two other forms of diazine. Its nucleobases are cytosine and thymine (C, T). Due to these differences, mutations can be distinguished as those from purines to pyrimidines (or vice versa) and those within the same nucleotide group. The former are called transversions, while the latter are called transitions, see Figure 1.3. Transitions are more common than transversions since they involve a change from one nucleotide to another within the same group, preserving the basic ring structure of the nucleotide. When modeling these mutations, a parameter acan be included to represent the probability that nucleotides remain the same, a parameter dfor the probabilities of transitions, and a parameter for each type of transversion, cfor A↔T, G ↔C, and bfor A↔Cor G↔T. This is the Kimura 3-parameter model (briefly denoted as K81) introduced in Section 1.3, where: πr={1 4,1 4,1 4,1 4} M=Üa b c d b a d c c d a b d c b aê. Figure 1.3: Parameters of nucleotide substitution in K81. One useful property of this model is that all K81 transition matrices Mcan be diagonalized in a specific basis. 10
Proposition 1.15 ([4]).Any Kimura 3-parameter transition matrix can be diagonalized in the same basis, which consists of the four vectors A′= (1,1,1,1)t, C′= (1,1,−1,−1)t, G′= (1,−1,1,−1)t, T′= (1,−1,−1,1)t.The corresponding eigenvalues are mA=a+b+c+d= 1, mC=a+b−c−d, mG= a−b+c−d, mT=a−b−c+d. We will call this basis Σ′={A′, C′, G′, T′}following the approach of [19]. Proof. Let us prove that A′is an eigenvector with eigenvalue mA: Üa b c d b a d c c d a b d c b aê·Ü1 1 1 1ê=Üa+b+c+d a+b+c+d a+b+c+d a+b+c+dê= (a+b+c+d)·Ü1 1 1 1ê= 1 ·Ü1 1 1 1ê Similarly, one can check the other eigenvectors. 11
Chapter 2 Flattenings and subflattenings The aim of this chapter is to construct mathematical elements that allow us to determine the correct tree, given a vector of join probabilities P. 2.1 Flattening matrices Definition 2.1. Let A|Bbe a bipartition of the leaf set Sof the phylogenetic tree T, where |S| =L=m+n. Suppose A={1,2, ..., m}and B={m+ 1, m + 2, ..., m +n}. The flattening FlatA|B(P) of the distribution vector P= (px1...xn)x1,...,xnis the 4m×4nmatrix with rows indexed by the strings x1, ..., xm, columns indexed by the strings xm+1, ..., xm+n, and entries px1...xmxm+1...xm+n. For a general bipartition A={s1, ..., sm}, B ={t1, ..., tn}of the leaf set S,the same definition holds reordering the indices as necessary. Example 2.2. For a 4-leaf tree, Flat12|34(P) and Flat13|24(P) are Flat12|34(P) = âAA AC AG · · · TT AA pAAAA pAAAC pAAAG · · · pAAT T AC pACAA pACAC pACAG · · · pACT T AG pAGAA pAGAC pAGAG · · · pAGT T . . .. . .. . .. . ..... . . TT pT T AA pT T AC pT T AG · · · pT T T T ì Flat13|24(P) = âAA AC AG · · · TT AA pAAAA pAAAC pAAAG · · · pAT AT AC pAACA pAACC pAACG · · · pAT CT AG pAAGA pAAGC pAAGG · · · pAT GT . . .. . .. . .. . ..... . . TT pT AT A pT AT C pT AT G · · · pT T T T ì Let us now describe how phylogenetic models can be algebraically represented using tensor products and Kronecker product operations. 12
Given a tree Twith Lleaves, the joint probability of nucleotides at the leaves, P= (pAA...A, ..., pT T...T ), can be seen as a tensor in R4⊗R4⊗ · · · ⊗ R4⊗R4 | {z } L . We denote Σ = {A, C, G, T}and identify Σ with the natural basis in R4. We can obtain a basis in R4⊗R4⊗ · · · ⊗ R4⊗R4 | {z } L naturally defined as A⊗A⊗ · · · ⊗ A⊗A | {z } L , A ⊗A⊗ · · · ⊗ A⊗C | {z } L , ..., T ⊗T⊗ · · · ⊗ T⊗T | {z } L . With these definitions, we can rewrite Pin tensor form as P=X x1,x2,...,xL∈Σ px1x2···xLx1⊗x2⊗ · · · ⊗ xL. Definition 2.3. Let Tbe a phylogenetic tree and P=φT(θ). Given invertible matrices Ni, i= 1, .., L, we define the Markov action as the transformation rule P−→ Nt 1⊗Nt 2⊗ · · · ⊗ Nt L·P. Proposition 2.4 ([21]).Let Tbe a phylogenetic tree and P=φT(θ). Assume θ={πr,(Me)e∈E(T)}. Consider the Markov action: (×LM4×4)× ⊗LR4−→ ⊗LR4 (N1, N2, ..., NL;P)7−→ K= (N1⊗N2⊗ · · · ⊗ NL)t·P Then, K=φT(θ′), where θ′={πr, M1N1, M2N2, ..., MLNL,(Me)e∈int(E(T))}. Therefore, this transformation expresses how a distribution Parising from a Markov model on a phylogenetic tree changes if additional Markov matrices Niare applied at the leaves of the tree. Proof. Let us first prove that P=M1t⊗ · · · MLt·Q, where Q=φT(πr, Id, ..., Id, (Me)e∈int(E(T))). ˜px1...xL=M1t⊗ · · · MLt·Q=X j1,...,jL∈Σ M1t x1j1M2t x2j2· · · MLt xLjLqj1...jL =X j1,...,jL∈Σ M1t x1j1M2t x2j2· · · MLt xLjLX xu∈Σ u∈Int(T),u=rX xr∈Σ πxrY e∈E(T) e:pa(e)→ch(e) Me xpa(e),xch(e) =X xu∈Σ u∈Int(T),u=rX xr∈Σ πxrY e∈E(T) e:pa(e)→ch(e) Me xpa(e),xch(e)=px1...xL. Additionally, φT(πr, M1N1, ..., MLNL,(Me)e∈int(E(T)))=(M1N1)t⊗ · · · ⊗ (MLNL)t·Q = (N1t⊗ · · · ⊗ NLt)(M1t⊗ · · · ⊗ MLt)Q = (N1⊗ · · · ⊗ NL)t·P. So, K= (N1⊗ · · · ⊗ NL)t·P=φT(πr, M1N1, ..., MLNL,(Me)e∈int(E(T))), as we aimed to see. 13
Lemma 2.5 ([2]).If P∈R44comes from a Markov process on tree T12|34, then Flat12|34(P)=(M1⊗M2)t·Flat12|34(Q)·(M3⊗M4), where Q∈R44can be understood as the distribution from the tree Twith exterior transition matrices equal to the identity (leaving πrand Methe same), i.e, Q=φT(πr, Id, Id, Id, Id, Me). Proof. Using the expression (1.3) and the fact that A·B= (ci,j)m×p, where A:= (ai,j)m×nand B:= (bi,j)n×pare matrices and ci,j =Pn r=1 ai,rbr,j, one can prove the lemma doing the following steps. We consider the flattening of Q=φT(πr, Id, Id, Id, Id, Me), Flat12|34(Q). Using expression (1.2), we have that qx1x2x3x4=X xr∈{A,C,G,T } Idxrx1Idxrx2X xs∈{A,C,G,T } πxrMe xrxsIdxsx3Idxsx4. Due to the form of the identity matrix, qx1x2x3x4= 0 if x1=x2or x3=x4. This tells us that Flat12|34(Q) is a 16 ×16 matrix whose unique non-zero entries are labelled by (xx,yy). And those entries are equal to qxxyy =πxMe xy. Moreover, [(M1⊗M2)t·Flat12|34(Q)](x1,x2),xk=X xr∈{A,C,G,T } [(M1⊗M2)t](x1,x2)(xr,xr)·[Flat12|34(Q)](xr,xr)(xk,xk) =X xr∈{A,C,G,T } [(M1⊗M2)t](x1,x2)(xr,xr)·πxrMe xrxk. In addition, the following expression can be obtained by manipulating the next formula: [(M1⊗M2)t·Flat12|34(Q)·(M3⊗M4)](x1,x2)(x3,x4)= =X xs∈{A,C,G,T } [(M1⊗M2)t·Flat12|34(Q)](x1,x2),(xs,xs)·[M3⊗M4](xs,xs)(x3,x4) =X xs∈{A,C,G,T }X xr∈{A,C,G,T } (M1⊗M2)t (x1,x2)(xr,xr)·πxrMe xrxs·(M3⊗M4)(xs,xs)(x3,x4) =px1x2x3x4= (Flat12|34(P))(x1,x2)(x3,x4). In a similar way, we obtain that Flat13|24(P)=(M1⊗M3)t·Flat13|24(Q)·(M2⊗M4) Flat14|23(P)=(M1⊗M4)t·Flat14|23(Q)·(M2⊗M3). Similarly, it can be proved that in general FlatA|B(P) = Mt A·FlatA|B(Q)·MB, where MA=Ms1⊗Ms2⊗ · · · ⊗ Msmand MB=Mt1⊗Mt2⊗ · · · ⊗ Mtn. 14
Remark 2.6.Let us now express the Markov action in terms of the flattening. This transformation rule becomes FlatA|B(P)−→ FlatA|B(Ns1 t⊗Ns2 t⊗ · · · ⊗ Ntm t·P) = Nt A·FlatA|B(P)·NB, where NA=Ns1⊗ · · · ⊗ Nsmand NB=Nt1⊗ · · · ⊗ Ntn. This equality holds from the following argument: FlatA|B(Ns1 t⊗Ns2 t⊗ · · · ⊗ Ntn t·P) = = (Ms1Ns1⊗ · · · ⊗ MsmNsm)t·FlatA|B(Q)·(Mt1Nt1⊗ · · · ⊗ MtnNtn) = (Ns1⊗ · · · ⊗ Nsm)t(Ms1⊗ · · · ⊗ Msm)t·FlatA|B(Q)·(Mt1⊗ · · · ⊗ Mtn)(Nt1⊗ · · · ⊗ Ntn) =NAt·FlatA|B(P)·NB. With all these ideas, we are ready to prove the following theorem: Theorem 2.7 ([1], Allman and Rhodes).Let P=φT(πr, M1, M2, M3, M4, Me)be a generic distribution arising from the general Markov model on T12|34. Then rank(Flat12|34(P)) = 4. Moreover, rank(Flat13|24(P)) = rank(Flat14|23(P)) = 16. Proof. From (2.5) we know that Flat12|34(P)=(M1⊗M2)t·Flat12|34(Q)·(M3⊗M4) Flat13|24(P)=(M1⊗M3)t·Flat13|24(Q)·(M2⊗M4) Flat14|23(P)=(M1⊗M4)t·Flat14|23(Q)·(M2⊗M3). We have already proved that Flat12|34(Q) is a matrix whose unique non-zero entries are in the diagonal labelled by (xx, yy). Similarly, and due to the indexing rules of the flattening matrices, Flat13|24(Q) is a matrix whose unique non-zero entries are in the diagonal labelled by (xy, xy) and are equal to πxMe x,y. And finally, Flat14|23(Q) is a matrix whose unique non-zero entries are labelled by (xy, xy) and are equal to πxMe x,y. This tells us that Flat13|24(Q) and Flat14|23(Q) are diagonal matrices, while Flat12|34(Q) only has 4 of its 16 rows different from 0. Therefore, for sufficiently generic parameters, Flat12|34(Q) has rank 4, and Flat13|24(Q) and Flat14|23(Q) have rank 16. As the rank of a Kronecker product is the product of ranks, we can finally say that, for generic parameters, rank(F lat12|34(P)) = 4, rank(Flat13|24(P)) = 16 and rank(Flat14|23(P)) = 16. In other words, this theorem states that the 5 ×5 minors of Flat12|34(P) are topology invariants for T12|34. If we want to state a more general theorem, we first need to give the following definition: Definition 2.8. The parsimony score,r, for the bipartition A|Bof the set of leaves Sconsidered as a binary character at the leaves of T, is the minimum number of binary changes needed in the interior nodes to obtain the bipartition desired, see [18]. Example 2.9. Let us show two examples on the computation of the parsimony score using the Fitch ’s Algorithm,[11]: 15
Figure 2.1: The Fitch’s Algorithm process for two trees. The left one with bipartition A={1}, B = {2,3,4}, and the right one with bipartition A={1,4}, B ={2,3}. Theorem 2.10 ([1]).Let Tbe a phylogenetic tree and P=φT(θ)a generic distribution arising from T. Let Aand Bbe a bipartition of the leaf set Sof Tand rits parsimony score. Then rank(FlatA|B(P)) = 4r. 2.2 Subflattening matrices In this section, we introduce subflattening matrices as a way to significantly reduce the dimensionality of flattening matrices associated to a given bipartition A|Bof Swhile preserving the rank information needed to determine if A|Bis an edge split of a given tree T(see Theorem 2.10). We show that the complexity of estimating the rank of FlatA|B(P) is exponential in the number of leaves, but the dimension of the subflattening is quadratic in the number of leaves. Let us now examine the transformations required to be applied to FlatA|B(P) to obtain the desired subflattening. We first make the following observation: Remark 2.11.Let S=Üs11 s21 s31 1 s12 s22 s32 1 s13 s23 s33 1 s14 s24 s34 1ê(*) be a similarity matrix and Mbe any Markov matrix. As each row of a Markov transition matrix Msums to one, the vector v1= (1,1,1,1)tis an eigenvector of eigenvalue 1. Then, S−1MS =Üm′ 11 m′ 21 m′ 31 0 m′ 12 m′ 22 m′ 32 0 m′ 13 m′ 23 m′ 33 0 m′ 14 m′ 24 m′ 34 1ê=ÅR0 v1ã. Definition 2.12. Let Sbe any invertible matrix as above and let Mbe any Markov matrix. We define M′as the transformed matrix M′:= S−1MS =ÅR0 v1ã,(2.1) where Ris a 3 ×3 matrix and vis a 3-component row vector. 16
We can assume that det(M)= 0, implying det(R)= 0. The set of such matrices (2.1) then forms what is known as the affine group Aff(3). Note that there are many possible choices for the similarity transformation S. In this project, we consider Sto be an invertible matrix with a constant column equal to one. Proposition 2.13 ([20]).Consider the tree topology T12|34 in the 4-leaf tree T. Let (M1)′= S−1M1Sand (M2)′=S−1M2S. Denote M′ 12 = (M1)′⊗(M2)′. Then, the 5×5bottom right subblock of M′ 12 is ‘ M′ 12 =ÑR10 0 0R20 v1v21é. Proof. We start by computing M′ 12 : M′ 12 = (M1)′⊗(M2)′= (S−1M1S)⊗(S−1M2S) = ÅR10 v11ã⊗ÅR20 v21ã=ÜR1⊗R20 0 0 R1⊗v2R10 0 v1⊗R20R20 v1⊗v2v1v21ê. Finally, by defining ‘ M′ 12 := ÑR10 0 0R20 v1v21é,we obtain the desired subblock. Remark 2.14 ([20]).This idea can be extended to the case of an arbitrary number of leaves. Let A|Bbe a bipartition of the set of leaves S. Suppose we have MA=Ms1⊗· · · ⊗Msm, where Msiis the transition matrix associated with the i-th leaf in A. After applying the same similarity transformation on each factor, i.e., M′ A=S−1Ms1S⊗ · · · ⊗ S−1MsmS, and possibly some simultaneous row and column permutations, we can extract a (3m+ 1) ×(3m+ 1) subblock of the form d M′ A:= âR10 0 · · · 0 0R20· · · 0 . . .. . .. . ..... . . 0 0 · · · Rm0 v1v2· · · vm1ì. Similarly, we can define d M′ Bfor the leaves in B. Definition 2.15. Let Tbe a phylogenetic tree with L=m+nleaves, A|Bbe a bipartition of the leaf set Sand let FlatA|B(P) be the flattening corresponding to some P=φT(θ). Let Sbe a similarity transformation as in (*). We define the transformed flattening as Flat′ A|B(P) := FlatA|B(P′), where P′= (S⊗S⊗ · · · ⊗ S |{z } m+n )t·P. Lemma 2.16. The transformed flattening F lat′ A|B(P)satisfies Flat′ A|B(P)=(S⊗S⊗ · · · ⊗ S)t | {z } m FlatA|B(P) (S⊗S⊗ · · · ⊗ S) | {z } n . 17
Proof. Using Remark 2.6 the calculation of the desired expression is straightforward. Definition 2.17. If A|Bis a bipartition of the set of leaves Son a phylogenetic tree T, where |A|=m, |B|=n, we denote by MA|B(R) to the set of 4m×4nmatrices with entries in R, where rows and columns are indexed by all possible patterns of states in Aand B, respectively. Corollary 2.18 ([20]).Given MA, MBand S, the following diagram is commutative: MA|B(R)σ// s MA|B(R) s MA|B(R)σ′ //MA|B(R) , where σ:X7−→ Mt AXMB, σ′:X7−→ (M′ A)tXM′ Band s:X7−→ X′= (S⊗S⊗ · · · ⊗ S | {z } m )t·X·(S⊗S⊗ · · · ⊗ S | {z } n ). In particular (Mt AFlatA|B(P)MB)′= (M′ A)tFlat′ A|B(P)M′ B. Proof. To show that the diagram is commutative, we need to verify that σ′◦s=s◦σ. Recall that smaps Xto the transformed matrix X′. Thus, we must demonstrate that (S⊗S⊗ · · · ⊗ S | {z } m )t·Mt AXMB·(S⊗S⊗ · · · ⊗ S | {z } n )=(M′ A)tX′M′ B. To establish the equality, we perform the following computations: (S⊗S⊗ · · · ⊗ S | {z } m )t·Mt AXMB·(S⊗S⊗ · · · ⊗ S | {z } n ) = = (S⊗S⊗ · · · ⊗ S | {z } m )tMt A(S−1⊗S−1⊗ · · · ⊗ S−1 | {z } m )t(S⊗S⊗ · · · ⊗ S | {z } m )t·X·(S⊗S⊗ · · · ⊗ S | {z } n ) (S−1⊗S−1⊗ · · · ⊗ S−1 | {z } n )MB(S⊗S⊗ · · · ⊗ S | {z } n ) = (M′ A)tX′M′ B. Thus, we have shown that σ′◦s=s◦σ, and consequently, the diagram is commutative. Definition 2.19. We define the subflattening ¤ Flat′ A|B(P) as a certain submatrix with (3m+ 1) rows and (3n+ 1) columns of Flat′ A|B(P). This submatrix corresponds to the rows chosen to construct ‘ M′ A tfrom (M′ A)tand the columns chosen to construct d M′ Bfrom M′ B, specified in Remark 2.14. 18
situation there, the new coordinates of Flat′ A′|B(P+) can be expressed as follows: p+′ x1...xmxm+1,y1...yn=X i1,...,im,im+1, j1,j2,...,jn∈Σ St x1i1· · · St xmimSt xm+1im+1 St y1j1· · · St ynjnp+i1i2...imim+1,j1j2...jn =X i1,...,im,im+1, j1,j2,...,jn∈Σ St x1i1· · · St xm+1im+1 St y1j1· · · St ynim+1 Idim+1jnpi1i2...im,j1j2...jn =X im+1,k∈Σ St xm+1im+1 St ynim+1 S−t im+1kX i1,...,im j1,...,jn∈Σ St x1i1· · · St yn−1jn−1St kjnpi1i2...im,j1j2...jn =X im+1,k∈Σ St xm+1im+1 St ynim+1 S−t im+1kp′ x1x2...xm,y1y2...yn−1k =X j,j′∈Σ St xm+1jSt ynjS−t jj′p′ x1x2...xm,y1y2...yn−1j′. In this case, the rows of ¤ Flat′ A′|B(P+) will be indexed by TT...T XT...TT | {z } m+1 , with X={A, C, G, T}, and the columns by T T...TXT...TT | {z } n , with X={A, C, G, T}. We will now use a similar reasoning as in the previous lemma to see which rows of the subflattening ¤ Flat′ A′|B(P+) and ¤ Flat′ A|B(P) are identical. (i). Suppose xm=xm+1 =T. Then, p+′ x1...xm−1T T,y1...yn=X j,j′∈Σ St T jSt ynjS−t jj′p′ x1...xm−1T,y1...yn−1j′=X j,j′∈Σ St ynjS−t jj′p′ x1...xm−1T,y1...yn−1j′ =X j′∈Σ p′ x1...xm−1T,y1...yn−1j′X j∈Σ St ynjS−t jj′=X j′∈Σ p′ x1...xm−1T,y1...yn−1j′(StS−t)ynj′ =X j′∈Σ p′ x1...xm−1T,y1...yn−1j′Idynj′=p′ x1...xm−1T,y1...yn−1yn. (ii). Suppose xm=T, xm+1 =T. Then, manipulating the expression in a similar way to the previous calculation, we obtain that p+′ x1...xmT,y1...yn=p′ x1...xm,y1...yn. Using these two equalities, we can observe that the first 3mrows and the last row are indeed identical. Let us now examine the three new rows of ¤ Flat′ A′|B(P+) indexed by T T...TX, X ∈ {A, C, G}. The corresponding expression is p+′ T T...T xm+1,y1...yn=X j,j′∈Σ St xm+1jSt ynjS−t jj′p′ T T...T,y1...yn−1j′, where the columns are indexed by y1...yn, with at most one yb=Tat a time. In particular, if we choose y1=T, we obtain: p+′ T...T xm+1,y1T...T =X j,j′∈Σ St xm+1jS−t jj′p′ T...T,y1T...T j′=X j′∈Σ p′ T...T,y1T...T j′Idxm+1j′=p′ T...T,y1T...T xm+1 . 25
Since xm+1 =Tand y1=T, the new coordinates p+′ T T...T xm+1,y1T...T do not appear in ¤ Flat′ A|B(P) because two indexes of the same part of the split are different from T. Furthermore, these coordinates do not appear in any of the other rows of ¤ Flat′ A′|B(P+). Thus, any linear dependence between the new rows and the remaining rows would imply a linear dependence between the remaining rows. Since these remaining rows are copied from ¤ Flat′ A|B(P), any linear dependence between them would imply linear dependence among the coordinates of ¤ Flat′ A|B(P). This would, in turn, imply linear constraints on the original L-leaf tree T. However, the existence of linear phylogenetic invariants for the general Markov model is known to be fake (see [13]). Therefore, the new rows of ¤ Flat′ A′|B(P+) are linearly independent from the remaining ones. To complete the proof we use induction on the base case of a two-taxon tree. In the general case, it is necessary to note that the two-taxon subflattening associated with the bipartition A|B={1}|{2} has full rank 4. In this case, as d M′ A=M′ Aand d M′ B=M′ B, we have that ¤ Flat′ {1}|{2}(P) = Flat′ {1}|{2}(P) = StFlat{1}|{2}(P)S. Furthermore, we know that Flat{1}|{2}(P) = M1tFlat{1}|{2}(Q)M2, where Q=φT(πr, Id, Id). Then, Flat{1}|{2}(Q) = diag(πA, πC, πG, πT) = D(πr) and Flat{1}|{2}(P) = M1tD(πr)M2. As in the generic case both M1and M2have full rank and πrhas no zero entries, Flat{1}|{2}(P) has full rank. Therefore, ¤ Flat′ {1}|{2}(P) also has full rank. Moreover, adding a new taxon to the tree results in a new subflattening that is a replica of the previous one and increases in three independent rows. This implies that if the previous subflattening had full rank, the new subflattening will also have full rank. By using induction on the base case (as we have demonstrated that the corresponding subflattening has full rank) and applying the above argument, the lemma can be established. With the help of the two lemmas established, we can now prove Theorem 2.22 for any L-leaf tree and any bipartition A|Bof the leaf set Sby following these steps: (i). Use Lemma 2.24 to prune the maximally A|B-consistent subtrees. It is important to note that this action does not affect the rank of the subflattening but generates a tree that satisfies the conditions specified in Lemma 2.25. (ii). Making an abuse of notation, denote the pruned tree as Tand the resulting bipartition as A|B. Apply Lemma 2.25 to conclude that ¤ Flat′ A|B(P) has full rank. (iii). As demonstrated in Lemma 2.25, adding a new taxon to the tree changes the subflattening by adding three new independent rows to the old one. This implies that the rank of the new subflattening is given by rank(new subflattening) = rank(old subflattening) + 3. Since the rank of the subflattening for an edge is 4, we can state by induction that rank(¤ Flat′ A|B(P)) = 4 + 3 ·k, where kdenotes the number of added leaves. Since we are considering a tree that 26
always satisfies the properties specified in Lemma 2.25 when adding a new taxon, we need to add a leaf in Anext to an original B-leaf and a leaf in B next to an original A-leaf to maintain this property. In terms of the parsimony score, this means increasing it by one unit. Moreover, the number of added leaves equals the parsimony score minus one, k=r−1. Thus, we can conclude that rank(¤ Flat′ A|B(P)) = 4 + 3(r−1) = 1 + 3r, where rdenotes the parsimony score. To calculate the parsimony score, one can refer to Fitch’s algorithm ([11]). (iv). If A|Bis and edge split, the parsimony score for this corresponding bipartition is r= 1, and the rank of the subflattening ¤ Flat′ A|B(P) is 4. If A|Bis not an edge split, then the parsimony score will be greater than or equal to 2, which implies that the rank of ¤ Flat′ A|B(P) will be greater than or equal to 1 + 3 ·2 = 7. Remark 2.26.Using this Theorem, we have shown that the edge invariants can be defined as the 5×5 minors of the subflattening ¤ Flat′ A|B(P). These minors are equal to zero if and only if the bipartition A|Bis an edge split of T. 27
Chapter 3 The Kimura 3-parameter model Let us now analyse how the previous results can be applied to the Kimura 3-parameter model. To do so, we first need to pay attention to a series of definitions and remarks. Definition 3.1. The matrix that gives the change of basis from the Fourier basis to the canonical basis is: H=Ü1 1 1 1 1 1 −1−1 1−1 1 −1 1−1−1 1 ê One of the important properties of this symmetric matrix His that its inverse is H−1=1 4H. Furthermore, His also a similarity matrix and in this chapter Hmay be chosen as the similarity matrix S(in the sense of Chapter 2) to define the subflattenings. The above matrix Hdiagonalizes any K81 transition matrix M, that is H−1MH is the diagonal matrix with eigenvalues given in Proposition 1.15. As a result, the transformed matrix M′takes on a simpler form in this specific model. To maintain consistency with the notation typically used in articles discussing the K81 model, and in relation to the notation introduced in the previous sections, we will assume that the desired form of M′in the context of the Kimura 3-parameter model is as follows: M′=Å1v 0Rã. The results obtained in the previous sections remain valid with appropriate modifications. Suppose Pis the joint distribution of nucleotides at the leaves of tree Tunder this model. As we have seen, the matrix M′can be obtained from Musing the transformation M′=H−1MH, which is a diagonal matrix. Note that the matrix His the change of basis from Σ′to the standard basis Σ. Note that Σ′ induces a basis in ⊗4R4(which will be called the Fourier basis again). If p′ AA...AA, ..., p′ T T...T T are the coordinates in the Fourier tensor basis and pAAAA, ..., pT T T T are the natural coordinates of the joint probability distribution, then X x1,x2,...,xL∈Σ px1x2...xLx1⊗x2⊗ · · · ⊗ xL=X x1,x2,...,xL∈Σ p′ x1x2...xLx′ 1⊗x′ 2⊗ · · · ⊗ x′ L. 28
Therefore, the relationship between the coordinates of the joint probability distribution in the natural tensor basis and the Fourier tensor basis is PΣ′= (H−1⊗H−1⊗ · · · ⊗ H−1⊗H−1)PΣ=1 4L(H⊗H⊗ · · · ⊗ H⊗H)PΣ. Throughout the work, we will get by without the factor 1 4L. So we define P′= (H⊗H⊗···⊗H⊗ H)PΣ= (Ht⊗Ht⊗ · · · ⊗ Ht⊗Ht)PΣ,which is consistent with the change of basis presented in Section 2.2. 3.1 Subflattenings of the K81 model We now want to study the rank of the subflattening in the K81 model, and have a look at which entries have a crucial role in calculating the rank of the subflattening. We will then compare this results with the ones obtained in Theorem 2.22. From now on we will only focus on 4-leaf trees. To start having a look at the specific form of the subflattening, let us first prove the following theorem: Theorem 3.2 ([2]).Let P=φT(πr, M1, M2, M3, M4, Me),where Miare Kimura 3-parameter transition matrices of the tree T=T12|34 and πr= (1 4,1 4,1 4,1 4). If (miA, miC, miG, miT)are the eigenvalues of Mi, then p′ x1x2x3x4=ßm1x1m2x2mex1+x2m3x3m4x4,if x1+x2=x3+x4 0,otherwise , where the sum of nucleotides is given by the bijection between Σand G=Z/2Z×Z/2Zdefined as A↔(0,0), C ↔(0,1), G ↔(1,0), T ↔(1,1). With this bijection we can consider Gas the additive group with neutral element Aand the + operation that satisfies C+C=G+G=T+T=A, C +G=T, G +T=C, C +T=G. Proof. Let us start calculating the form of the Q=φT(πr, Id, Id, Id, Id, M) coordinates. Based on Lemma 2.5, we know that: qx1x2x3x4=X xr∈{A,C,G,T } Idxrx1Idxrx2X xs∈{A,C,G,T } 1 4MxrxsIdxsx3Idxsx4. This tells us that qx1x2x3x4=ß1 4Mxy ,if x=x1=x2, y =x3=x4 0,otherwise We have seen at the beginning of this Chapter that Q′= (H⊗H⊗H⊗H)Q, so q′ x1x2x3x4=X y1,y2,y3,y4∈Σ Hx1y1Hx2y2Hx3y3Hx4y4qy1y2y3y4=1 4X y,z∈Σ Hx1yHx2yHx3zHx4zMyz. 29
Furthermore, since Hx3zHx4z=Hx3+x4,z, q′x1x2x3x4=1 4X y∈Σ Hx1yHx2yX z∈Σ Hx3zHx4zMyz =1 4X y∈Σ Hx1+x2,y X z∈Σ Hx3+x4,zMyz =1 4X y∈Σ Hx1+x2,y X z∈Σ Hx3+x4,z(M)t zy =1 4X y∈Σ Hx1+x2,y(H(M)t)x3+x4,y =1 4(H(H(M)t)t)x1+x2,x3+x4=1 4(HMHt)x1+x2,x3+x4 =1 4(HMH)x1+x2,x3+x4= (H−1MH)x1+x2,x3+x4=M′ x1+x2,x3+x4. As M′=diag(mA, mC, mG, mT), q′ x1x2x3x4=ßmx1+x2,if x1+x2=x3+x4 0,otherwise Additionally, as Flat12|34(P)=(M1⊗M2)t·Flat12|34(Q)·(M3⊗M4), using Proposition 2.18 it follows that Flat′ 12|34(P)=(M1′⊗M2′)t·Flat′ 12|34(Q)·(M3′⊗M4′). It is known that p′x1x2x3x4=F lat′ 12|34(P)x1x2,x3x4. Furthermore, (M1′⊗M2′) and (M3′⊗M4′) are diagonal matrices, and the only non-zero elements of Flat12|34(Q′) are those for which x1+x2= x3+x4. Therefore, p′x1x2x3x4=ßm1x1m2x2mex1+x2m3x3m4x4,if x1+x2=x3+x4 0,otherwise as we aimed to see. Our goal now is to determine the rank of the subflattening obtained in the Fourier basis. To achieve this, we will prove the following theorem without making use of Theorem 2.22: Theorem 3.3. Let T12|34 be a phylogenetic tree. Let us consider that its root distribution is πr= (1 4,1 4,1 4,1 4)and that the transition Markov matrices Meon each edge e∈E(T)are Kimura 3- parameter transition matrices. For the generic case parameters, if P=φT(πr, M1, M2, M3, M4, Me), the subflattening Flat′ 12|34(P) V has rank 4. Moreover, Flat′ 13|24(P) V and Flat′ 14|23(P) V have rank 7. Proof. In Theorem 3.2 we have seen that p′x1x2x3x4=ßm1x1m2x2mex1+x2m3x3m4x4,if x1+x2=x3+x4 0,otherwise As in this section we are considering that the desired form of M′=Å1v 0Rã,the submatrices d M′ A and d M′ Bwill be obtained by selecting the rows and columns AA, AC, AG, AT, CA, GA, T A, since M1′⊗M2′=Å1v1 0R1ã⊗Å1v2 0R2ã=Ü1v2v1v1⊗v2 0R20v1⊗R2 0 0 R1R1⊗v2 0 0 0 R1⊗R2ê. 30
This tells us that in the indices of the selected rows and columns of Flat′ A|B(P) V all states are equal to A except at most one (cf. as happened in the previous chapters with the Tcharacter). In a compact way we can write Flat′ 12|34(P) V = p′ AAAA 0 0 0 0 0 0 0p′ ACAC 0 0 p′ ACCA 0 0 0 0 p′ AGAG 0 0 p′ AGGA 0 0 0 0 p′ AT AT 0 0 p′ AT T A 0p′ CAAC 0 0 p′ CACA 0 0 0 0 p′ GAAG 0 0 p′ GAGA 0 0 0 0 p′ T AAT 0 0 p′ T AT A, .(3.1) where the zero entries are given by Theorem 3.2. Our next objective is to analyze the rank of the previous matrix. Since row and column permutations does not affect the rank, we have that rank(Flat′ 12|34(P) V ) = rank p′ AAAA 0 0 0 0 0 0 0p′ ACAC p′ ACCA 0 0 0 0 0p′ CAAC p′ CACA 0 0 0 0 0 0 0 p′ AGAG p′ AGGA 0 0 0 0 0 p′ GAAG p′ GAGA 0 0 0 0 0 0 0 p′ AT AT p′ AT T A 0 0 0 0 0 p′ T AAT p′ T AT A . Moreover, each 2 ×2 subblock of this matrix has rank=1 by looking at the expression of p′given in Theorem 3.2. Therefore, the rank of Flat′ 12|34(P) V is 4 and it is composed by 4 blocks of rank 1. Let us now compute rank(Flat′ 13|24(P)) = rank p′AAAA 0 0 0 0 0 0 0p′AACC p′ACCA 0 0 0 0 0p′CAAC p′CCAA 0 0 0 0 0 0 0 p′AAGG p′AGGA 0 0 0 0 0 p′GAAG p′GGAA 0 0 00000p′AAT T p′AT T A 00000p′T AAT p′T T AA . In this case, if y=xand y=A, Theorem 3.2 gives that det Åp′xxyy p′xyyx p′yxxy p′yyxxã=p′xxyyp′yyxx −p′xyyxp′yxxy =m1xm2xm3ym4ym1ym2ym3xm4x((mex+x)2−(mex+y)2)= 0, because y=A. This tells us that the rank of each 2 ×2 block equals 2, and therefore that the rank of Flat′ 13|24(P) V is 7. The rank of Flat′ 14|23(P) V would be calculated analogously. 31
Remark 3.4.This theorem provides an ad hoc proof of Theorem 2.22 in the specific case of the Kimura model. Additionally, it provides a stronger condition: the blocks of F lat′ 12|34(P) V have rank 1. For any parameters, not only the ones for the generic case, this Theorem would state that the subflattening Flat′ 12|34(P) V has rank ≤4 and that the blocks of Flat′ 12|34(P) V have rank ≤1. 3.2 Marginalization of distributions After exploring the entries of the K81 model subflattening, a natural question arises: what is the significance of these entries? In this section, we will delve into the connection between these components and the marginalization of the leaves. Definition 3.5. Let us consider P=φT(πr, M1, M2, M3, M4, Me). The marginalization of Pover the leaf 4 is defined as P123, where P123x1x2x3=px1x2x3+=X x4∈Σ px1x2x3x4=X x4∈ΣX xr,xs∈Σ πxrM1 xrx1M2 xrx2Me xrxsM3 xsx3M4 xsx4 =X xr,xs∈Σ πxrM1 xrx1M2 xrx2Me xrxsM3 xsx3X x4∈Σ M4 xsx4 =X xr,xs∈Σ πxrM1 xrx1M2 xrx2Me xrxsM3 xsx3=X xr∈Σ πxrM1 xrx1M2 xrx2X xs∈Σ Me xrxsM3 xsx3 =X xr∈Σ πxrM1 xrx1M2 xrx2(MeM3)xrx3. The expression gives the probability of observing nucleotides x1, x2, x3in a phylogenetic tree containing three leaves, with transition matrices M1, M2,and MeM3(see figure 3.1). Figure 3.1: Phylogenetic tree of 3 leaves with transition matrices M1, M2, MeM3, obtained from the marginalization over the leaf 4 on T12|34. Proposition 3.6. Let P=φT(πr,(Me)e∈E(T))∈R44denote the joint probability at the leaves. Let p′x1x2x3x4denote the components of Pin the Fourier basis. Then, p′x1x2x3A= (P123)′ x1x2x3, for all x1, x2, x3. Proof. To begin, we compute the Fourier coordinates of P123 and we obtain (P123)′ x1x2x3=ßm1x1m2x2mex3m3x3,if x1+x2+x3= 0 0,otherwise . 32
Additionally, by Theorem 3.3 we have p′x1x2x3A=ßm1x1m2x2mex1+x2m3x3m4A,if x1+x2=x3+A=x3 0,otherwise =ßm1x1m2x2mex3m3x3,if x1+x2+x3= 0 0,otherwise . Therefore, we conclude that p′x1x2x3A= (P123)′ x1x2x3, for all x1, x2, x3. Let us now repeat the entire process to marginalize over a new leaf. Definition 3.7. The marginalization of Pover the leaves 2,4 is P13,where P13 x1x3=px1+x3+= Px2,x4∈Σpx1x2x3x4. Proposition 3.8. Let P=φT(πr,(Me)e∈E(T))∈R44denote the joint probability at the leaves. Let p′x1x2x3x4denote the elements of Pin the Fourier Basis. Then, p′x1Ax3A= (P13)′ x1x3,for all x1, x3. Proof. Let us perform the same calculation as before. We have P13 x1x3=X x2∈Σ px1x2x3+=X x2∈ΣX xr∈Σ πxrM1 xrx1M2 xrx2(MeM3)xrx3=X xr∈Σ πxrM1 xrx1(MeM3)xrx3. The previous expression gives the probability of observing nucleotides x1and x3in a tree with two leaves, and transition matrices M1and MeM3(see figure 3.2). Figure 3.2: Phylogenetic tree of 2 leaves with transition matrices M1, MeM3,coming from the marginalization over leaves 2 and 4 on a tree with 4 leaves. Let us proceed with the calculation of the Fourier coordinates of P13. (P13)′ x1x3=ßm1x1mex3m3x3,if x1+x3= 0 0,otherwise . Moreover, p′x1Ax3A=ßm1x1m2Amex1+Am3x3m4A,if x1+A=x1=x3+A=x3 0,otherwise =ßm1x1mex3m3x3,if x1+x3= 0 0,otherwise . As the two expressions coincide, we conclude that p′x1Ax3A= (P13)′ x1x3,for all x1, x3. 33
We can perform the same process with the different marginalizations to obtain: (P13)′= (px1+x3+)′ xi∈Σ= (p′ x1Ax3A)xi∈Σ(P14)′= (px1++x4)′ xi∈Σ= (p′ x1AAx4)xi∈Σ (P23)′= (p+x2x3+)′ xi∈Σ= (p′ Ax2x3A)xi∈Σ(P24)′= (p+x2+x4)′ xi∈Σ= (p′ Ax2Ax4)xi∈Σ. If we now express the corresponding flattenings of these new elements, Flat′ 1|3(P13) = Ü(pA+A+)′(pA+C+)′(pA+G+)′(pA+T+)′ (pC+A+)′(pC+C+)′(pC+G+)′(pC+T+)′ (pG+A+)′(pG+C+)′(pG+G+)′(pG+T+)′ (pT+A+)′(pT+C+)′(pT+G+)′(pT+T+)′ê=Üp′ AAAA 0 0 0 0p′ CACA 0 0 0 0 p′ GAGA 0 0 0 0 p′ T AT Aê. We call X13 the 3 ×3 bottom right submatrix of Flat′ 1|3(P13). Analogously, Flat1|4(P′14) = Üp′AAAA 0 0 0 0p′CAAC 0 0 0 0 p′GAAG 0 0 0 0 p′T AAT ê, Flat′ 2|3(P23) = Üp′AAAA 0 0 0 0p′ACCA 0 0 0 0 p′AGGA 0 0 0 0 p′AT T Aêand Flat′ 2|4(P24) = Üp′AAAA 0 0 0 0p′ACAC 0 0 0 0 p′AGAG 0 0 0 0 p′AT AT ê. We call Xij the 3 ×3 bottom right subblock of Flat′ i|j(Pij). From the above and 3.1, we conclude that ¤ Flat′ xy|zt(P) = Ñp′AAAA 0 0 0Xyt Xyz 0Xxt Xxzé. Therefore, the subflattening of F latA|Bis given by entries from the pairwise marginalizations. This gives us a better understanding of the process of taking subflattenings and gives a faster way of constructing these matrices. 34
(a) N= 1000 (b) N= 10000 Figure 5.2: Bar graphs representing the results for the general Markov model. Branch lengths SVD Subflattenings Erik+2 Fourier Normalization a=101, b=101 85 70 76 72 a=21, b=101 68 79 49 65 a=51, b=51 99 99 99 97 Table 5.3: % of success of the different methods tested in 3 different scenarios. The alignments have been generated under the K81 model and the alignment length is N=1000. Branch lengths SVD Subflattenings Erik+2 Fourier Normalization a=101, b=101 98 98 96 94 a=21, b=101 99 99 96 73 a=51, b=51 99 99 99 99 Table 5.4: % of success of the different methods tested in 3 different scenarios. The alignments have been generated under the K81 model and the alignment length is N=10000. If we now have a look at Tables 5.3 and 5.4, one can see that in general terms both SVD and the subflattening method have a similar performance. When employing K81 alignments, the percentage of success shows a significant increase when using the subflattening method in the a= 21, b = 101, N = 1000 scenario, an overall 11% of better performance. This can be attributed to the use of matrix H, introduced in Chapter 3, as S, which provides a change of basis in which the elements of the matrix are simplified, and the calculations can be simpler and more concrete. Moreover, we can see that only in one of the 6 cases tested (a= 101, b = 101 and N= 1000), the subflattening method works worse. Similar to the analysis done in Tables 5.1 and 5.2, the Erik+2 method gives a similar percentage of success than the SVD method in most scenarios. In this case, when using this methods as some 41
rows and columns need to be discarded, the information retained decreases. If we now analyse the Fourier Normalization method, we only observe a decrease in success of 4,6% compared to the SVD method, and 2,5% compared to the subflattening method. This fact is important, since we are only computing the rank of a 4 ×4 matrix, instead of computing the rank of a 16 ×16 matrix. This tells us, that the Fourier Normalization model is useful when working with large K81 phylogenetic trees. The previous results are shown in the following graphics: (a) N= 1000 (b) N= 10000 Figure 5.3: Bar graphs representing the results for the K81 model. Taking into account the various tested scenarios, it is evident that when using general Markov model or K81 DNA alignments of length N= 10000 the subflattening method performs equal to the SVD method. When analysing the corresponding N= 1000 alignments, it can be seen that in 3 cases (a= 55, b = 55 and a= 105, b = 105 in the GMM and a= 101, b = 101 in the K81 model) the subflattening method presents an overall 7,5% less of success regarding the SVD method. But in 2 other scenarios (a= 15, b = 101 in the GMM and a= 21, b = 101 in the K81 method) the subflattening method performs a 17% better than the SVD method. Furthermore, the triplet of scores for each method are depicted in a ternary plot to assess the accuracy, see Figure 5.4. This ternary plot consist of a triangle, the vertices of which are indexed by T12|34, T13|24, T14|23. Each point represents the barycentric coordinates of the scores as computed before. Therefore, for a given reconstruction method, the closer a point is to a vertex, the clearer is the choice of the corresponding topology according to that method. Upon analyzing the various ternary plots, it becomes evident that the points associated with the SVD method are clustered or in close proximity to each other. However, this clustering does not necessarily indicate a high level of precision with respect to the correct result. In contrast, when employing the subflattening method, although the points are more dispersed, they are closer to the correct result. Additionally, the points obtained with the Erik+2 method exhibit significant clustering but are less closer to the T12|34 vertex. Finally, we can see that the points obtained with 42
the Fourier Normalization, although they are more spread out, they still lie symmetrically around the angle bisector. From the plots we note that the four methods are unbiased. An illustration of this scenario can be observed in Figure 5.4. (a) SVD method (b) Subflattening (c) Erik+2 (d) Fourier Normalization Figure 5.4: Ternary plots produced with alignments generated under the general Markov model with N=10000, a= 55 and b= 55. Finally, we present a table where the success percentage of the different methods can be observed using a random Smatrix. Similarity matrix Subflattenings Fourier Normalization S=Ü1 0 −1 1 −1−111 0−2−2 1 1−2−2 1ê59 49 S=Ü−360 676 −266 1 −55 −424 −694 1 307 −726 139 1 60 −738 988 1ê45 61 Table 5.5: % of success of the different methods tested in alignments generated under the general Markov model with a= 15, b = 101 and N=1000. 43
Similarity Matrix Subflattenings Fourier Normalization S=Ü4−16 −21 1 91 63 31 1 85 68 29 1 0−5−15 1ê53 82 S=Ü−5 0 −2 1 −5 2 3 1 3 4 −2 1 2−1−2 1ê60 78 Table 5.6: % of success of the different methods tested in alignments generated under the K81 model with a= 101, b = 101 and N=1000. If we analyze the results from Tables 5.5 and 5.6, in contrast to Tables 5.1 and 5.3, we can observe that using a random Smatrix decreases the efficiency of the subflattening method compared to using the Hmatrix as S. However, there are no significant changes (and even a slight improvement) when considering a random matrix Sin the case of the Fourier Normalization method results. This last observation is normal in the case of alignments generated under the general Markov model, as this method is motivated by theoretical considerations of the K81 model, regardless of the chosen matrix S. However, it is more surprising when considering the alignments generated under the K81 model. Perhaps, as we are dealing with a matrix of small dimensions and a relatively short alignment, the loss of information can cause these differences. 5.2 Performance on trees with random branches We have also examined various 4-leaf tree alignments obtained from trees with random branch length. We have used two intervals (0,1) and (0,3) to randomly choose the branch lengths. Branch lengths SVD Subflattenings Erik+2 Fourier Normalization (0,1) 93.98 93,91 89,13 85,19 (0,3) 64,68 57,49 60,68 59,59 Table 5.7: % of success of the different methods tested in 2 different scenarios. The alignments have been generated under the general Markov model with random branch length and the alignment length is N=1000. Branch lengths SVD Subflattenings Erik+2 Fourier Normalization (0,1) 97,97 98,19 96,99 86,08 (0,3) 77,61 72,19 79,56 65,03 Table 5.8: % of success of the different methods tested in 2 different scenarios. The alignments have been generated under the general Markov model with random branch length and the alignment length is N=10000. 44
Let us start analysing Tables 5.7 and 5.8. When using DNA alignments obtained from a quartet tree with random branch lengths, we can see that using the SVD method is slightly better than using the subflattening method, since the percentage of success is 4,22 % higher. When the branch lengths are chosen randomly from the interval (0,1), one can see that both SVD and subflattening methods perform similar when. But if we use the interval (0,3), the subflattening method success decreases a 6,31% in respect to the SVD method. This difference is due to the fact that trees with higher branch length distances are less balanced and make the reconstruction methods more difficult. Even though the performance of the SVD method seems better, as approximating the rank of the subflattening matrices requires less calculations, when analysing large trees, this method could be useful to simplify the process. Moreover it is clear to see that the success of the Erik+2 method is similar to the SVD (overall a 1,98% of success difference can be observed). The Fourier Normalization model does not have a good precision. Even so, it is the expected result since we are working with alignments obtained from a general Markov model, instead of alignments from a K81 model. The previous results are shown in the following graphics: (a) N= 1000 (b) N= 10000 Figure 5.5: Bar graphs representing the results for the general Markov model with random branches lengths. 45
Chapter 6 Discussion and conclusions Throughout this project we have reviewed how several algebraic tools can indeed be used in phylogenetics. More precisely, we have deeply studied how subflattening matrices can reduce the dimensionality of traditional models from exponential to quadratic in the number of species considered. Moreover, we have studied which form takes the subflattening matrices in the Kimura 3-parameter model. Finally, we have tested different reconstruction methods on a wide range of simulated data to see how some theoretical methods perform in practice. At the end of the project, we have successfully fulfilled the following: (i). Understand and study evolutionary models from a mathematical point of view, with special emphasis in the Kimura 3-parameter model. More specifically, we focus on the Theorems 2.7 and 2.10 as our key-stones and the use of tools from linear algebra and numerical linear algebra for phylogenetic inference. Throughout bibliographic research we have read and understood different articles and papers that use phylogenetic trees to model the evolution of species, see [3], [7] and [13] among others. We have also learnt about phylogenetic invariants, what they are and some of their uses, see [1]. In particular, we have devoted some time to understand the biology behind the Kimura 3-parameter model. (ii). Use multilinear algebra techniques as a tool to obtain dimensional reduction of the flattening matrices. We have analysed how phylogenetic invariants offer the possibility of reducing the high dimensionality of phylogenetic models from exponential in the number of present-day species to a one-dimensional subspace spanned by single polynomials. We have reviewed the idea of subflattenings and have proved how these matrices preserve the rank information needed for phylogenetic reconstruction, see Theorem 2.22. (iii). Understand the uses of subflattening matrices in the K81 model. We have seen how introducing matrix Has the similarity transformation S, simplifies the entries of the flattening and subflattening matrices. We have proved Theorem 2.22 for the specific case of the K81 model, and we have studied leaves marginalizations to give a better understanding of the process of taking subflattenings and to give a faster way of constructing these matrices. (iv). Test several theoretical phylogenetic reconstruction methods and see how they perform on simulated data. If we analyse the results obtained testing the different reconstructions methods, see Chapter 5, we can obtain several conclusions. 46
•One of the first conclusions that can be derived in the different scenarios is that if we increase the length Nof the alignment DNA sequences, the percentage of success increases too. Since more data becomes available the accuracy of the methods is improved. •We can conclude that subflattenings are more sensitive to the amount of available data than flattenings. We have observed that they are sensitive to alignment length as well as branch length. However, for specific data close to the K81 model, the subflattening method performs better. It seems that in the Felsenstein zone, the subflattening method works better. With all this analysis we can assure that using the subflattening method is appropriate if we want to reconstruct large phylogenetic trees because the percentage of correctness is acceptable and less calculations are needed to obtain the rank approximation. •We have also shown the sensibility of the subflattening method to the choice of S. It has been seen that the success of the subflattening method in some cases lowers at 45%, if we do not use Has the similarity matrix S. This shows that there exists a dependence between the success of the subflattening method and the matrix S. It seems natural that for the Fourier basis the performance improves. •Finally, we have seen that the method called Fourier Normalization does not work properly for a general Markov model alignment since this method is motivated by theoretical considerations of the K81 model which are not satisfied by the general Markov model. On the other hand, the Fourier Normalization model works better when using K81 alignments. This phenomenon is an important fact, since we have reduced the dimensionality of the matrix needed for phylogenetic reconstruction from a 16 ×16 matrix to a 4 ×4 matrix, a matrix whose dimensions are linear on the number of present-day species. Therefore, throughout the work we have theoretically proved why the reduction of dimensionality taking subflattenings works, and practically tested that this method works well with simulated data. Moreover, we have seen that the new implemented Fourier Normalization method works properly when analysing K81 alignments. As the results obtained in this project are satisfactory, it is compelling to explore this study further in future research. Some aspects, which could not be addressed in this project due to leak of time, are designated for future work: •Investigate the subflattening matrices and Theorem 2.22 for an arbitrary number of molecular states. In particular, we would like to explore the performance of the subflattening method applied to amino acids instead of DNA nucleotides. •Explore in broader scenarios the performance of the subflattening matrices and its convenience to detect phylogenetic signal. This exploration (for nucleotide or otherwise) can be addressed varying the substitution model, the length of the alignments, the branch length of the tree or applying the method to real biological data. •Investigate whether the Fourier Normalization can be extended to general Markov model alignments. 47
Bibliography [1] Elizabeth S. Allman and John A. Rhodes. Phylogenetic invariants for the general markov model of sequence mutation. Mathematical Biosciences, 186(2):113–144, 2003. [2] M. Casanellas. El modelo evolutivo de kimura, un enlace entre el ´algebra, la biolog´ıa i la estad´ıstica. La Gaceta de la Real Sociedad Matem´atica Espa˜nola, 21(2):241–257, 6 2018. [3] Marta Casanellas. Algebraic tools for evolutionary biology. Mathematical Society, 12, 2012. [4] Marta Casanellas and Anna M. Kedzierska. Generating markov evolutionary matrices for a given branch length. Linear Algebra and its Applications, 438(5):2484–2499, 2013. [5] Marta Casanellas and Seth Sullivant. The strand symmetric model. Algebraic Statistics for Computational Biology, 08 2005. [6] James A Cavender and Joseph Felsenstein. Invariants of phylogenies in a simple case with discrete states. Journal of classification, 4:57–71, 1987. [7] Gustavo Cilleruelo Calder´on. Phylogenetic reconstruction based on algebra. PhD thesis, UPC, Facultat de Matem`atiques i Estad´ıstica, Departament de Matem`atiques, 2019. [8] Mart´ı Cortada and Adri`a Di´eguez. Alignment to frequencies. https://github.com/ adriadieguez/TFG/blob/main/align_to_freq.py, 2023. [9] Charles Darwin. On the origin of species, 1859. Routledge, 2004. [10] Carl Eckart and Gale Young. The approximation of one matrix by another of lower rank. Psychometrika, 1(3):211–218, 1936. [11] Felsenstein, Joe. Phylogeny methods i (parsimony and such). https://evolution.gs. washington.edu/gs541/2010/lecture1.pdf, 2022. [Online; accessed 18-March-2023]. [12] Jes´us Fern´andez-S´anchez and Marta Casanellas. Invariant Versus Classical Quartet Inference When Evolution is Heterogeneous Across Sites and Lineages. Systematic Biology, 65(2):280– 291, 11 2015. [13] Thomas R Hagedorn. A combinatorial approach to determining phylogenetic invariants for the general model. CRM-2671, 2000. [14] Thomas H Jukes, Charles R Cantor, et al. Evolution of protein molecules. Mammalian protein metabolism, 3:21–132, 1969. [15] Anna M Kedzierska and Marta Casanellas. Gennon-h: Generating multiple sequence alignments on nonhomogeneous phylogenetic trees. BMC bioinformatics, 13(1):1–4, 2012. 48
[16] Motoo Kimura. Estimation of evolutionary distances between homologous nucleotide sequences. Proceedings of the National Academy of Sciences, 78(1):454–458, 1981. [17] James A Lake. A rate-independent technique for analysis of nucleic acid sequences: evolutionary parsimony. Molecular biology and evolution, 4(2):167–191, 1987. [18] Jandre Snyman, Colin Fox, and David Bryant. Parsimony and the rank of a flattening matrix. Journal of Mathematical Biology, 86(3):44, 2023. [19] Bernd Sturmfels and Seth Sullivant. Toric ideals of phylogenetic invariants. Journal of Computational Biology, 12(2):204–228, 2005. PMID: 15767777. [20] Jeremy G Sumner. Dimensional reduction for the general markov model on phylogenetic trees. Bulletin of mathematical biology, 79(3):619–634, 2017. [21] J.G. Sumner, M.A. Charleston, L.S. Jermiin, and P.D. Jarvis. Markov invariants, plethysms, and phylogenetics. Journal of Theoretical Biology, 253(3):601–615, 2008. 49
Appendix In this chapter, we present the Python code that implements the different reconstruction methods presented in Chapter 4: SVD, the reconstruction based on the subflattening matrices, the Erik+2 method and the Fourier Normalization method. [ ]: #Let us start importing the packages needed import sys from collections import Counter from Bio import SeqIO import itertools import numpy as np import os; import math #Let us create the vectors with the needed data to draw the graphics #SVD data Tree_12_34 =[] Tree_13_24 =[] Tree_14_23 =[] #Subflattening data TTree_12_34 =[] TTree_13_24 =[] TTree_14_23 =[] #Erik+2 data Erik2Tree_12_34 =[] Erik2Tree_13_24 =[] Erik2Tree_14_23 =[] #Fourier normalization data FNTree_12_34 =[] FNTree_13_24 =[] FNTree_14_23 =[] Hits_Flattening = 0 Hits_SubFlattening = 0 Hits_Erik2 = 0 Hits_FN = 0 #READ THE FASTA FILES for iin range(99): os.chdir(’/Users/aidacunill/’) sequences =[i for iin SeqIO.parse(f"length10000_a15_b101_num{i}.fa",’fasta’)] # Read sequences n_sequences =len(sequences) # Number of sequences len_sequence =len(sequences[0].seq) # Length of sequences v=[] for iin range (len_sequence): 50
[Freq[’TGAT’],Freq[’TGCT’],Freq[’TGGT’],Freq[’TGTA’],Freq[’TGTC’], Freq[’TGTG’],Freq[’TGTT’]], [Freq[’TTAT’],Freq[’TTCT’],Freq[’TTGT’],Freq[’TTTA’],Freq[’TTTC’], Freq[’TTTG’],Freq[’TTTT’]]] SubFlat13_24 =[[Freq[’AATT’],Freq[’ACTT’],Freq[’AGTT’],Freq[’ATTA’],Freq[’ATTC’], Freq[’ATTG’],Freq[’ATTT’]], [Freq[’CATT’],Freq[’CCTT’],Freq[’CGTT’],Freq[’CTTA’],Freq[’CTTC’], Freq[’CTTG’],Freq[’CTTT’]], [Freq[’GATT’],Freq[’GCTT’],Freq[’GGTT’],Freq[’GTTA’],Freq[’GTTC’], Freq[’GTTG’],Freq[’GTTT’]], [Freq[’TAAT’],Freq[’TCAT’],Freq[’TGAT’],Freq[’TTAA’],Freq[’TTAC’], Freq[’TTAG’],Freq[’TTAT’]], [Freq[’TACT’],Freq[’TCCT’],Freq[’TGCT’],Freq[’TTCA’],Freq[’TTCC’], Freq[’TTCG’],Freq[’TTCT’]], [Freq[’TAGT’],Freq[’TCGT’],Freq[’TGGT’],Freq[’TTGA’],Freq[’TTGC’], Freq[’TTGG’],Freq[’TTGT’]], [Freq[’TATT’],Freq[’TCTT’],Freq[’TGTT’],Freq[’TTTA’],Freq[’TTTC’], Freq[’TTTG’],Freq[’TTTT’]]] SubFlat14_23 =[[Freq[’AATT’],Freq[’ACTT’],Freq[’AGTT’],Freq[’ATAT’],Freq[’ATCT’], Freq[’ATGT’],Freq[’ATTT’]], [Freq[’CATT’],Freq[’CCTT’],Freq[’CGTT’],Freq[’CTAT’],Freq[’CTCT’], Freq[’CTGT’],Freq[’CTTT’]], [Freq[’GATT’],Freq[’GCTT’],Freq[’GGTT’],Freq[’GTAT’],Freq[’GTCT’], Freq[’GTGT’],Freq[’GTTT’]], [Freq[’TATA’],Freq[’TCTA’],Freq[’TGTA’],Freq[’TTAA’],Freq[’TTCA’], Freq[’TTGA’],Freq[’TTTA’]], [Freq[’TATC’],Freq[’TCTC’],Freq[’TGTC’],Freq[’TTAC’],Freq[’TTCC’], Freq[’TTGC’],Freq[’TTTC’]], [Freq[’TATG’],Freq[’TCTG’],Freq[’TGTG’],Freq[’TTAG’],Freq[’TTCG’], Freq[’TTGG’],Freq[’TTTG’]], [Freq[’TATT’],Freq[’TCTT’],Freq[’TGTT’],Freq[’TTAT’],Freq[’TTCT’], Freq[’TTGT’],Freq[’TTTT’]]] #Let us now compute the svd U11, svd_11, Vt11 =np.linalg.svd (SubFlat12_34, full_matrices =False) U22, svd_22, Vt22 =np.linalg.svd (SubFlat13_24, full_matrices =False) U33, svd_33, Vt33 =np.linalg.svd (SubFlat14_23, full_matrices =False) s_11 =math.sqrt(svd_11[4]**2+svd_11[5]**2+svd_11[6]**2) s_22 =math.sqrt(svd_22[4]**2+svd_22[5]**2+svd_22[6]**2) s_33 =math.sqrt(svd_33[4]**2+svd_33[5]**2+svd_33[6]**2) r_11= 1/s_11 r_22 = 1/s_22 r_33=1/s_33 SSuma =r_11+r_22+r_33 R11 =r_11/SSuma R22 =r_22/SSuma R33 =r_33/SSuma TTree_12_34.append(R11) TTree_13_24.append(R22) TTree_14_23.append(R33) 57
#Let us see if the result is correct if R11 >R22 and R11 >R33: Hits_SubFlattening += 1 ##ERIK+2 FlatRows12_34 =np.array(Flat12_34) FlatRows13_24 =np.array(Flat13_24) FlatRows14_23 =np.array(Flat14_23) FlatColumns12_34 =np.array(Flat12_34) FlatColumns13_24 =np.array(Flat13_24) FlatColumns14_23 =np.array(Flat14_23) #if the sum <3/N , we will erase the corresponding row or column to avoid bias. for iin range(16): if sum(Flat12_34[i]) > 2/len_sequence: FlatRows12_34[i]=FlatRows12_34[i]/sum(Flat12_34[i]) else: np.delete(FlatRows12_34,i,axis=0) for iin range(16): if sum(Flat13_24[i]) > 2/len_sequence: FlatRows13_24[i]=FlatRows13_24[i]/sum(Flat13_24[i]) else: np.delete(FlatRows13_24,i,axis=0) for iin range(16): if sum(Flat14_23[i]) > 2/len_sequence: FlatRows14_23[i]=FlatRows14_23[i]/sum(Flat14_23[i]) else: np.delete(FlatRows12_34,i,axis=0) for iin range(16): if sum(fila[i] for fila in Flat12_34) > 2/len_sequence: FlatColumns12_34[:,i] =FlatColumns12_34[:,i]/sum(fila[i] for fila in Flat12_34) else: np.delete(FlatColumns12_34,i,axis=1) for iin range(16): if sum(fila[i] for fila in Flat13_24) > 2/len_sequence: FlatColumns13_24[:,i] =FlatColumns13_24[:,i]/sum(fila[i] for fila in Flat13_24) else: np.delete(FlatColumns13_24,i,axis=1) for iin range(16): if sum(fila[i] for fila in Flat14_23) > 2/len_sequence: FlatColumns14_23[:,i] =FlatColumns14_23[:,i]/sum(fila[i] for fila in Flat14_23) else: np.delete(FlatColumns14_23,i,axis=1) #Let us compute the svd UErikr1, svdErikr_1, VtErikr1 =np.linalg.svd (FlatRows12_34, full_matrices =False) UErikr2, svdErikr_2, VtErikr2 =np.linalg.svd (FlatRows13_24, full_matrices =False) UErikr3, svdErikr_3, VtErikr3 =np.linalg.svd (FlatRows14_23, full_matrices =False) 58
sum1=0 sum2=0 sum3=0 for iin range(4,np.shape(svdErikr_1)[0]): sum1 += svdErikr_1[i]**2 sErikr_1 =math.sqrt(sum1) for iin range(4,np.shape(svdErikr_2)[0]): sum2 += svdErikr_2[i]**2 sErikr_2 =math.sqrt(sum2) for iin range(4,np.shape(svdErikr_3)[0]): sum3 += svdErikr_3[i]**2 sErikr_3 =math.sqrt(sum3) UErikc1, svdErikc_1, VtErikc1 =np.linalg.svd (FlatColumns12_34, full_matrices =False) UErikc2, svdErikc_2, VtErikc2 =np.linalg.svd (FlatColumns13_24, full_matrices =False) UErikc3, svdErikc_3, VtErikc3 =np.linalg.svd (FlatColumns14_23, full_matrices =False) sumc1=0 sumc2=0 sumc3=0 for iin range(4,np.shape(svdErikc_1)[0]): sumc1 += svdErikc_1[i]**2 sErikc_1 =math.sqrt(sumc1) for iin range(4,np.shape(svdErikc_2)[0]): sumc2 += svdErikc_2[i]**2 sErikc_2 =math.sqrt(sumc2) for iin range(4,np.shape(svdErikc_3)[0]): sumc3 += svdErikc_3[i]**2 sErikc_3 =math.sqrt(sumc3) sErik2_1 =(sErikr_1 +sErikc_1)/2 sErik2_2 =(sErikr_2 +sErikc_2)/2 sErik2_3 =(sErikr_3 +sErikc_3)/2 rErik2_1 = 1/sErik2_1 rErik2_2 = 1/sErik2_2 rErik2_3 = 1/sErik2_3 sumaErik2 =rErik2_1 +rErik2_1 +rErik2_1 RErik2_1 =rErik2_1/sumaErik2 RErik2_2 =rErik2_2/sumaErik2 RErik2_3 =rErik2_3/sumaErik2 Erik2Tree_12_34.append(RErik2_1) 59
Erik2Tree_13_24.append(RErik2_2) Erik2Tree_14_23.append(RErik2_3) if RErik2_1 >RErik2_2 and RErik2_1 >RErik2_3: Hits_Erik2 += 1 ##FOURIER NORMALIZATION sumRows_1 =[] for iin range(16): sumRows_1.append(sum(Flat12_34[i])) sumRows_2 =[] for iin range(16): sumRows_2.append(sum(Flat13_24[i])) sumRows_3 =[] for iin range(16): sumRows_3.append(sum(Flat14_23[i])) MatRows_1 =np.matmul(np.kron(St,St),sumRows_1) MatRows_2 =np.matmul(np.kron(St,St),sumRows_2) MatRows_3 =np.matmul(np.kron(St,St),sumRows_3) sumColumns_1 =[] for iin range(16): sumColumns_1.append(sum(fila[i] for fila in Flat12_34)) sumColumns_2 =[] for iin range(16): sumColumns_2.append(sum(fila[i] for fila in Flat13_24)) sumColumns_3 =[] for iin range(16): sumColumns_3.append(sum(fila[i] for fila in Flat14_23)) MatColumns_1 =np.matmul(np.kron(St,St),sumColumns_1) MatColumns_2 =np.matmul(np.kron(St,St),sumColumns_2) MatColumns_3 =np.matmul(np.kron(St,St),sumColumns_3) #Let us perfrom the Block_A submatrix Block_A_12_34 =[[Freq[’AAAA’],Freq[’AACC’],Freq[’AAGG’],Freq[’AATT’]], [Freq[’CCAA’],Freq[’CCCC’],Freq[’CCGG’],Freq[’CCTT’]], [Freq[’GGAA’],Freq[’GGCC’],Freq[’GGGG’],Freq[’GGTT’]], [Freq[’TTAA’],Freq[’TTCC’],Freq[’TTGG’],Freq[’TTTT’]]] Block_A_13_24 =[[Freq[’AAAA’],Freq[’ACAC’],Freq[’AGAG’],Freq[’ATAT’]], [Freq[’CACA’],Freq[’CCCC’],Freq[’CGCG’],Freq[’CTCT’]], [Freq[’GAGA’],Freq[’GCGC’],Freq[’GGGG’],Freq[’GTGT’]], [Freq[’TATA’],Freq[’TCTC’],Freq[’TGTG’],Freq[’TTTT’]]] Block_A_14_23 =[[Freq[’AAAA’],Freq[’ACCA’],Freq[’AGGA’],Freq[’ATTA’]], [Freq[’CAAC’],Freq[’CCCC’],Freq[’CGGC’],Freq[’CTTC’]], [Freq[’GAAG’],Freq[’GCCG’],Freq[’GGGG’],Freq[’GTTG’]], [Freq[’TAAT’],Freq[’TCCT’],Freq[’TGGT’],Freq[’TTTT’]]] 60
MatRows_1 =[MatRows_1[0],MatRows_1[5], MatRows_1[10], MatRows_1[15]] MatRows_2 =[MatRows_2[0],MatRows_2[5], MatRows_2[10], MatRows_2[15]] MatRows_3 =[MatRows_3[0],MatRows_3[5], MatRows_3[10], MatRows_3[15]] MatColumns_1 =[MatColumns_1[0], MatColumns_1[5], MatColumns_1[10], MatColumns_1[15]] MatColumns_2 =[MatColumns_2[0], MatColumns_2[5], MatColumns_2[10], MatColumns_2[15]] MatColumns_3 =[MatColumns_3[0], MatColumns_3[5], MatColumns_3[10], MatColumns_3[15]] for iin range(4): if MatRows_1[i] == 0: np.delete(Block_A_12_34,i,axis = 0) np.delete(MatRows_1,i) else: MatRows_1[i] = 1/MatRows_1[i] for iin range(4): if MatRows_2[i] == 0: np.delete(Block_A_13_24,i,axis = 0) np.delete(MatRows_2,i) else: MatRows_2[i] = 1/MatRows_2[i] for iin range(4): if MatRows_3[i] == 0: np.delete(Block_A_14_23,i,axis = 0) np.delete(MatRows_3,i) else: MatRows_3[i] = 1/MatRows_3[i] for iin range(4): if MatColumns_1[i] == 0: np.delete(Block_A_12_34,i,axis = 1) np.delete(MatColumns_1,i) else: MatColumns_1[i] = 1/MatColumns_1[i] for iin range(4): if MatColumns_2[i] == 0: np.delete(Block_A_13_24,i,axis = 1) np.delete(MatColumns_2,i) else: MatColumns_2[i] = 1/MatColumns_2[i] for iin range(4): if MatColumns_3[i] == 0: np.delete(Block_A_14_23,i,axis = 1) np.delete(MatColumns_3,i) else: MatColumns_3[i] = 1/MatColumns_3[i] MC1 =np.diag(MatColumns_1) MC2 =np.diag(MatColumns_2) MC3 =np.diag(MatColumns_3) MR1 =np.diag(MatRows_1) MR2 =np.diag(MatRows_2) MR3 =np.diag(MatRows_3) 61
FN12_34 =np.matmul(np.matmul(MR1,Block_A_12_34),MC1) FN13_24 =np.matmul(np.matmul(MR2,Block_A_13_24),MC2) FN14_23 =np.matmul(np.matmul(MR3,Block_A_14_23),MC3) #Let us compute the svd sumFN_1 = 0 sumFN_2 = 0 sumFN_3 = 0 UFN1, svdFN_1, VtFN1 =np.linalg.svd (FN12_34, full_matrices =False) UFN2, svdFN_2, VtFN2 =np.linalg.svd (FN13_24, full_matrices =False) UFN3, svdFN_3, VtFN3 =np.linalg.svd (FN14_23, full_matrices =False) for iin range(1,np.shape(svdFN_1)[0]): sumFN_1 += svdFN_1[i]**2 sFN_1 =math.sqrt(sumFN_1) for iin range(1,np.shape(svdFN_2)[0]): sumFN_2 += svdFN_2[i]**2 sFN_2 =math.sqrt(sumFN_2) for iin range(1,np.shape(svdFN_3)[0]): sumFN_3 += svdFN_3[i]**2 sFN_3 =math.sqrt(sumFN_3) rFN_1= 1/sFN_1 rFN_2 = 1/sFN_2 rFN_3=1/sFN_3 sumaFN =rFN_1+rFN_2+rFN_3 RFN1 =rFN_1/sumaFN RFN2 =rFN_2/sumaFN RFN3 =rFN_3/sumaFN FNTree_12_34.append(RFN1) FNTree_13_24.append(RFN2) FNTree_14_23.append(RFN3) if RFN1 >RFN2 and RFN1 >RFN3: Hits_FN += 1 #PERCENTAGE OF SUCCESS print("Success by SVD:") print(Hits_Flattening) print("Success by Subflattenings:") print(Hits_SubFlattening) print("Success by Erik+2:") print(Hits_Erik2) print("Success by Fourier Normalization:") print(Hits_FN) 62
#CENTER OF GRAVITY CenterOfGravity_SVD =[sum(Tree_13_24)/100,sum(Tree_12_34)/100,sum(Tree_14_23)/100] CenterOfGravity_Subflattening =[sum(TTree_13_24)/100,sum(TTree_12_34)/100,sum(TTree_14_23)/100] CenterOfGravity_Erik2 =[sum(Erik2Tree_13_24)/100,sum(Erik2Tree_12_34)/100,sum(Erik2Tree_14_23)/ ,→100] CenterOfGravity_Fourier =[sum(FNTree_13_24)/100,sum(FNTree_12_34)/100,sum(FNTree_14_23)/100] print("Center of gravity with SVD:") print(CenterOfGravity_SVD) print("Center of gravity with Sublattenings:") print(CenterOfGravity_Subflattening) print("Center of gravity with Erik+2:") print(CenterOfGravity_Erik2) print("Center of gravity with Fourier Normalization:") print(CenterOfGravity_Fourier) 63