OpenMS  2.7.0
Public Types | Public Member Functions | Private Attributes | List of all members
ClusteringGrid Class Reference

data structure to store 2D data to be clustered e.g. (m/z, retention time) coordinates from multiplex filtering More...

#include <OpenMS/COMPARISON/CLUSTERING/ClusteringGrid.h>

Collaboration diagram for ClusteringGrid:
[legend]

Public Types

typedef std::pair< int, int > CellIndex
 
typedef DPosition< 2 > Point
 

Public Member Functions

 ClusteringGrid (const std::vector< double > &grid_spacing_x, const std::vector< double > &grid_spacing_y)
 constructor taking two vectors More...
 
std::vector< double > getGridSpacingX () const
 returns grid spacing in x direction More...
 
std::vector< double > getGridSpacingY () const
 returns grid spacing in y direction More...
 
void addCluster (const CellIndex &cell_index, const int &cluster_index)
 adds a cluster to this grid cell More...
 
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 More...
 
void removeAllClusters ()
 removes all clusters from this grid (and hence all cells) More...
 
std::list< int > getClusters (const CellIndex &cell_index) const
 returns clusters in this grid cell More...
 
CellIndex getIndex (const Point &position) const
 returns grid cell index (i,j) for the positions (x,y) More...
 
bool isNonEmptyCell (const CellIndex &cell_index) const
 checks if there are clusters at this cell index More...
 
int getCellCount () const
 returns number of grid cells occupied by one or more clusters More...
 

Private Attributes

const std::vector< double > grid_spacing_x_
 spacing of the grid in x and y direction More...
 
const std::vector< double > grid_spacing_y_
 
std::pair< double, double > range_x_
 [min, max] of the grid in x and y direction More...
 
std::pair< double, double > range_y_
 
std::map< CellIndex, std::list< int > > cells_
 grid cell index mapped to a list of clusters in it More...
 

Detailed Description

data structure to store 2D data to be clustered e.g. (m/z, retention time) coordinates from multiplex filtering

See also
LocalClustering

Member Typedef Documentation

◆ CellIndex

typedef std::pair<int,int> CellIndex

coordinates of a grid cell

◆ Point

typedef DPosition<2> Point

coordinates in x-y-plane

Constructor & Destructor Documentation

◆ ClusteringGrid()

ClusteringGrid ( const std::vector< double > &  grid_spacing_x,
const std::vector< double > &  grid_spacing_y 
)

constructor taking two vectors

Parameters
grid_spacing_xgrid spacing in x direction
grid_spacing_ygrid spacing in y direction
Note
Vectors are assumed to be sorted.

Member Function Documentation

◆ addCluster()

void addCluster ( const CellIndex cell_index,
const int &  cluster_index 
)

adds a cluster to this grid cell

Parameters
cell_indexcell index (i,j) on the grid
cluster_indexindex of the cluster in the cluster list

Referenced by GridBasedClustering< Metric >::cluster(), GridBasedClustering< Metric >::extendClustersY(), and GridBasedClustering< Metric >::init_().

◆ getCellCount()

int getCellCount ( ) const

returns number of grid cells occupied by one or more clusters

Returns
number of non-empty cells

◆ getClusters()

std::list<int> getClusters ( const CellIndex cell_index) const

returns clusters in this grid cell

Parameters
cell_indexcell index (i,j) on the grid
Returns
list of cluster indices (from the list of clusters) which are centred in this cell

Referenced by GridBasedClustering< Metric >::extendClustersY(), and GridBasedClustering< Metric >::findNearestNeighbour_().

◆ getGridSpacingX()

std::vector<double> getGridSpacingX ( ) const

returns grid spacing in x direction

Referenced by GridBasedClustering< Metric >::extendClustersY().

◆ getGridSpacingY()

std::vector<double> getGridSpacingY ( ) const

returns grid spacing in y direction

Referenced by GridBasedClustering< Metric >::extendClustersY().

◆ getIndex()

CellIndex getIndex ( const Point position) const

returns grid cell index (i,j) for the positions (x,y)

Parameters
positioncoordinates (x,y) on the grid
Returns
cell index (i,j) of the cell in which (x,y) lies

Referenced by GridBasedClustering< Metric >::cluster(), GridBasedClustering< Metric >::extendClustersY(), GridBasedClustering< Metric >::findNearestNeighbour_(), and GridBasedClustering< Metric >::init_().

◆ isNonEmptyCell()

bool isNonEmptyCell ( const CellIndex cell_index) const

checks if there are clusters at this cell index

Parameters
cell_indexcell index (i,j) on the grid
Returns
true if there are clusters in this cell
Exceptions
Exception::IllegalArgumentif the coordinates (x,y) lie outside the grid.
Exception::InvalidValueif one of the two indices is negative.

Referenced by GridBasedClustering< Metric >::extendClustersY(), and GridBasedClustering< Metric >::findNearestNeighbour_().

◆ removeAllClusters()

void removeAllClusters ( )

removes all clusters from this grid (and hence all cells)

◆ removeCluster()

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

Parameters
cell_indexcell index (i,j) on the grid
cluster_indexindex of the cluster in the cluster list

Referenced by GridBasedClustering< Metric >::cluster(), GridBasedClustering< Metric >::extendClustersY(), and GridBasedClustering< Metric >::init_().

Member Data Documentation

◆ cells_

std::map<CellIndex, std::list<int> > cells_
private

grid cell index mapped to a list of clusters in it

◆ grid_spacing_x_

const std::vector<double> grid_spacing_x_
private

spacing of the grid in x and y direction

◆ grid_spacing_y_

const std::vector<double> grid_spacing_y_
private

◆ range_x_

std::pair<double,double> range_x_
private

[min, max] of the grid in x and y direction

◆ range_y_

std::pair<double,double> range_y_
private