Package org.biojava.nbio.core.util
Class SingleLinkageClusterer
- java.lang.Object
-
- org.biojava.nbio.core.util.SingleLinkageClusterer
-
public class SingleLinkageClusterer extends Object
An implementation of a single linkage clusterer See http://en.wikipedia.org/wiki/Single-linkage_clustering- Author:
- Jose Duarte
-
-
Constructor Summary
Constructors Constructor Description SingleLinkageClusterer(double[][] matrix, boolean isScoreMatrix)
Constructs a new SingleLinkageClusterer Subsequently usegetDendrogram()
to get the full tree orgetClusters(double)
to get the clusters at a certain cutoff in the tree Please note that the matrix will be altered during the clustering procedure.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Integer,Set<Integer>>
getClusters(double cutoff)
Get the clusters by cutting the dendrogram at given cutofforg.biojava.nbio.core.util.SingleLinkageClusterer.LinkedPair[]
getDendrogram()
Get the full dendrogram (size n-1) result of the hierarchical clustering
-
-
-
Constructor Detail
-
SingleLinkageClusterer
public SingleLinkageClusterer(double[][] matrix, boolean isScoreMatrix)
Constructs a new SingleLinkageClusterer Subsequently usegetDendrogram()
to get the full tree orgetClusters(double)
to get the clusters at a certain cutoff in the tree Please note that the matrix will be altered during the clustering procedure. A copy must be made before by the user if needing to use the original matrix further.- Parameters:
matrix
- the distance matrix with distance values in j>i half, all other values will be ignoredisScoreMatrix
- if false the matrix will be considered a distance matrix: lower values (distances) mean closer objects, if true the matrix will be considered a score matrix: larger values (scores) mean closer objects- Throws:
IllegalArgumentException
- if matrix not square
-
-
Method Detail
-
getDendrogram
public org.biojava.nbio.core.util.SingleLinkageClusterer.LinkedPair[] getDendrogram()
Get the full dendrogram (size n-1) result of the hierarchical clustering- Returns:
-
getClusters
public Map<Integer,Set<Integer>> getClusters(double cutoff)
Get the clusters by cutting the dendrogram at given cutoff- Parameters:
cutoff
-- Returns:
- Map from cluster numbers to indices of the cluster members
-
-