Computing Triplet and Quartet Distances Between Trees Gerth
Computing Triplet and Quartet Distances Between Trees Gerth Stølting Brodal, Morten Kragelund Holt, Jens Johansen Aarhus University Rolf Fagerberg University of Southern Denmark Thomas Mailund, Christian N. S. Pedersen, Andreas Sand Aarhus University, Bioinformatics Research Center Work presented at SODA 2013 and ALENEX 2014 Computer Science Institute, Charles University, Prague, Czech Republic, 18 September 2014
Outline § Evolutionary trees – rooted vs. unrooted, binary vs. arbitrary degree § Tree distances – Robinson-Foulds, triplet, quartet § Results and previous work – triplet, quartet distances § Algorithms – triplet (quartet) § Experimental results (ALENEX 2014)
Time Rooted Evolutionary Tree Bonobo Chimpanzee Human Neanderthal Gorilla Orangutan
Unrooted Evolutionary Tree Dominant modern approach to study evolution is from DNA analysis
Constructing Evolutionary Trees – Binary or Arbitrary Degrees ? 1 2 3 ··· Sequence data Distance matrix n n Binary trees (despite no evidence in distance data) 1 2 3 ··· n Arbitrary degree (compromise ; good support for all edges). . Neighbor Joining Saitou, Nei 1987 [ O(n 3) Saitou, Nei 1987 ] Arbitrary degrees (strong support for all edges ; few branches). . Refined Buneman Trees Moulton, Steel 1999 [ O(n 3) Brodal et al. 2003 ] Buneman Trees Buneman 1971 [ O(n 3) Berry, Bryan 1999 ]
Data Analysis vs Expert Trees – Binary vs Arbitrary Degrees ? Cultural Phylogenetics of the Tupi Language Family in Lowland South America. R. S. Walker, S. Wichmann, T. Mailund, C. J. Atkisson. PLo. S One. 7(4), 2012. Neighbor Joining on linguistic data Linguistic expert classification (Aryon Rodrigues)
Evolutionary Tree Comparison split 1357|2468 5 3 8 2 4 7 6 ? 1 6 7 4 5 3 8 2 1 T 2 Common Only T 1 Only T 2 1357|2468 35|124678 57|123468 13567|248 48|123567 Robinson-Foulds distance = # non-common splits = 2 + 1 = 3 D. F. Robinson and L. R. Foulds. Comparison of weighted labeled trees. In Combinatorial mathematics, VI, Lecture Notes in Mathematics, pages 119– 126. Springer, 1979. [Day 1985] O(n) time algorithm using 2 x DFS + radix sort
Robinson-Foulds Distance (unrooted trees) D. F. Robinson and L. R. Foulds. Comparison of weighted labeled trees. In Combinatorial mathematics, VI, Lecture Notes in Mathematics, pages 119– 126. Springer, 1979. 3 4 6 3 6 8 2 1 5 ? 2 1 8 5 7 T 1 4 T 2 Common Only T 1 Only T 2 (none) 12567|348 1257|3468 157|23468 57|123468 125678|34 12578|346 1578|2346 578|12346 78|123456 7 RF-dist(T 1 , T 2) = 4 + 5 = 9 RF-dist(T 1{8} , T 2{8}) = 0 Robinson-Foulds very sensitive to outliers
Quartet Distance (unrooted trees) G. Estabrook, F. Mc. Morris, and C. Meacham. Comparison of undirected phylogenetic trees based on subtrees of four evolutionary units. Systematic Zoology, 34: 193 -200, 1985. § j l i k resolved : ij|kl 3 4 1 3 4 2 T 1 (only non-binary trees) 5 5 2 unresolved : ijkl 1 T 2 Quartet {1, 2, 3, 4} {1, 2, 3, 5} {1, 2, 4, 5} {1, 3, 4, 5} {2, 3, 4, 5} T 1 14|23 13|25 14|35 25|34 T 2 14|23 15|23 1245 1345 23|45
Triplet Distance (rooted trees) D. E. Critchlow, D. K. Pearl, C. L. Qian: The triples distance for rooted bifurcating phylogenetic trees. Systematic Biology, 45(3): 323 -334, 1996. § i j k i 1 5 4 T 1 2 k unresolved : ijk resolved : k|ij 3 j (only non-binary trees) 2 4 3 1 T 2 5 Triplet {1, 2, 3} {1, 2, 4} {1, 2, 5} {1, 3, 4} {1, 3, 5} {1, 4, 5} {2, 3, 4} {2, 3, 5} {2, 4, 5} {3, 4, 5} T 1 2|13 1|24 1|25 4|13 5|13 1|45 3|24 3|25 5|24 3|45 T 2 2|13 4|12 5|12 4|13 5|13 1|45 4|23 5|23 2|45 3|45
Computational Results Rooted Triplet distance Unrooted Quartet distance 5 2 3 3 Binary 1 O(n 2) O(n log 2 n) O(n log n) 5 4 2 CPQ 1996 SBFPM 2013 [SODA 2013] 4 O(n 3) O(n 2) O(n log 2 n) O(n log n) 10 3 Arbitrary degrees 3 1 7 5 12 4 62 O(n 2) O(n log n) BDF 2011 [SODA 2013] D 1985 1 6 BTKL 2000 BFP 2001 BFP 2003 1 9 7 O(d 9 n log n) O(n 2. 688) O(d n log n) 13 5 8 11 SPMBF 2007 NKMP 2011 [SODA 2013] [ALENEX 2014]
Distance Computation O(n ·log T 2 n) trip lets & q uar te Resolved i T 1 j Resolved ts A : Agree i k k Unresolved j k C B : Disagree j i Unresolved i i k j D k j i j lets p i r t ets n) t g r o a l · O(n og n) qu n·l · d ( O E k j j k i i j Sufficient to compute A and E D + E and C + E unresolved in one tree (For binary trees C, D and E are all zero) k ets trip ) n ( O let art u q s &
Parameterized Triplet & Quartet Distances B + α·(C + D) , 0 α 1 T 2 Resolved A : Agree Resolved i T 1 j i k k Unresolved j k C B : Disagree j i Unresolved i i k j D k j i j E k j j k i i j k BDF 2011 O(n 2) for triplet, NKMP 2011 O(n 2. 688) for quartet [SODA 2013/ALENEX 2014] O(n·log n) and O(d·n·log n), respectively
Counting Unresolved Triplets in One Tree v n 1 n 2 n 3 ··· nd Triplet anchored at v Computable in O(n) time using DFS + dynamic programming Quartets (root tree arbitrary) v n 1 n 2 n 3 ··· nd Quartet anchored at v
Counting Agreeing Triplets (Basic Idea) v 0 w j 1 j i c d i i T 1 T 2
Efficient Computation 0 v Limit recolorings in T 1 (and T 2) to O(n·log n) 1 0 Recolor v 1 1 1 (precondition) 0 v 2 0 Recolor d v Recurse 0 1 v . . . T 1 0 v 1 Recolor & recurse Count T 2 contribution 1 Reduce recoloring cost in T 2 from O(n 2) to O(n·log 2 n) T 2 arbitrary height degree 7 2 4 1 6 3 H(T 2) 9 8 5 2 7 4 1 3 6 9 Reduce recoloring cost in T 2 from O(n·log 2 n) to O(n·log n) § Contract T 2 and reconstruct H(T 2) during recursion 5 8 binary height O(log n)
Counting Agreeing Triplets (II) T 1 v C 2 node in H(T 2) = component composition in T 2 0 j i j C 1 1 i j i d j i i Contribution to agreeing triplets at node in H(T 2) + + i i
From O(n·log 2 n) to O(n·log n) T 1 v Compressed version of T 2 of size O(nv) 0 w 1 Update O(1) counters for all colors through node j i d ni nv a(4) T 1 a(3) a(1) Colored path lengths a(5) Total cost for updating counters a(2) l=a(0)
Counting Quartets. . . § Root T 1 and T 2 arbitrary § Keep up to 7 d 2 + 97 d + 29 different counters per node in H(T 2). . . Bottleneck in computing disagreeing resolved-resolved quartets T 1 v T 2 0 G 1 i j d double-sum factor d time G 2
Distance Computation O(n ·log T 2 n) trip lets & q uar te Resolved i T 1 j Resolved ts A : Agree i k k Unresolved j k C B : Disagree j i Unresolved i i k j D k j i j lets p i r t ets n) t g r o a l · O(n og n) qu n·l · d ( O E k j j k i Sufficient to compute A and E i j k
ALENEX 2014: Implementation (M. Sc. thesis Morten Kragelund Holt and Jens Johansen) Binary time counters Triplet O(n log n) 6 time Arbitrary degree counters O(n log n) 4 d+2 O(max(d 1, d 2) n log n) 2 d 2 + 79 d + 22 (B, with T 1 T 2) Quartet O(n log n) 40 O(min(d 1, d 2) n log n) 7 d 2 + 97 d + 29 (B, no swap) d 2 + 12 d + 12 (E, no swap) Worst-case #counters per node in HDT(T 2) § First implementation for triplets for arbitrary degree § Space usage 10 KB per node for quartet (binary trees) can handle 1, 000 leaves § 64 bit integers, except 128 bit integers for values > n 3 quartet distance of up to 2, 000 leaves
Experimental Results Quartet Distance – Binary Trees [SODA 2013] MP 2004 NKMP 2011 § [ALENEX 2014] are the first O(n log n) implementations § MP 2004 overhead from working with polynomials
Experimental Results Quartet Distance – High Degree Trees max [SODA 2013] NKMP 2011 d = 1024 d = 256 § [ALENEX 2014] are the first n poly(log n, d) implementation
Experimental Results Triplet Distance – Binary Trees [SODA 2013] SBFPM 2013 § [ALENEX 2014] are the first O(n log n) implementation § SBFPM 2013 only binary trees, no contractions
Experimental Results Triplet Distance – High Degree Trees [SODA 2013], d=2 SODA 2013 [SODA[SBFPM 2013], d 2013] = 256 [SODA 2013], d = 1024 § [ALENEX 2014] first implementation § Triplet distance appears hardest for binary trees
Summary Rooted Triplet distance Unrooted Quartet distance 5 2 3 Binary 1 5 4 O(n 2) 2 CPQ 1996 O(n log 2 n) O(n log n) SBFPM 2013 [SODA 2013] o(n·log n) ? O(n 3) 4 O(n 2) O(n log 2 n) O(n log n) 10 3 Arbitrary degrees 3 1 7 5 12 4 62 O(n 2) O(n log n) BDF 2011 [SODA 2013] 6 3 BTKL 2000 1 BFP 2003 [SODA 2013] 1 9 7 13 O(d 9 n log n) O(n 2. 688) O(d n log n) d = minimal degree of any node in T 1 and T 2 = fastest implementation for large n D 1985 5 8 11 SPMBF 2007 NKMP 2011 [SODA 2013] [ALENEX 2014] O(n·log n) ?
References § § § § § On the Scalability of Computing Triplet and Quartet Distances. M. K. Holt, J. Johansen, G. S. Brodal. ALENEX 2014. Algorithms for Computing the Triplet and Quartet Distances for Binary and General Trees. A. Sand, M. K. Holt, J. Johansen, R. Fagerberg, G. S. Brodal, C. N. S. Pedersen, T. Mailund. Biology - Special Issue on Developments in Bioinformatic Algorithms, 2013. A practical O(n log 2 n) time algorithm for computing the triplet distance on binary trees. A. Sand, G. S. Brodal, R. Fagerberg, C. N. S. Pedersen, T. Mailund. BMC Bioinformatics 2013. Efficient Algorithms for Computing the Triplet and Quartet Distance Between Trees of Arbitrary Degree. G. S. Brodal, R. Fagerberg, C. N. S. Pedersen, T. Mailund, A. Sand. SODA 2013. A sub-cubic time algorithm for computing the quartet distance between two general trees. J. Nielsen, A. K. Kristensen, T. Mailund, C. N. S. Pedersen. Algorithms in Molecular Biology 2011. Computing the Quartet Distance Between Evolutionary Trees of Bounded Degree. M. Stissing, C. N. S. Pedersen, T. Mailund, G. S. Brodal, R. Fagerberg. APBC 2007. QDist - Quartet Distance between Evolutionary Trees. T. Mailund and C. N. S. Pedersen. Bioinformatics 2004. Computing the Quartet Distance Between Evolutionary Trees in Time O(n log n). G. S. Brodal, R. Fagerberg, C. N. S. Pedersen. Algorithmica 2004. Computing the Quartet Distance Between Evolutionary Trees in Time O(n log 2 n). G. S. Brodal, R. Fagerberg, C. N. S. Pedersen. ISAAC 2001. birc. au. dk/software
- Slides: 27