41 #ifndef OPENMS_COMPARISON_CLUSTERING_CLUSTERHIERARCHICAL_H 42 #define OPENMS_COMPARISON_CLUSTERING_CLUSTERHIERARCHICAL_H 80 threshold_(source.threshold_)
107 template <
typename Data,
typename SimilarityComparator>
113 original_distance.
clear();
114 original_distance.
resize(data.size(), 1);
115 for (
Size i = 0; i < data.size(); i++)
117 for (
Size j = 0; j < i; j++)
120 original_distance.
setValueQuick(i, j, 1 - comparator(data[i], data[j]));
127 clusterer(original_distance, cluster_tree, threshold_);
149 std::vector<BinnedSpectrum> binned_data;
150 binned_data.reserve(data.size());
153 for (
Size i = 0; i < data.size(); i++)
160 original_distance.
clear();
161 original_distance.
resize(data.size(), 1);
163 for (
Size i = 0; i < binned_data.size(); i++)
165 for (
Size j = 0; j < i; j++)
168 original_distance.
setValue(i, j, 1 - comparator(binned_data[i], binned_data[j]));
173 clusterer(original_distance, cluster_tree, threshold_);
202 =
"Clustering with unnormalized similarity measurement requested, normalized is mandatory")
throw();
207 #endif //OPENMS_COMPARISON_CLUSTERING_CLUSTERHIERARCHICAL_H Base class for compare functors of BinnedSpectra.
Definition: BinnedSpectrumCompareFunctor.h:57
virtual ~ClusterHierarchical()
destructor
Definition: ClusterHierarchical.h:85
void cluster(std::vector< PeakSpectrum > &data, const BinnedSpectrumCompareFunctor &comparator, double sz, UInt sp, const ClusterFunctor &clusterer, std::vector< BinaryTreeNode > &cluster_tree, DistanceMatrix< float > &original_distance)
clustering function for binned PeakSpectrum
Definition: ClusterHierarchical.h:146
void resize(SizeType dimensionsize, Value value=Value())
resizing the container
Definition: DistanceMatrix.h:350
A two-dimensional distance matrix, similar to OpenMS::Matrix.
Definition: DistanceMatrix.h:68
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
double getThreshold()
get the threshold
Definition: ClusterHierarchical.h:177
Exception thrown if clustering is attempted without a normalized compare functor. ...
Definition: ClusterHierarchical.h:197
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void clear()
reset all
Definition: DistanceMatrix.h:328
void setValueQuick(SizeType i, SizeType j, ValueType value)
sets a value at a given position:
Definition: DistanceMatrix.h:310
void setThreshold(double x)
Definition: ClusterHierarchical.h:185
ClusterHierarchical(const ClusterHierarchical &source)
copy constructor
Definition: ClusterHierarchical.h:79
ClusterHierarchical()
default constructor
Definition: ClusterHierarchical.h:73
double threshold_
the threshold given to the ClusterFunctor
Definition: ClusterHierarchical.h:69
Exception base class.
Definition: Exception.h:90
This is a binned representation of a PeakSpectrum.
Definition: BinnedSpectrum.h:65
void setValue(SizeType i, SizeType j, ValueType value)
sets a value at a given position:
Definition: DistanceMatrix.h:264
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
SizeType dimensionsize() const
gives the number of rows (i.e. number of columns)
Definition: DistanceMatrix.h:419
Hierarchical clustering with generic clustering functions.
Definition: ClusterHierarchical.h:64
void cluster(std::vector< Data > &data, const SimilarityComparator &comparator, const ClusterFunctor &clusterer, std::vector< BinaryTreeNode > &cluster_tree, DistanceMatrix< float > &original_distance)
Clustering function.
Definition: ClusterHierarchical.h:108
Base class for cluster functors.
Definition: ClusterFunctor.h:54