26#include <unordered_map>
41 MinimumDistance(
const int& cluster_index,
const int& nearest_neighbour_index,
const double& distance);
98 template <
typename Metric>
110 typedef std::unordered_multimap<int, MultisetIterator>::const_iterator
NNIterator;
218 const std::vector<int>&
B1 =
cluster1.getPropertiesB();
219 const std::vector<int>&
B2 =
cluster2.getPropertiesB();
220 std::vector<int>
new_B;
322 double box1x_min = (*c1).getBoundingBox().minX();
323 double box1x_max = (*c1).getBoundingBox().maxX();
324 double box1y_min = (*c1).getBoundingBox().minY();
325 double box1y_max = (*c1).getBoundingBox().maxY();
326 double box2x_min = (*c2).getBoundingBox().minX();
327 double box2x_max = (*c2).getBoundingBox().maxX();
328 double box2y_min = (*c2).getBoundingBox().minY();
329 double box2y_max = (*c2).getBoundingBox().maxY();
350 std::vector<int>
points1 = (*c1).getPoints();
351 std::vector<int>
points2 = (*c2).getPoints();
459 std::unordered_multimap<int, std::multiset<MinimumDistance>::const_iterator>
reverse_nns_;
498 std::map<int, GridBasedCluster>::iterator iterator =
clusters_.
begin();
533 int A1 =
c1.getPropertyA();
534 int A2 =
c2.getPropertyA();
537 if (
A1 == -1 ||
A2 == -1)
543 if (
A1 !=
A2)
return true;
545 std::vector<int>
B1 =
c1.getPropertiesB();
546 std::vector<int>
B2 =
c2.getPropertiesB();
585 for (
int i = -1; i <= 1; ++i)
587 for (
int j = -1;
j <= 1; ++
j)
data structure to store 2D data to be clustered e.g. (m/z, retention time) coordinates from multiplex...
Definition ClusteringGrid.h:30
CellIndex getIndex(const Point &position) const
returns grid cell index (i,j) for the positions (x,y)
void removeCluster(const CellIndex &cell_index, const int &cluster_index)
removes a cluster from this grid cell and removes the cell if no other cluster left
std::vector< double > getGridSpacingY() const
returns grid spacing in y direction
std::pair< int, int > CellIndex
Definition ClusteringGrid.h:35
std::list< int > getClusters(const CellIndex &cell_index) const
returns clusters in this grid cell
bool isNonEmptyCell(const CellIndex &cell_index) const
checks if there are clusters at this cell index
void addCluster(const CellIndex &cell_index, const int &cluster_index)
adds a cluster to this grid cell
std::vector< double > getGridSpacingX() const
returns grid spacing in x direction
const_iterator begin() const
Non-mutable begin iterator.
Definition DPosition.h:348
CoordinateType getY() const
Name accessor for the second dimension. Only for DPosition<2>, for visualization.
Definition DPosition.h:147
CoordinateType getX() const
Name accessor for the first dimension. Only for DPosition<2>, for visualization.
Definition DPosition.h:140
const_iterator end() const
Non-mutable end iterator.
Definition DPosition.h:354
static constexpr Size size()
Returns the number of dimensions.
Definition DPosition.h:304
Invalid value exception.
Definition Exception.h:306
basic data structure for clustering
Definition GridBasedCluster.h:23
2D hierarchical clustering implementation optimized for large data sets containing many small cluster...
Definition GridBasedClustering.h:101
void removeSmallClustersY(double threshold_y)
removes clusters with bounding box dimension in y-direction below certain threshold
Definition GridBasedClustering.h:399
std::map< int, GridBasedCluster > getResults() const
returns final results (mapping of cluster indices to clusters)
Definition GridBasedClustering.h:419
bool findNearestNeighbour_(const GridBasedCluster &cluster, int cluster_index)
determines the nearest neighbour for each cluster
Definition GridBasedClustering.h:577
std::unordered_map< int, std::multiset< MinimumDistance >::const_iterator > distance_it_for_cluster_idx_
cluster index to distance iterator lookup table for finding out which clusters need to be updated fas...
Definition GridBasedClustering.h:465
bool mergeVeto_(const GridBasedCluster &c1, const GridBasedCluster &c2) const
checks if two clusters can be merged Each point in a cluster can (optionally) have two properties A a...
Definition GridBasedClustering.h:531
void init_(const std::vector< double > &data_x, const std::vector< double > &data_y, const std::vector< int > &properties_A, const std::vector< int > &properties_B)
initialises all data structures
Definition GridBasedClustering.h:475
ClusteringGrid grid_
grid on which the position of the clusters are registered used in cluster method
Definition GridBasedClustering.h:435
void extendClustersY()
extends clusters in y-direction if possible (merges clusters further in y-direction,...
Definition GridBasedClustering.h:272
Metric metric_
metric for measuring the distance between points in the 2D plane
Definition GridBasedClustering.h:429
GridBasedClustering(Metric metric, const std::vector< double > &data_x, const std::vector< double > &data_y, std::vector< double > grid_spacing_x, std::vector< double > grid_spacing_y)
initialises all data structures
Definition GridBasedClustering.h:142
GridBasedCluster::Rectangle Rectangle
Definition GridBasedClustering.h:107
std::multiset< MinimumDistance > distances_
list of minimum distances stores the smallest of the distances in the head
Definition GridBasedClustering.h:453
GridBasedClustering(Metric metric, const std::vector< double > &data_x, const std::vector< double > &data_y, const std::vector< int > &properties_A, const std::vector< int > &properties_B, std::vector< double > grid_spacing_x, std::vector< double > grid_spacing_y)
initialises all data structures
Definition GridBasedClustering.h:123
void cluster()
performs the hierarchical clustering (merges clusters until their dimension exceeds that of cell)
Definition GridBasedClustering.h:158
GridBasedCluster::Point Point
cluster centre, cluster bounding box, grid index
Definition GridBasedClustering.h:106
std::unordered_multimap< int, std::multiset< MinimumDistance >::const_iterator > reverse_nns_
reverse nearest neighbor lookup table for finding out which clusters need to be updated faster
Definition GridBasedClustering.h:459
std::multiset< MinimumDistance >::const_iterator MultisetIterator
Definition GridBasedClustering.h:109
std::map< int, GridBasedCluster > clusters_
list of clusters maps cluster indices to clusters
Definition GridBasedClustering.h:441
std::map< int, GridBasedCluster > clusters_final_
list of final clusters i.e. clusters that are no longer merged
Definition GridBasedClustering.h:447
std::unordered_multimap< int, MultisetIterator >::const_iterator NNIterator
Definition GridBasedClustering.h:110
void eraseMinDistance_(const std::multiset< MinimumDistance >::const_iterator it)
remove minimum distance object and its related data
Definition GridBasedClustering.h:644
ClusteringGrid::CellIndex CellIndex
Definition GridBasedClustering.h:108
basic data structure for distances between clusters
Definition GridBasedClustering.h:35
MinimumDistance()
hide default constructor
bool operator>(const MinimumDistance &other) const
int getClusterIndex() const
returns cluster index
MinimumDistance(const int &cluster_index, const int &nearest_neighbour_index, const double &distance)
constructor
int nearest_neighbour_index_
index of the nearest neighbour of the above cluster
Definition GridBasedClustering.h:74
int getNearestNeighbourIndex() const
returns index of nearest cluster
double distance_
distance between cluster and its nearest neighbour
Definition GridBasedClustering.h:79
bool operator==(const MinimumDistance &other) const
int cluster_index_
index in the cluster list
Definition GridBasedClustering.h:69
bool operator<(const MinimumDistance &other) const
operators for comparisons (for multiset)
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
void setProgress(SignedSize value) const
Sets the current progress.
void endProgress(UInt64 bytes_processed=0) const
void startProgress(SignedSize begin, SignedSize end, const std::string &label) const
Initializes the progress display.
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19