LingPy

lingpy.algorithm.cluster.neighbor

lingpy.algorithm.cluster.neighbor(matrix, taxa, distances=True)

Function clusters data according to the Neighbor-Joining algorithm (Saitou1987).

Parameters :

matrix : list or numpy.array

A two-dimensional list containing the distances.

taxa : list

An list containing the names of all taxa corresponding to the distances in the matrix.

distances : bool

If set to False, only the topology of the tree will be returned.

Returns :

newick : str

A string in newick-format which can be further used in biological software packages to view and plot the tree.

Examples

Function is automatically imported when importing lingpy.

>>> from lingpy import *

Create an arbitrary list of taxa.

>>> taxa = ['Norwegian','Swedish','Icelandic','Dutch','English']

Create an arbitrary matrix.

>>> matrix = squareform([0.5,0.67,0.8,0.2,0.4,0.7,0.6,0.8,0.8,0.3])

Carry out the cluster analysis.

>>> neighbor(matrix,taxa)
'(((Norwegian,(Swedish,Icelandic)),English),Dutch);'