This documentation is for version 2.0.dev, which is not released yet.
Carry out a flat cluster analysis based on the UPGMA algorithm (Sokal1958).
Parameters : | threshold : float
matrix : or numpy.array
taxa : (default = [])
|
---|---|
Returns : | clusters : dict
|
See also
lingpy.algorithm.clusters.upgma, lingpy.algorithm.clusters.neighbor
Examples
The function is automatically imported along with LingPy.
>>> from lingpy import *
Create a of arbitrary taxa.
>>> taxa = ['German','Swedish','Icelandic','English','Dutch']
Create an arbitrary distance matrix.
>>> matrix = squareform([0.5,0.67,0.8,0.2,0.4,0.7,0.6,0.8,0.8,0.3])
>>> matrix
array([[ 0. , 0.5 , 0.67, 0.8 , 0.2 ],
[ 0.5 , 0. , 0.4 , 0.7 , 0.6 ],
[ 0.67, 0.4 , 0. , 0.8 , 0.8 ],
[ 0.8 , 0.7 , 0.8 , 0. , 0.3 ],
[ 0.2 , 0.6 , 0.8 , 0.3 , 0. ]])
Carry out the flat cluster analysis.
>>> flat_upgma(0.5,matrix,taxa)
{0: ['German', 'Dutch', 'English'], 1: ['Swedish', 'Icelandic']}