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

Private Attributes

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

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
[in]grid_spacing_xgrid spacing in x direction
[in]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
[in]cell_indexcell index (i,j) on the grid
[in]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
[in]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
[in]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
[in]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
[in]cell_indexcell index (i,j) on the grid
[in]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