OpenMS
ClusterHierarchical Class Reference

Hierarchical clustering with generic clustering functions. More...

#include <OpenMS/ML/CLUSTERING/ClusterHierarchical.h>

Collaboration diagram for ClusterHierarchical:
[legend]

Public Member Functions

 ClusterHierarchical ()
 default constructor More...
 
 ClusterHierarchical (const ClusterHierarchical &source)
 copy constructor More...
 
virtual ~ClusterHierarchical ()
 destructor More...
 
template<typename Data , typename SimilarityComparator >
void cluster (std::vector< Data > &data, const SimilarityComparator &comparator, const ClusterFunctor &clusterer, std::vector< BinaryTreeNode > &cluster_tree, DistanceMatrix< float > &original_distance)
 Clustering function. More...
 
void cluster (std::vector< PeakSpectrum > &data, const BinnedSpectrumCompareFunctor &comparator, double sz, UInt sp, float offset, const ClusterFunctor &clusterer, std::vector< BinaryTreeNode > &cluster_tree, DistanceMatrix< float > &original_distance) const
 clustering function for binned PeakSpectrum More...
 
double getThreshold () const
 get the threshold More...
 
void setThreshold (double x)
 

Private Attributes

double threshold_
 the threshold given to the ClusterFunctor More...
 

Detailed Description

Hierarchical clustering with generic clustering functions.

ClusterHierarchical clusters objects with corresponding distancemethod and clusteringmethod.

Constructor & Destructor Documentation

◆ ClusterHierarchical() [1/2]

ClusterHierarchical ( )
inline

default constructor

◆ ClusterHierarchical() [2/2]

ClusterHierarchical ( const ClusterHierarchical source)
inline

copy constructor

◆ ~ClusterHierarchical()

virtual ~ClusterHierarchical ( )
inlinevirtual

destructor

Member Function Documentation

◆ cluster()

void cluster ( std::vector< Data > &  data,
const SimilarityComparator &  comparator,
const ClusterFunctor clusterer,
std::vector< BinaryTreeNode > &  cluster_tree,
DistanceMatrix< float > &  original_distance 
)
inline

Clustering function.

Cluster data using SimilarityComparator and ClusterFunctor.

Creates a DistanceMatrix (if an empty matrix is passed) and the clustering is started. Clustering stops if the ClusterHierarchical::threshold_ is reached by the ClusterFunctor.

First template parameter is the cluster object type, Second template parameter is the similarity functor applicable to the type.

For example, PeakSpectrum with a PeakSpectrumCompareFunctor.

The similarity functor must provide the similarity calculation with the ()-operator and yield normalized values in range of [0,1] for the type of < Data >.

Parameters
dataValues to be clustered
comparatorSimilarity functor which returns a similarity in [0, 1] for any pair of values in data
clustererA cluster method implementation, e.g. SingleLinkage or CompleteLinkage. See base class ClusterFunctor.
cluster_treeThe vector that will hold the BinaryTreeNodes representing the clustering (for further investigation with the ClusterAnalyzer methods)
original_distancePrecomputed DistanceMatrix holding the pairwise distances of the elements in data; if empty or wrong size, it will be re-created using comparator
See also
ClusterFunctor, BinaryTreeNode, ClusterAnalyzer

References DistanceMatrix< Value >::clear(), DistanceMatrix< Value >::dimensionsize(), DistanceMatrix< Value >::resize(), and DistanceMatrix< Value >::setValueQuick().

Referenced by SpectraMerger::mergeSpectraPrecursors().

◆ getThreshold()

double getThreshold ( ) const
inline

get the threshold

◆ setThreshold()

void setThreshold ( double  x)
inline

set the threshold (in terms of distance) The default is 1, i.e. only at similarity 0 the clustering stops. Warning: clustering is not supported by all methods yet (e.g. SingleLinkage does ignore it).

Member Data Documentation

◆ threshold_

double threshold_
private

the threshold given to the ClusterFunctor