Efficient Approaches to the Mixture Distance Problem

The ancestral mixture model, an important model building a hierarchical tree from high dimensional binary sequences, was proposed by Chen and Lindsay in 2006. As a phylogenetic tree (or evolutionary tree), a mixture tree created from ancestral mixture models, involves the inferred evolutionary relationships among various biological species. Moreover, it contains the information of time when the species mutates. The tree comparison metric, an essential issue in bioinformatics, is used to measure the similarity between trees. To our knowledge, however, the approach to the comparison between two mixture trees is still unknown. In this paper, we propose a new metric named the mixture distance metric, to measure the similarity of two mixture trees. It uniquely considers the factor of evolutionary times between trees. If we convert the mixture tree that contains the information of mutation time of each internal node into a weighted tree, the mixture distance metric is very close to the weighted path difference distance metric. Since the converted mixture tree forms a special weighted tree, we were able to design a more efficient algorithm to calculate this new metric. Therefore, we developed two algorithms to compute the mixture distance between two mixture trees. One requires O(n2) and the other requires O(nh1h2) computational time with O(n) preprocessing time, where n denotes the number of leaves in the two mixture trees, and h1 and h2 denote the heights of these two trees.


Introduction
Phylogeny reconstruction involves reconstructing the evolutionary relationship from biological sequences among species. Nowadays it has become a critical issue in molecular biology and bioinformatics. Several existing methods, such as neighbor-joining methods [1] and maximum likelihood methods [2], have been proposed to reconstruct a phylogenetic tree. A novel and natural method, ancestral mixture models [3], was developed by Chen and Lindsay to deal with such a problem. The mixture tree, a hierarchical tree created from the ancestral mixture model, induces a sieve parameter to represent the evolutionary time. Chen, Rosenberg and Lindsay (2011) then developed MixtureTree algorithm [4], a linux based program written in C++, which employed the ancestral mixture models to reconstruct mixture tree from DNA sequences. With the information provided by the mixture tree, one can identify when and how a mutation event of species occurs. An example of the mixture tree created by MixtureTree algorithm [3] is shown in Figure 1. The data from Griffiths and Tavare (1994) [5] are a subset of the mitochondrial DNA sequences which first appeared in Ward et al. (1991) [6]. To study the mitochondrial diversity within the Nuu-Chuah-Nulth, an Amerindian tribe from Vancouver Island, Ward et al. (1991) [6] sequenced 360 nucleotide segments of the mitochondrial control region for 63 individuals from the Nuu-Chuah-Nulth. Griffiths' and Tavares' subsample consisted of 55 of the 63 distinct sequences and 18 segregating sites, including 13 pyrimidines (C, T ) and five purines (A, G). Each linage represents a distinct sequence-that is, there are lineages a through n. The time scale on the tree can be represented by − log(1 − 2p), where p is a parameter, the mutation rate. The number on the tree represents the site of the lineage whereat the mutation occurs. For example, when p = 0.01, lineages e and f merge because mutation occurs at site 5 of lineage f . Distinct methods may produce distinct trees, even though the methods adopt an identical dataset [7]. To uncover a well-represented tree involved in evolutionary relationship among species it is quite important to estimate how similar (or different) trees are. The tree distance between two trees is a general measurement for the similarity of the trees.
The tree distance problem is a traditional issue in mathematics. Several metrics have been proposed to measure the similarity between two trees, such as the partition metric (also called the Robison-Foulds metric or RF distance for short) [8], the quartet metric [9], the nearest neighbour interchange metric [10] and the nodal distance metric [11]. Those metrics all compare two trees by considering the tree structure only, and do not mention any parameter in the tree. Thus, those metrics are not suitable for computing the similarity between two mixture trees. Therefore, we propose a novel metric named the mixture distance metric to measure the similarity of two mixture trees in this paper. Among the above metrics, the metric from the nodal distance algorithm is similar to our proposed metric. In 2003, John Bluis and Dong-Guk Shin [11] presented the nodal distance algorithm which is used to measure the distances from leaves to all other leaves in a tree. The metric is defined as follows: denotes the distance of leaf x to leaf y in the tree T i . The nodal distance algorithm was developed for this metric. Anyway, using this metric to measure the distance between two mixture trees is not conformable.
For the metric of the mixture distance, the time parameter indicating when a mutation event of species occurs plays an important role in the tree similarity, which is, however, not considered by those previous metrics. If the weight of an edge in a mixture tree is defined as the difference in time parameters between its two endpoints, a mixture tree can be regarded as a weighted tree. We can design metrics to calculate the distance between two weighted trees. Some literature discusses the distance problem between two weighted trees. For example, take the weighted RF metric [12], geodesic distance [13] and the path difference metric [14]. However, the weight on each edge is considered to be the number of base changes between the sequences of the species represented by its incident vertices in these documents. Since the weights of each edge in those weighted trees may be different, the algorithm must spend more time to calculate those distances between those two weighted trees. For example, although there is an linear time algorithm to compute RF distance [15], and a randomized algorithm has been shown to approximate the RF distance with a bounded error in sublinear time [16], the complexity of the weighted RF distance still needs O(n 2 ). Some papers have studied algorithms for calculating the geodesic trees distances [17][18][19]. The best one already known is O(n 4 ) [19]. Due to the characteristics of the time parameter of a mixture tree, any two edges connecting two leaves to the same parent will have the same "weight" in a mixture tree. This helped us to design a better metric and algorithm. We further developed two algorithms to compute the mixture distance between two mixture trees. One requires O(n 2 ) and the other requires O(nh 1 h 2 ) computational time with O(n) preprocessing time, where n denotes the number of leaves in these two mixture trees, and h 1 and h 2 denote the heights of these two trees. If we use the nodal distance algorithm with the mixture distance metric, the time complexity will be O(n 3 ) for binary unrooted trees. Comparisons with some previous methods show our method performs better.

Mixture Distance Metric
A tree T = (V(T), E(T)) is a connected and acyclic graph with a node set V(T) and an edge set E(T). T is a rooted tree if exactly one node of T has been designated the root. A node v ∈ V(T) is a leaf if it has no child; otherwise, v is an internal node. A node v ∈ V(T) is called in level i, denoted by level(v) = i, which means the number of edges on the path between the root and v is i. Let L(T) denote a subset of node set V(T), where each member is a leaf in T and n = |L(T)|. Let height(T) denote the height of tree T, which is max{level(v)|v ∈ L(T)}. T is a full binary tree if each node of T either has two children or it is a leaf. A complete binary tree is a full binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. Let For a mixture tree T, each leaf is associated with a species, and every internal node v is associated with a mutation time m T (v) that represents the time when a mutation event occurs on the species node. In fact, the mutation time of an internal node in a mixture tree can be regarded as the distance between the node and any leaf of its descendants. Any two mixture tress T 1 and T 2 are comparable if L(T 1 ) = L(T 2 ). Throughout this paper, a tree refers to a rooted full binary tree and each internal node of the tree is associated with its mutation time, if not mentioned particularly.
Given any two nodes u, v ∈ V(T), the least common ancestor or lowest common ancestor (abbreviated LCA) of u and v is an ancestor of both u and v with the smallest mutation time. (It is also called the most recent common ancestor (abbreviated MRCA), or the last common ancestor (abbreviated LCA) in biology and genealogy.) Let P T (u, v) denote the mutation time m T (w) of the LCA w of two leaves u and v in T. The mixture distance metric, a metric for the mixture tree, is formally defined as follows.
The mixture distance between two comparable mixture trees T 1 and T 2 , denoted by d m (T 1 , T 2 ), is defined as the sum of difference of the mutation times with respect to the LCAs of any two leaves in The significance of the mixture distance metric is to measure the similarity between two mixture trees, considering the mutation times (molecular clock) and mutation sites simultaneously. The study sought to develop two algorithms for efficiently computing the mixture distance between two comparable mixture trees. Before we go into the algorithms, three properties of the mixture distance matric are demonstrated. Felsenstein [20] derived three mathematical properties-reflexivity, symmetry and triangle inequality-required for a well-defined metric. We show that the mixture distance is well-defined in Theorem 1. 3. Triangle inequality: for any three comparable mixture trees T 1 , T 2 and T 3 , d m (T 1 , On the other hand, if d m (T 1 , T 2 ) = 0 for any two comparable mixture trees T 1 and T 2 . We have 3. The triangle inequality is always satisfied for any three nonnegative numbers a, b,

An O(nh 1 h 2 )-Time Algorithm
Let T 1 and T 2 denote two comparable mixture trees of n leaves for each tree. Note that the mixture distance of T 1 and T 2 can be solved in O(n 2 )-time: As when given two comparable mixture trees T 1 and T 2 each with n leaves, there are O(n 2 ) pairs of leaves separately in T 1 and T 2 . In fact, the LCA of any pair of leaves can be found by adopting the O(1)-time algorithm with O(n)-time preprocessing [21].
In the following, another O(n 2 )-time algorithm, named Algorithm MIXTUREDISTANCE, is proposed to compute the mixture distance between T 1 and T 2 , which will help us to realize the next O(nh 1 h 2 )-time algorithm, the main result.

Algorithm MixtureDistance
Algorithm MIXTUREDISTANCE, as shown on Algorithm 1, proceeds the nodes of T 1 by breadth-first search. For each internal node v in T 1 , we find out the leaves of T 1 such that v is exactly the LCA of each pair of leaves, and then compute the LCA u of the leaves in T 2 which are mapped into the found leaves of T 1 . Finally, the difference of the mutation times between u and v is calculated. For convenience, we define (a, b) * (c, d) = ad + bc for any two ordered pairs (a, b) and (c, d) in this algorithm, where a, b, c and d are any four integers.
The algorithm adopts a 2-coloring method [22] on the leaves in T 1 and T 2 for easy implementation. For each iteration associated with an internal node v of T 1 in line 4, the leaves of the left and right subtrees rooted by v are colored by red and green, respectively. The mapped leaves in T 2 have the same coloring as one in T 1 . The mixture distance between each internal node u in T 2 and v is calculated according the coloring scheme in T 2 (in lines [16][17], and the coloring information of u would be derived for the computation of its parent node (in line 18).
The coloring information of u, denoted by color(u), indicates the coloring information of the subtree in T 2 rooted by u. color(u) includes two numbers of u's descendant leaves colored by red (color(u)[0]) and green (color(u) [1]), respectively. color(u) is derived by the coloring information of its two children. That is, color(u)[0] = color(u L )[0] + color(u R )[0] and color(u) [1] = color(u L )[1] + color(u R ) [1], where u L and u R separately denote the left and right children of u in T 2 .

Algorithm 1: MIXTUREDISTANCE(T 1 , T 2 ).
Input: Two comparable mixture trees T 1 and T 2 , with mutation times m T 1 (v) (m T 2 (u), respectively) for every internal node v of T 1 (u of T 2 , respectively). Output: The mixture distance D between T 1 and T 2 . 1 D = 0. 2 Traverse T 1 by the breadth-first search from its root and keep a list I 1 of the internal nodes in order. 3 Traverse T 2 by the breadth-first search from its root and keep a list I 2 of the internal nodes in reverse order. 4 for each node v ∈ I 1 do 5 In T 1 , color red the leaves of the left subtree rooted by v and green the leaves of the right subtree rooted by v. 6 for each node u ∈ I 2 do // Initialize the coloring information of u's children 7 for each child w of u in T 2 do 8 if w is a leaf then 9 if w is colored by red in T 1 then 10 color(w) = (1, 0). 11 else if w is colored by green in T 1 then 12 color(w) = (0, 1). 13 else 14 color(w) = (0, 0). 15 Let u L and u R be the left and right children of u in T 2 , respectively. // Calculate the difference of the mutation times of u and v and sum them up for computing mixture distance 16 number(u) = color(u L ) * color(u R ).
// Calculate the coloring information of u 18 color(u) = color(u L ) + color(u R ).
In line 16, number(u) is achieved by the special product of the color vectors of u's two children, , which means the number of times that u is an LCA of a red leaf and a green leaf. We multiply the difference of their mutation times by number(u) in line 17, for computing the mixture distance between each internal node u in T 2 and v. At the end of Algorithm MIXTUREDISTANCE, D indicates the mixture distance of T 1 and T 2 .
Since the numbers of internal nodes in T 1 and T 2 (= I 1 and I 2 ) are both equal to n − 1, two for-loops will take O(n) time, and the innermost for-loop always takes 2 (a constant) time units. Therefore, Algorithm MIXTUREDISTANCE requires O(n 2 ) computational time.

Modified Algorithm
After introducing Algorithm MIXTUREDISTANCE, we can give a O(nh 1 h 2 ) computational time algorithm for computing the mixture distance between two mixture trees in the following part. In Algorithm MIXTUREDISTANCE, when the leaves of the subtree rooted by an internal node v in T 1 are colored, other leaves in T 1 have no color, as do the mapped leaves in T 2 . That is, color(w) = (0, 0) for w ∈ L(T 2 ). However, Algorithm MIXTUREDISTANCE still processes the ancestors of such leaves in T 2 . In the following, we propose an algorithm for disregarding the nodes without meaningful coloring information, and reduce the time complexity from O(n 2 ) to O(nh 1 h 2 ) .
The algorithm contains three main stages, as follows:

1.
Rank the leaves in T 1 and T 2 .

2.
Construct a minimal subtree T 2 of T 2 involved in colored leaves with respect to node v, for each internal node v in T 1 .

3.
Compute the mixture distance between v and each internal node in T 2 .
In stage 1, the nodes of T 2 are ranked in postorder, and the leaves of T 1 are assigned by the same rank of the mapped leaves in T 2 . In Figure 2, red numbers nearby leaves in two given comparable mixture trees T 1 and T 2 indicate the ranking achieved by stage 1 of the algorithm. Note that the number within the nodes means the mutation time m T i (v) of the associated node v for i = 1 or 2. The algorithm proceeds to stage 2 for each internal node v of T 1 in the reverse order of breadth-first search. When v in T 1 is processed, stage 2 seeks to construct a minimal subtree T 2 of T 2 involved in colored leaves with respect to node v. For node v, a nondecreasing list of the leaves of the subtree rooted by v, denoted by lea f (v), is obtained from the leaf lists of its two children, where the leaves in the list are sorted by their ranks. Suppose that there are k ordered nodes in lea f (v), that is, lea f (v) = {w 1 , w 2 , . . . , w k }. With the list lea f (v), the subtree T 2 can be constructed as follows.
Let lca(w i , w j ) denote the LCA of leaves w i and w j in T 2 , for any i, j ∈ {1, 2, . . . , k}. The subtree T 2 = (V , E ) is initialized by V = {w 1 , w 2 , lca(w 1 , w 2 )}, E = {lca(w 1 , w 2 )w 1 , lca(w 1 , w 2 )w 2 } and root = lca(w 1 , w 2 ) . For node w i , i ∈ {1, 2, . . . , k − 2}, Moreover, if the mutation time (the number written in the node circle) of lca(w i+1 , w i+2 ), denoted by t(lca(w i+1 , w i+2 )), is larger than the mutation time of root, denoted by t(root), the edge lca(w i+1 , w i+2 )root is inserted into E and reset lca(w i+1 , w i+2 ) as the new root. Otherwise, if t(lca(w i+1 , w i+2 )) is smaller than the mutation time of lca(w i , w i+1 ), denoted by t(lca(w i , w i+1 )), the edge lca(w i , w i+1 )w i+1 is removed from E and the edges lca(w i+1 , w i+2 )w i+1 and lca(w i , w i+1 )lca(w i+1 , w i+2 ) are inserted into E . Otherwise, let x = w i+1 and repeat do x = f ather(x) until t(x) < t(lca(w i+1 , w i+2 )) < t( f ather(x)), where f ather(x) is the node y such that yx ∈ E . Then the edge f ather(x)x is removed from E and the edges lca(w i+1 , w i+2 )x and f ather(x)lca(w i+1 , w i+2 ) are inserted into E . Example 1. An example of constructing the subtree T 2 with respect to lea f (v 2 ) = {A, B, G, H} is illustrated in Figure 3. Initially, the node set V is {A, B, lca(A, B)} and the edge set E includes the incident edges of the three nodes in T 2 . As node A is processed, two nodes lca(B, G) and G are inserted into V , and two edges lca(A, B)lca(B, G) and lca(B, G)G are inserted into E . Later, when node B is processed, two nodes lca(G, H) and H are inserted into V and two edges lca(B, G)lca(G, H) and lca(G, H)H are inserted into E . Meanwhile, the edge lca(B, G)G is removed from E and the edge lca(G, H)G is inserted into E , because the mutation time of lca(B, G) is larger than the time of the lca(G, H). After the subtree T 2 with respect to currently processed node v is constructed, stage 3 of the algorithm performs lines 5-18 of Algorithm MIXTUREDISTANCE to compute the "partial" mixture distance between T 2 and the subtree rooted by v (only computes the distances of some nodes pairs, for which LCA is equal to v). At the end of the algorithm, D indicates the mixture distance between T 1 and T 2 . Proof. The algorithm contains three main stages. The first stage ranks the leaves in T 1 and T 2 , which takes O(n) time.
In the second stage, a minimal subtree T 2 of T 2 involved in colored leaves with respect to each node v in T 1 is constructed. For each node v, a leaf list lea f (v) is obtained from the leaf lists of its two children, which is achieved in O(t) time by using the two-way merging algorithm [23] performed on the leaf list of v's children, where t is the size of lea f (v). The O(1)-time algorithm with O(n)-time processing [21] is employed to compute the LCA of any pair of nodes in T 2 . Constructing T 2 takes O(th ) time, where h is the height of T 2 due to the "repeat" step. The last stage computes the mixture distance between v and each internal node in T 2 by performing lines 5-18 of Algorithm MIXTUREDISTANCE, which takes O(t) time. Stages 2 and 3 take O(n) iterations in total. However, each iteration deals with different t nodes. Note that for all internal nodes which are in the same level of T 1 , the sum of t (for each node) is n. Therefore, stages 2 and 3 totally take O(nh 1 h ) = O(h 1 h 2 ) time, where h 1 is the height of T 1 (note that h ≤ h 2 = height(T 2 )). Hence, the algorithm requires O(nh 1 h 2 ) computational time with O(n) preprocessing time.

Conclusions
In this paper, we provide a novel metric named the mixture distance metric to measure the similarity between two mixture trees. It uniquely considers the estimated evolutionary time in the trees. Two algorithms were developed to compute the mixture distance between mixture trees. One requires O(n 2 ) computational time and the other requires O(nh 1 h 2 ) computational time with O(n) preprocessing time, respectively. Note that when T 1 and T 2 are complete binary trees, h 1 and h 2 will be O(log n) and the time complexity of our algorithm will be (n log 2 n). Now, we compare our metric with some previous methods which measure phylogenetic differences in consideration of the branch length, when we consider a mixture tree as a weighted tree (recall that the weight of an edge in a mixture tree is defined as the difference of time parameters between its two endpoints). For the geodesic tree distance, the implementation is quite complex and requires heavy computation [19], although a heuristic fast version exists [18]. The definition of the weighted path difference distance [14] is almost the same as the mixture distance. Actually, the weighted path difference distance between two mixture trees T 1 and T 2 is equal to 2d m (T 1 , T 2 ). However, it requires O(n 2 ) computational time. The mixture distance seems to be similar to the weighted RF distance [12], but the calculation performance will vary when we consider the distance between two different extents of similar mixture trees. We give an example as follows.

Example 2.
Four mixture trees with the same lineages A, B and C are illustrated in Figure 4; the time parameters are listed in the vertices, and the associated edge weights are labeled beside each edge. All pairs of these four trees have been compared using the methods outlined in [12] and this paper. The tables of the weighted RF (wRF) and mixture distances (d m ) are given in Tables 1 and 2, respectively. From these two tables, one can find something interesting. (1) d m seems maintain the order relationship in wRF: When wRF thinks that two trees are similar, then d m also gets a smaller value between these two trees: wRF(T 1 , (2) When wRF thinks that the distances between two pairs of trees are the same, then d m also thinks they are in the same: wRF(T 1 ,    Therefore, it can be said that the performance of the mixture distance in calculating the similarity of two weighted trees is as good as the performance of the weighted RF distance, while the time complexity of the mixture distance is better. In addition, we compared our approaches with the methods performed with the nodal distance metric [11], geodesic tree distance [19], weighted path difference metric [14] and weighted RF distance [12], and the results are shown in Table 3. Our proposed approaches performed better than all of the previous methods when discussing the distance between two mixture trees. Table 3. Comparison of metrics for binary trees.

Metric
Consideration Time Complexity

Conflicts of Interest:
The authors declare no conflict of interest.