[BioPython] Bio.Cluster with 3D coordinates

Michiel De Hoon mdehoon at c2b2.columbia.edu
Tue Feb 21 16:45:01 EST 2006


> Can anyone give axample amd suggestions how to find cluster centers
> of my points in Cartesian space (x,y,z) using Bio.Cluster or Bio.kMeans ?

>>> from Numeric import *
>>> from Bio.Cluster import kcluster, clustercentroid
>>> datapoints = array([[1.1,0.9,1.1],
...                     [2.3,3.1,2.7],
...                     [1.2,1.0,0.9],
...                     [2.2,2.9,2.6],
...                     [2.2,3.0,2.9]])
>>> clusterid, error, nfound = kcluster(datapoints)
>>> clusterid
array([0, 1, 0, 1, 1])
>>> centroid, centroid_mask = clustercentroid(datapoints,
clusterid=clusterid)
>>> centroid[0]
array([ 1.15,  0.95,  1.  ])
>>> centroid[1]
array([ 2.23333333,  3.        ,  2.73333333])
>>> centroid_mask
array([[1, 1, 1],
       [1, 1, 1]])
# Because there are no missing data.


kcluster uses the Euclidean distance by default. To find more than two
clusters, use kcluster(..., nclusters=the_number_of_clusters_you_want). If
you have a lot of data points, it's better to make kcluster use multiple runs
by specifying kcluster(..., npass=some_big_number).

--Michiel.




Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032



-----Original Message-----
From: biopython-bounces at portal.open-bio.org on behalf of
ziemys at ecr6.ohio-state.edu
Sent: Tue 2/21/2006 1:51 PM
To: biopython at biopython.org
Subject: [BioPython] Bio.Cluster with 3D coordinates
 
HI,



Bio.Cluster seems to be "optimised" for gene data. However, I did not find
clues how to use it with 3D coordinates.

Arturas Z.


_______________________________________________
BioPython mailing list  -  BioPython at biopython.org
http://biopython.org/mailman/listinfo/biopython




More information about the BioPython mailing list