Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
GridBasedClustering.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2015.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Lars Nilse $
32 // $Authors: Lars Nilse $
33 // --------------------------------------------------------------------------
34 
40 
41 #include <cmath>
42 #include <limits>
43 #include <map>
44 #include <queue>
45 #include <vector>
46 #include <algorithm>
47 #include <iostream>
48 
49 #ifndef OPENMS_COMPARISON_CLUSTERING_GRIDBASEDCLUSTERING_H
50 #define OPENMS_COMPARISON_CLUSTERING_GRIDBASEDCLUSTERING_H
51 
52 namespace OpenMS
53 {
54 
58  class OPENMS_DLLAPI MinimumDistance
59  {
60 public:
61 
65  MinimumDistance(const int& cluster_index, const int& nearest_neighbour_index, const double& distance);
66 
70  int getClusterIndex() const;
71 
75  int getNearestNeighbourIndex() const;
76 
81  bool operator<(MinimumDistance other) const;
82  bool operator>(MinimumDistance other) const;
83  bool operator==(MinimumDistance other) const;
84 
85 private:
86 
89 
94 
99 
103  double distance_;
104 
105  };
106 
122  template <typename Metric>
124  public ProgressLogger
125  {
126 public:
130  typedef GridBasedCluster::Point Point; // DPosition<2>
131  typedef GridBasedCluster::Rectangle Rectangle; // DBoundingBox<2>
132  typedef ClusteringGrid::CellIndex CellIndex; // std::pair<int,int>
133 
144  GridBasedClustering(Metric metric, const std::vector<double>& data_x,
145  const std::vector<double>& data_y, const std::vector<int>& properties_A,
146  const std::vector<int>& properties_B, std::vector<double> grid_spacing_x,
147  std::vector<double> grid_spacing_y) :
148  metric_(metric),
149  grid_(grid_spacing_x, grid_spacing_y)
150  {
151  init_(data_x, data_y, properties_A, properties_B);
152  }
153 
162  GridBasedClustering(Metric metric, const std::vector<double>& data_x,
163  const std::vector<double>& data_y, std::vector<double> grid_spacing_x,
164  std::vector<double> grid_spacing_y) :
165  metric_(metric),
166  grid_(grid_spacing_x, grid_spacing_y)
167  {
168  // set properties A and B to -1, i.e. ignore properties when clustering
169  std::vector<int> properties_A(data_x.size(), -1);
170  std::vector<int> properties_B(data_x.size(), -1);
171  init_(data_x, data_y, properties_A, properties_B);
172  }
173 
178  void cluster()
179  {
180  // progress logger
181  Size clusters_start = clusters_.size();
182  startProgress(0, clusters_start, "clustering");
183 
184  MinimumDistance zero_distance(-1, -1, 0);
185  typedef std::multiset<MinimumDistance>::iterator MultisetIterator;
186 
187  // combine clusters until all have been moved to the final list
188  while (clusters_.size() > 0)
189  {
190  setProgress(clusters_start - clusters_.size());
191 
192  MultisetIterator smallest_distance_it = distances_.lower_bound(zero_distance);
193  MinimumDistance smallest_distance(*smallest_distance_it);
194  distances_.erase(smallest_distance_it);
195  int cluster_index1 = smallest_distance.getClusterIndex();
196  int cluster_index2 = smallest_distance.getNearestNeighbourIndex();
197 
198  // update cluster list
199  GridBasedCluster cluster1 = clusters_.find(cluster_index1)->second;
200  GridBasedCluster cluster2 = clusters_.find(cluster_index2)->second;
201  std::vector<int> points1 = cluster1.getPoints();
202  std::vector<int> points2 = cluster2.getPoints();
203  std::vector<int> new_points;
204  new_points.reserve(points1.size() + points2.size());
205  new_points.insert(new_points.end(), points1.begin(), points1.end());
206  new_points.insert(new_points.end(), points2.begin(), points2.end());
207 
208  double new_x = (cluster1.getCentre().getX() * points1.size() + cluster2.getCentre().getX() * points2.size()) / (points1.size() + points2.size());
209  double new_y = (cluster1.getCentre().getY() * points1.size() + cluster2.getCentre().getY() * points2.size()) / (points1.size() + points2.size());
210 
211  Rectangle box1 = cluster1.getBoundingBox();
212  Rectangle box2 = cluster2.getBoundingBox();
213  Rectangle new_box(box1);
214  new_box.enlarge(box2.minPosition());
215  new_box.enlarge(box2.maxPosition());
216 
217  // Properties A of both clusters should by now be the same. The merge veto has been checked
218  // when a new entry to the minimum distance list was added, @see findNearestNeighbour_.
219  if (cluster1.getPropertyA() != cluster2.getPropertyA())
220  {
221  throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Property A of both clusters not the same. ", "A");
222  }
223  int new_A = cluster1.getPropertyA();
224 
225  std::vector<int> B1 = cluster1.getPropertiesB();
226  std::vector<int> B2 = cluster2.getPropertiesB();
227  std::vector<int> new_B;
228  new_B.reserve(B1.size() + B2.size());
229  new_B.insert(new_B.end(), B1.begin(), B1.end());
230  new_B.insert(new_B.end(), B2.begin(), B2.end());
231 
232  GridBasedCluster new_cluster(DPosition<2>(new_x, new_y), new_box, new_points, new_A, new_B);
233 
234  clusters_.erase(clusters_.find(cluster_index1));
235  clusters_.erase(clusters_.find(cluster_index2));
236  clusters_.insert(std::make_pair(cluster_index1, new_cluster));
237 
238  // update grid
239  CellIndex cell_for_cluster1 = grid_.getIndex(cluster1.getCentre());
240  CellIndex cell_for_cluster2 = grid_.getIndex(cluster2.getCentre());
241  CellIndex cell_for_new_cluster = grid_.getIndex(DPosition<2>(new_x, new_y));
242 
243  grid_.removeCluster(cell_for_cluster1, cluster_index1);
244  grid_.removeCluster(cell_for_cluster2, cluster_index2);
245  grid_.addCluster(cell_for_new_cluster, cluster_index1);
246 
247  // update minimum distance list
248  std::vector<int> clusters_to_be_updated;
249  clusters_to_be_updated.push_back(cluster_index1); // index of the new cluster
250 
251  MultisetIterator it = distances_.begin();
252  while (it != distances_.end())
253  {
254  MinimumDistance distance(*it);
255  if (distance.getClusterIndex() == cluster_index2)
256  {
257  // distance.getClusterIndex() == cluster_index1 should never happen since this entry has already been erased.
258  // Cluster 2 no longer exists. Hence only remove the entry from the list of minimum distances.
259  distances_.erase(it++);
260  }
261  else if (distance.getNearestNeighbourIndex() == cluster_index1 || distance.getNearestNeighbourIndex() == cluster_index2)
262  {
263  clusters_to_be_updated.push_back(distance.getClusterIndex());
264  distances_.erase(it++);
265  }
266  else
267  {
268  ++it;
269  }
270  }
271 
272  for (std::vector<int>::const_iterator cluster_index = clusters_to_be_updated.begin(); cluster_index != clusters_to_be_updated.end(); ++cluster_index)
273  {
274  if (findNearestNeighbour_(clusters_.find(*cluster_index)->second, *cluster_index))
275  {
276  GridBasedCluster c = clusters_.find(*cluster_index)->second;
277  grid_.removeCluster(grid_.getIndex(c.getCentre()), *cluster_index); // remove from grid
278  clusters_.erase(clusters_.find(*cluster_index)); // remove from cluster list
279  }
280  }
281 
282  }
283 
284  endProgress();
285  }
286 
292  {
293 
294  // construct new grid (grid only in x-direction, single cell in y-direction)
295  std::vector<double> grid_spacing_x = grid_.getGridSpacingX();
296  std::vector<double> grid_spacing_y = grid_.getGridSpacingY();
297  std::vector<double> grid_spacing_y_new;
298  grid_spacing_y_new.push_back(grid_spacing_y.front());
299  grid_spacing_y_new.push_back(grid_spacing_y.back());
300  ClusteringGrid grid_x_only(grid_spacing_x, grid_spacing_y_new);
301 
302  // register final clusters on the new grid
303  for (std::map<int, GridBasedCluster>::iterator it = clusters_final_.begin(); it != clusters_final_.end(); ++it)
304  {
305  int cluster_index = it->first;
306  GridBasedCluster cluster = it->second;
307  grid_x_only.addCluster(grid_x_only.getIndex(cluster.getCentre()), cluster_index);
308  }
309 
310 
311  // scan through x on the grid
312  for (unsigned cell = 0; cell < grid_spacing_x.size(); ++cell)
313  {
314  CellIndex grid_index(cell, 1);
315  if (grid_x_only.isNonEmptyCell(grid_index))
316  {
317  std::list<int> cluster_indices = grid_x_only.getClusters(grid_index); // indices of clusters in this x-range
318  if (cluster_indices.size() > 1)
319  {
320  // First, order the clusters in ascending y.
321  std::list<GridBasedCluster> cluster_list; // list to order clusters in y
322  std::map<GridBasedCluster, int> index_list; // allows us to keep track of cluster indices after sorting
323  for (std::list<int>::iterator it = cluster_indices.begin(); it != cluster_indices.end(); ++it)
324  {
325  cluster_list.push_back(clusters_final_.find(*it)->second);
326  index_list.insert(std::make_pair(clusters_final_.find(*it)->second, *it));
327  }
328  cluster_list.sort();
329 
330  // Now check if two adjacent clusters c1 and c2 can be merged.
331  std::list<GridBasedCluster>::iterator c1 = cluster_list.begin();
332  std::list<GridBasedCluster>::iterator c2 = cluster_list.begin();
333  ++c1;
334  while (c1 != cluster_list.end())
335  {
336  double centre1x = (*c1).getCentre().getX();
337  double centre1y = (*c1).getCentre().getY();
338  double centre2x = (*c2).getCentre().getX();
339  double centre2y = (*c2).getCentre().getY();
340 
341  double box1x_min = (*c1).getBoundingBox().minX();
342  double box1x_max = (*c1).getBoundingBox().maxX();
343  double box1y_min = (*c1).getBoundingBox().minY();
344  double box1y_max = (*c1).getBoundingBox().maxY();
345  double box2x_min = (*c2).getBoundingBox().minX();
346  double box2x_max = (*c2).getBoundingBox().maxX();
347  double box2y_min = (*c2).getBoundingBox().minY();
348  double box2y_max = (*c2).getBoundingBox().maxY();
349 
350  //double y_range1 = box1y_max - box1y_min;
351  //double y_range2 = box2y_max - box2y_min;
352  //double y_gap = box1y_min - box2y_max;
353 
354  // Is there an overlap of the two clusters in x?
355  bool overlap = (box1x_min <= box2x_max && box1x_min >= box2x_min) || (box1x_max >= box2x_min && box1x_max <= box2x_max);
356 
357  // Is the x-centre of one cluster in the x-range of the other?
358  //bool centre_in_range1 = (box2x_min <= centre1x && centre1x <= box2x_max);
359  //bool centre_in_range2 = (box1x_min <= centre2x && centre2x <= box1x_max);
360 
361  // Is the y-gap between the two clusters smaller than 1/s of their average y-range?
362  //double s = 6; // scaling factor
363  //bool clusters_close = (y_gap * s <= (y_range1 - y_range2)/2);
364 
365  // Shall we merge the two adjacent clusters?
366  //if ((centre_in_range1 || centre_in_range2) && clusters_close)
367  if (overlap)
368  {
369  std::vector<int> points1 = (*c1).getPoints();
370  std::vector<int> points2 = (*c2).getPoints();
371  std::vector<int> new_points;
372  new_points.reserve(points1.size() + points2.size());
373  new_points.insert(new_points.end(), points1.begin(), points1.end());
374  new_points.insert(new_points.end(), points2.begin(), points2.end());
375 
376  double new_x = (centre1x * points1.size() + centre2x * points2.size()) / (points1.size() + points2.size());
377  double new_y = (centre1y * points1.size() + centre2y * points2.size()) / (points1.size() + points2.size());
378 
379  double min_x = std::min(box1x_min, box2x_min);
380  double min_y = std::min(box1y_min, box2y_min);
381  double max_x = std::max(box1x_max, box2x_max);
382  double max_y = std::max(box1y_max, box2y_max);
383 
384  Point new_centre(new_x, new_y);
385  Point position_min(min_x, min_y);
386  Point position_max(max_x, max_y);
387  Rectangle new_bounding_box(position_min, position_max);
388 
389  GridBasedCluster new_cluster(new_centre, new_bounding_box, new_points);
390 
391  // update final cluster list
392  clusters_final_.erase(clusters_final_.find(index_list.find(*c1)->second));
393  clusters_final_.erase(clusters_final_.find(index_list.find(*c2)->second));
394  clusters_final_.insert(std::make_pair(index_list.find(*c1)->second, new_cluster));
395 
396  // update grid
397  CellIndex cell_for_cluster1 = grid_x_only.getIndex((*c1).getCentre());
398  CellIndex cell_for_cluster2 = grid_x_only.getIndex((*c2).getCentre());
399  CellIndex cell_for_new_cluster = grid_x_only.getIndex(new_centre);
400 
401  grid_x_only.removeCluster(cell_for_cluster1, index_list.find(*c1)->second);
402  grid_x_only.removeCluster(cell_for_cluster2, index_list.find(*c2)->second);
403  grid_x_only.addCluster(cell_for_new_cluster, index_list.find(*c1)->second);
404  }
405  ++c1;
406  ++c2;
407  }
408  }
409  }
410  }
411 
412  }
413 
418  void removeSmallClustersY(double threshold_y)
419  {
420  std::map<int, GridBasedCluster>::iterator it = clusters_final_.begin();
421  while (it != clusters_final_.end())
422  {
423  Rectangle box = it->second.getBoundingBox();
424  if (box.maxY() - box.minY() < threshold_y)
425  {
426  clusters_final_.erase(it++);
427  }
428  else
429  {
430  ++it;
431  }
432  }
433  }
434 
438  std::map<int, GridBasedCluster> getResults() const
439  {
440  return clusters_final_;
441  }
442 
443 private:
444 
448  Metric metric_;
449 
455 
460  std::map<int, GridBasedCluster> clusters_;
461 
466  std::map<int, GridBasedCluster> clusters_final_;
467 
472  std::multiset<MinimumDistance> distances_;
473 
482  void init_(const std::vector<double>& data_x, const std::vector<double>& data_y,
483  const std::vector<int>& properties_A, const std::vector<int>& properties_B)
484  {
485  // fill the grid with points to be clustered (initially each cluster contains a single point)
486  for (unsigned i = 0; i < data_x.size(); ++i)
487  {
488  Point position(data_x[i], data_y[i]);
489  Rectangle box(position, position);
490 
491  std::vector<int> pi; // point indices
492  pi.push_back(i);
493  std::vector<int> pb; // properties B
494  pb.push_back(properties_B[i]);
495 
496  // add to cluster list
497  GridBasedCluster cluster(position, box, pi, properties_A[i], pb);
498  clusters_.insert(std::make_pair(i, cluster));
499 
500  // register on grid
501  grid_.addCluster(grid_.getIndex(position), i);
502  }
503 
504  // fill list of minimum distances
505  std::map<int, GridBasedCluster>::iterator iterator = clusters_.begin();
506  while (iterator != clusters_.end())
507  {
508  int cluster_index = iterator->first;
509  GridBasedCluster cluster = iterator->second;
510 
511  if (findNearestNeighbour_(cluster, cluster_index))
512  {
513  // remove from grid
514  grid_.removeCluster(grid_.getIndex(cluster.getCentre()), cluster_index);
515  // remove from cluster list
516  clusters_.erase(iterator++);
517  }
518  else
519  {
520  ++iterator;
521  }
522  }
523  }
524 
539  {
540  int A1 = c1.getPropertyA();
541  int A2 = c2.getPropertyA();
542  std::vector<int> B1 = c1.getPropertiesB();
543  std::vector<int> B2 = c2.getPropertiesB();
544 
545  // check if any of the properties A and B is not set i.e. =-1
546  if (A1 == -1 || A2 == -1 || std::find(B1.begin(), B1.end(), -1) != B1.end() || std::find(B2.begin(), B2.end(), -1) != B2.end())
547  {
548  return false;
549  }
550 
551  // Will the merged cluster have the same properties A?
552  bool vetoA = !(A1 == A2);
553 
554  // Will the merged cluster have different properties B?
555  // (Hence the intersection of properties B of cluster 1 and cluster 2 should be empty.)
556  std::vector<int> B_intersection;
557  sort(B1.begin(), B1.end());
558  sort(B2.begin(), B2.end());
559  set_intersection(B1.begin(), B1.end(), B2.begin(), B2.end(), back_inserter(B_intersection));
560  bool vetoB = !B_intersection.empty();
561 
562  return vetoA || vetoB;
563  }
564 
579  {
580  Point centre = cluster.getCentre();
581  CellIndex cell_index = grid_.getIndex(centre);
582 
583  double min_dist = 0;
584  int nearest_neighbour = -1;
585 
586  // search in the grid cell and its 8 neighbouring cells for the nearest neighbouring cluster
587  for (int i = -1; i <= 1; ++i)
588  {
589  for (int j = -1; j <= 1; ++j)
590  {
591  CellIndex cell_index2(cell_index);
592  cell_index2.first += i;
593  cell_index2.second += j;
594  if (grid_.isNonEmptyCell(cell_index2))
595  {
596  std::list<int> cluster_indices = grid_.getClusters(cell_index2);
597  for (std::list<int>::const_iterator cluster_index2 = cluster_indices.begin(); cluster_index2 != cluster_indices.end(); ++cluster_index2)
598  {
599  if (*cluster_index2 != cluster_index)
600  {
601  GridBasedCluster cluster2 = clusters_.find(*cluster_index2)->second;
602  Point centre2 = cluster2.getCentre();
603  double distance = metric_(centre, centre2);
604  bool veto = mergeVeto_(cluster, cluster2); // If clusters cannot be merged anyhow, they are no nearest neighbours.
605  if (!veto && (distance < min_dist || nearest_neighbour == -1))
606  {
607  min_dist = distance;
608  nearest_neighbour = *cluster_index2;
609  }
610  }
611  }
612  }
613  }
614  }
615 
616  if (nearest_neighbour == -1)
617  {
618  // no other cluster nearby, hence move the cluster to the final results
619  clusters_final_.insert(std::make_pair(cluster_index, clusters_.find(cluster_index)->second));
620  return true;
621  }
622 
623  // add to the list of minimal distances
624  distances_.insert(MinimumDistance(cluster_index, nearest_neighbour, min_dist));
625  return false;
626  }
627 
628  };
629 
630 }
631 #endif /* OPENMS_COMPARISON_CLUSTERING_GRIDBASEDCLUSTERING_H */
CoordinateType maxY() const
Accessor for max_ coordinate maximum.
Definition: DIntervalBase.h:259
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::pair< int, int > CellIndex
Definition: ClusteringGrid.h:57
double distance_
distance between cluster and its nearest neighbour
Definition: GridBasedClustering.h:103
std::vector< double > getGridSpacingX() const
returns grid spacing in x direction
std::map< int, GridBasedCluster > clusters_final_
list of final clusters i.e. clusters that are no longer merged
Definition: GridBasedClustering.h:466
void enlarge(const PositionType &p)
Enlarges the bounding box such that it contains a position.
Definition: DBoundingBox.h:122
std::multiset< MinimumDistance > distances_
list of minimum distances stores the smallest of the distances in the head
Definition: GridBasedClustering.h:472
GridBasedCluster::Point Point
cluster centre, cluster bounding box, grid index
Definition: GridBasedClustering.h:130
std::list< int > getClusters(const CellIndex &cell_index) const
returns clusters in this grid cell
void removeSmallClustersY(double threshold_y)
removes clusters with bounding box dimension in y-direction below certain threshold ...
Definition: GridBasedClustering.h:418
bool findNearestNeighbour_(GridBasedCluster cluster, int cluster_index)
determines the nearest neighbour for each cluster
Definition: GridBasedClustering.h:578
std::vector< double > getGridSpacingY() const
returns grid spacing in y direction
void cluster()
performs the hierarchical clustering (merges clusters until their dimension exceeds that of cell) ...
Definition: GridBasedClustering.h:178
const double c
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
ClusteringGrid grid_
grid on which the position of the clusters are registered used in cluster method
Definition: GridBasedClustering.h:454
GridBasedCluster::Rectangle Rectangle
Definition: GridBasedClustering.h:131
std::map< int, GridBasedCluster > clusters_
list of clusters maps cluster indices to clusters
Definition: GridBasedClustering.h:460
Point getCentre() const
returns cluster centre
void extendClustersY()
extends clusters in y-direction if possible (merges clusters further in y-direction, i.e. clusters can now span multiple cells)
Definition: GridBasedClustering.h:291
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:162
bool isNonEmptyCell(const CellIndex &cell_index) const
checks if there are clusters at this cell index
2D hierarchical clustering implementation optimized for large data sets containing many small cluster...
Definition: GridBasedClustering.h:123
int getClusterIndex() const
returns cluster index
CoordinateType minY() const
Accessor for max_ coordinate minimum.
Definition: DIntervalBase.h:247
void addCluster(const CellIndex &cell_index, const int &cluster_index)
adds a cluster to this grid cell
void endProgress() const
Ends the progress display.
data structure to store 2D data to be clustered e.g. (m/z, retention time) coordinates from multiplex...
Definition: ClusteringGrid.h:51
int cluster_index_
index in the cluster list
Definition: GridBasedClustering.h:93
int getPropertyA() const
returns property A
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:482
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:144
Metric metric_
metric for measuring the distance between points in the 2D plane
Definition: GridBasedClustering.h:448
int getNearestNeighbourIndex() const
returns index of nearest cluster
std::vector< int > getPropertiesB() const
returns properties B of all points
std::map< int, GridBasedCluster > getResults() const
returns final results (mapping of cluster indices to clusters)
Definition: GridBasedClustering.h:438
Invalid value exception.
Definition: Exception.h:336
PositionType const & minPosition() const
Accessor to minimum position.
Definition: DIntervalBase.h:122
CellIndex getIndex(const Point &position) const
returns grid cell index (i,j) for the positions (x,y)
bool mergeVeto_(GridBasedCluster c1, 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:538
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
void startProgress(SignedSize begin, SignedSize end, const String &label) const
Initializes the progress display.
void setProgress(SignedSize value) const
Sets the current progress.
ClusteringGrid::CellIndex CellIndex
Definition: GridBasedClustering.h:132
Rectangle getBoundingBox() const
returns bounding box
PositionType const & maxPosition() const
Accessor to maximum position.
Definition: DIntervalBase.h:128
CoordinateType getY() const
Name accessor for the second dimension. Only for DPosition<2>, for visualization. ...
Definition: DPosition.h:158
basic data structure for distances between clusters
Definition: GridBasedClustering.h:58
basic data structure for clustering
Definition: GridBasedCluster.h:55
int nearest_neighbour_index_
index of the nearest neighbour of the above cluster
Definition: GridBasedClustering.h:98
CoordinateType getX() const
Name accessor for the first dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:151
std::vector< int > getPoints() const
returns indices of points in cluster

OpenMS / TOPP release 2.0.0 Documentation generated on Fri May 29 2015 17:20:24 using doxygen 1.8.9.1