HOME

TheInfoList



OR:

In
bioinformatics Bioinformatics () is an interdisciplinary field that develops methods and software tools for understanding biological data, in particular when the data sets are large and complex. As an interdisciplinary field of science, bioinformatics combi ...
, neighbor joining is a bottom-up (agglomerative) clustering method for the creation of
phylogenetic trees A phylogenetic tree (also phylogeny or evolutionary tree Felsenstein J. (2004). ''Inferring Phylogenies'' Sinauer Associates: Sunderland, MA.) is a branching diagram or a tree showing the evolutionary relationships among various biological spec ...
, created by Naruya Saitou and Masatoshi Nei in 1987. Usually based on DNA or
protein Proteins are large biomolecules and macromolecules that comprise one or more long chains of amino acid residues. Proteins perform a vast array of functions within organisms, including catalysing metabolic reactions, DNA replication, res ...
sequence In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is called ...
data, the algorithm requires knowledge of the distance between each pair of
taxa In biology, a taxon (back-formation from ''taxonomy''; plural taxa) is a group of one or more populations of an organism or organisms seen by taxonomists to form a unit. Although neither is required, a taxon is usually known by a particular nam ...
(e.g., species or sequences) to create the phylogenetic tree.


The algorithm

Neighbor joining takes a
distance matrix In mathematics, computer science and especially graph theory, a distance matrix is a square matrix (two-dimensional array) containing the distances, taken pairwise, between the elements of a set. Depending upon the application involved, the ''dist ...
, which specifies the distance between each pair of
taxa In biology, a taxon (back-formation from ''taxonomy''; plural taxa) is a group of one or more populations of an organism or organisms seen by taxonomists to form a unit. Although neither is required, a taxon is usually known by a particular nam ...
, as input. The algorithm starts with a completely unresolved tree, whose topology corresponds to that of a star network, and iterates over the following steps, until the tree is completely resolved, and all branch lengths are known: # Based on the current distance matrix, calculate a matrix Q (defined below). # Find the pair of distinct taxa i and j (i.e. with i \neq j) for which Q(i,j) is smallest. Make a new node that joins the taxa i and j, and connect the new node to the central node. For example, in part (B) of the figure at right, node u is created to join f and g. # Calculate the distance from each of the taxa in the pair to this new node. # Calculate the distance from each of the taxa outside of this pair to the new node. # Start the algorithm again, replacing the pair of joined neighbors with the new node and using the distances calculated in the previous step.


The Q-matrix

Based on a distance matrix relating the n taxa, calculate the n x n matrix Q as follows: where d(i,j) is the distance between taxa i and j.


Distance from the pair members to the new node

For each of the taxa in the pair being joined, use the following formula to calculate the distance to the new node: and: : \delta(g,u)=d(f,g)-\delta(f,u) \quad Taxa f and g are the paired taxa and u is the newly created node. The branches joining f and u and g and u, and their lengths, \delta(f,u) and \delta(g,u) are part of the tree which is gradually being created; they neither affect nor are affected by later neighbor-joining steps.


Distance of the other taxa from the new node

For each taxon not considered in the previous step, we calculate the distance to the new node as follows: where u is the new node, k is the node which we want to calculate the distance to and f and g are the members of the pair just joined.


Complexity

Neighbor joining on a set of n taxa requires n-3 iterations. At each step one has to build and search a Q matrix. Initially the Q matrix is size n\times n, then the next step it is (n-1)\times(n-1), etc. Implementing this in a straightforward way leads to an algorithm with a time complexity of O(n^3); implementations exist which use heuristics to do much better than this on average.


Example

Let us assume that we have five taxa (a,b,c,d,e) and the following distance matrix D:


First step


First joining

We calculate the Q_1 values by equation (). For example: :Q_1(a,b) = (n-2)d(a,b) - \sum_^5 d(a,k) - \sum_^5 d(b,k) := (5-2) \times 5 - (5+9+9+8) - (5+10+10+9) = 15-31-34 = -50 We obtain the following values for the Q_1 matrix (the diagonal elements of the matrix are not used and are omitted here): In the example above, Q_1(a,b)=-50. This is the smallest value of Q_1, so we join elements a and b.


First branch length estimation

Let u denote the new node. By equation (), above, the branches joining a and b to u then have lengths: :\delta(a,u)=\fracd(a,b)+\frac \left \sum_^5 d(a,k) - \sum_^5 d(b,k) \right \quad =\frac + \frac = 2 :\delta(b,u)=d(a,b)-\delta(a,u) \quad = 5-2 = 3


First distance matrix update

We then proceed to update the initial distance matrix D into a new distance matrix D_1 (see below), reduced in size by one row and one column because of the joining of a with b into their neighbor u. Using equation () above, we compute the distance from u to each of the other nodes besides a and b. In this case, we obtain: :d(u,c)=\frac (a,c)+d(b,c)-d(a,b)= \frac = 7 :d(u,d)=\frac (a,d)+d(b,d)-d(a,b)= \frac = 7 :d(u,e)=\frac (a,e)+d(b,e)-d(a,b)= \frac = 6 The resulting distance matrix D_1 is: Bold values in D_1 correspond to the newly calculated distances, whereas italicized values are not affected by the matrix update as they correspond to distances between elements not involved in the first joining of taxa.


Second step


Second joining

The corresponding Q_2 matrix is: We may choose either to join u and c, or to join d and e; both pairs have the minimal Q_2 value of -28, and either choice leads to the same result. For concreteness, let us join u and c and call the new node v.


Second branch length estimation

The lengths of the branches joining u and c to v can be calculated: :\delta(u,v)=\fracd(u,c)+\frac \left \sum_^4 d(u,k) - \sum_^4 d(c,k) \right \quad =\frac + \frac = 3 :\delta(c,v)=d(u,c)-\delta(u,v) \quad = 7-3 = 4 The joining of the elements and the branch length calculation help drawing the neighbor joining tree as shown in the figure.


Second distance matrix update

The updated distance matrix D_2 for the remaining 3 nodes, v, d, and e, is now computed: :d(v,d)=\frac (u,d)+d(c,d)-d(u,c)= \frac = 4 :d(v,e)=\frac (u,e)+d(c,e)-d(u,c)= \frac = 3


Final step

The tree topology is fully resolved at this point. However, for clarity, we can calculate the Q_3 matrix. For example: :Q_3(v,e) = (3-2)d(v,e) - \sum_^3 d(v,k) - \sum_^3 d(e,k) = 3-7-6 = -10 For concreteness, let us join v and d and call the last node w. The lengths of the three remaining branches can be calculated: :\delta(v,w)=\fracd(v,d)+\frac \left \sum_^3 d(v,k) - \sum_^3 d(d,k) \right \quad =\frac + \frac = 2 :\delta(w,d)=d(v,d)-\delta(v,w) = 4-2 = 2 :\delta(w,e)=d(v,e)-\delta(v,w) = 3-2 = 1 The neighbor joining tree is now complete, as shown in the figure.


Conclusion: additive distances

This example represents an idealized case: note that if we move from any taxon to any other along the branches of the tree, and sum the lengths of the branches traversed, the result is equal to the distance between those taxa in the input distance matrix. For example, going from d to b we have 2+2+3+3=10. A distance matrix whose distances agree in this way with some tree is said to be 'additive', a property which is rare in practice. Nonetheless it is important to note that, given an additive distance matrix as input, neighbor joining is guaranteed to find the tree whose distances between taxa agree with it.


Neighbor joining as minimum evolution

Neighbor joining may be viewed as a greedy heuristic for the Balanced Minimum Evolution (BME) criterion. For each topology, BME defines the tree length (sum of branch lengths) to be a particular weighted sum of the distances in the distance matrix, with the weights depending on the topology. The BME optimal topology is the one which minimizes this tree length. Neighbor joining at each step greedily joins that pair of taxa which will give the greatest decrease in the estimated tree length. This procedure does not guarantee to find the optimum for the BME criterion, although it often does and is usually quite close.


Advantages and disadvantages

The main virtue of NJ is that it is fast as compared to
least squares The method of least squares is a standard approach in regression analysis to approximate the solution of overdetermined systems (sets of equations in which there are more equations than unknowns) by minimizing the sum of the squares of the re ...
,
maximum parsimony In phylogenetics, maximum parsimony is an optimality criterion under which the phylogenetic tree that minimizes the total number of character-state changes (or miminizes the cost of differentially weighted character-state changes) is preferred. ...
and
maximum likelihood In statistics, maximum likelihood estimation (MLE) is a method of estimating the parameters of an assumed probability distribution, given some observed data. This is achieved by maximizing a likelihood function so that, under the assumed stat ...
methods. This makes it practical for analyzing large data sets (hundreds or thousands of taxa) and for
bootstrapping In general, bootstrapping usually refers to a self-starting process that is supposed to continue or grow without external input. Etymology Tall boots may have a tab, loop or handle at the top known as a bootstrap, allowing one to use fingers ...
, for which purposes other means of analysis (e.g.
maximum parsimony In phylogenetics, maximum parsimony is an optimality criterion under which the phylogenetic tree that minimizes the total number of character-state changes (or miminizes the cost of differentially weighted character-state changes) is preferred. ...
,
maximum likelihood In statistics, maximum likelihood estimation (MLE) is a method of estimating the parameters of an assumed probability distribution, given some observed data. This is achieved by maximizing a likelihood function so that, under the assumed stat ...
) may be
computation Computation is any type of arithmetic or non-arithmetic calculation that follows a well-defined model (e.g., an algorithm). Mechanical or electronic devices (or, historically, people) that perform computations are known as ''computers''. An esp ...
ally prohibitive. Neighbor joining has the property that if the input distance matrix is correct, then the output tree will be correct. Furthermore, the correctness of the output tree topology is guaranteed as long as the distance matrix is 'nearly additive', specifically if each entry in the distance matrix differs from the true distance by less than half of the shortest branch length in the tree.Atteson K (1997). "The performance of neighbor-joining algorithms of phylogeny reconstruction", pp. 101–110. ''In'' Jiang, T., and Lee, D., eds., ''Lecture Notes in Computer Science, 1276'', Springer-Verlag, Berlin. COCOON '97. In practice the distance matrix rarely satisfies this condition, but neighbor joining often constructs the correct tree topology anyway. The correctness of neighbor joining for nearly additive distance matrices implies that it is statistically consistent under many models of evolution; given data of sufficient length, neighbor joining will reconstruct the true tree with high probability. Compared with
UPGMA UPGMA (unweighted pair group method with arithmetic mean) is a simple agglomerative (bottom-up) hierarchical clustering method. The method is generally attributed to Sokal and Michener. The UPGMA method is similar to its ''weighted'' variant, the ...
and
WPGMA WPGMA (Weighted Pair Group Method with Arithmetic Mean) is a simple agglomerative (bottom-up) hierarchical clustering method, generally attributed to Sokal and Michener. The WPGMA method is similar to its ''unweighted'' variant, the UPGMA method. ...
, neighbor joining has the advantage that it does not assume all lineages evolve at the same rate (
molecular clock hypothesis The molecular clock is a figurative term for a technique that uses the mutation rate of biomolecules to deduce the time in prehistory when two or more life forms diverged. The biomolecular data used for such calculations are usually nucleotid ...
). Nevertheless, neighbor joining has been largely superseded by phylogenetic methods that do not rely on distance measures and offer superior accuracy under most conditions. Neighbor joining has the undesirable feature that it often assigns negative lengths to some of the branches.


Implementations and variants

There are many programs available implementing neighbor joining.
RapidNJ
an

are fast implementations with typical run times proportional to approximately the square of the number of taxa
BIONJ
an
Weighbor
are variants of neighbor joining which improve on its accuracy by making use of the fact that the shorter distances in the distance matrix are generally better known than the longer distances

is an implementation of the closely related balanced minimum evolution method.


See also

*
Nearest neighbor search Nearest neighbor search (NNS), as a form of proximity search, is the optimization problem of finding the point in a given set that is closest (or most similar) to a given point. Closeness is typically expressed in terms of a dissimilarity function ...
*
UPGMA UPGMA (unweighted pair group method with arithmetic mean) is a simple agglomerative (bottom-up) hierarchical clustering method. The method is generally attributed to Sokal and Michener. The UPGMA method is similar to its ''weighted'' variant, the ...
and
WPGMA WPGMA (Weighted Pair Group Method with Arithmetic Mean) is a simple agglomerative (bottom-up) hierarchical clustering method, generally attributed to Sokal and Michener. The WPGMA method is similar to its ''unweighted'' variant, the UPGMA method. ...
* Minimum Evolution


References


Other sources

* *


External links


The Neighbor-Joining Method
— a tutorial {{DEFAULTSORT:Neighbor-Joining Bioinformatics algorithms Phylogenetics Computational phylogenetics Cluster analysis algorithms