This class is an interface to the cluster algorithm described at http://bonsai.hgc.jp/~mdehoon/software/cluster/. More...
#include <ms_treecluster.hpp>
Public Types | |
enum | TREE_CLUSTER_DISTANCE { TCD_CORRELATION , TCD_ABS_CORRELATION , TCD_UNCENTERED_CORRELATION , TCD_ABS_UNCENTERED_CORRELATION , TCD_SPEARMANS_RANK_CORRELATION , TCD_KENDALLS_TAU_CORRELATION , TCD_EUCLIDEAN , TCD_CITY_BLOCK } |
Flags for cluster(). More... | |
Public Member Functions | |
ms_treecluster (const ms_treecluster &right) | |
Copying constructor. | |
ms_treecluster (int rows, int columns) | |
Constructor. | |
~ms_treecluster () | |
Destructor. | |
void | appendErrors (const ms_errors &src) |
Copies all errors from another instance and appends them at the end of own list. | |
void | clearAllErrors () |
Remove all errors from the current list of errors. | |
bool | cluster (TREE_CLUSTER_DISTANCE tcd, ms_mascotresults::TREE_CLUSTER_METHOD tcm, const std::vector< double > &weight, std::vector< int > &left, std::vector< int > &right, std::vector< double > &distance, bool transpose=false) |
Perform the clustering and populate the left, right and distance vectors with the results. | |
void | copyFrom (const ms_errors *right) |
Use this member to make a copy of another instance. | |
void | copyFrom (const ms_treecluster *right) |
Copies all data from another instance of the class. | |
void | defaultValues () |
Initialises the instance. | |
const ms_errs * | getErrorHandler () const |
Retrive the error object using this function to get access to all errors and error parameters. | |
int | getLastError () const |
Return the error description of the last error that occurred. | |
std::string | getLastErrorString () const |
Return the error description of the last error that occurred. | |
bool | isValid () const |
Call this function to determine if there have been any errors. | |
ms_treecluster & | operator= (const ms_treecluster &right) |
Assignment operator. | |
bool | setRow (int row, std::vector< double > datarow, std::vector< int > maskrow) |
Sets the values for the specified row in the data and mask arrays. | |
This class is an interface to the cluster algorithm described at http://bonsai.hgc.jp/~mdehoon/software/cluster/.
The License agreement for using this excellent Open Source code is included with Mascot Parser; see C Clustering library.
Flags for cluster().
In order to cluster data into groups we need to define what exactly we mean by similar. In the C Clustering Library, eight distance functions are available to measure similarity, or conversely, distance.
See Using enumerated values and static const ints in Perl, Java, Python and C#.
ms_treecluster | ( | int | rows, |
int | columns | ||
) |
Constructor.
rows | is the number of rows in the data |
columns | is the number of columns in the data |
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
|
inherited |
Remove all errors from the current list of errors.
The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.
All messages are accumulated into a list in this object, until clearAllErrors() is called.
See Error Handling.
bool cluster | ( | TREE_CLUSTER_DISTANCE | tcd, |
ms_mascotresults::TREE_CLUSTER_METHOD | tcm, | ||
const std::vector< double > & | weight, | ||
std::vector< int > & | left, | ||
std::vector< int > & | right, | ||
std::vector< double > & | distance, | ||
bool | transpose = false |
||
) |
Perform the clustering and populate the left, right and distance vectors with the results.
Call this function after making rows calls to setRow()
For details of how to use the weight, left, right and distance parameters, see Using STL vector classes vectori, vectord and VectorString in Perl, Java, Python and C#.
The function returns a list of items, nodes and distances in the left, right and distance vectors.
The original elements are numbered {0, . . . , nelements-1} and the nodes are numbered {-1, . . . , -(nelements-1)}.
The left, right and distance vectors are guaranteed to have the same number of elements, and for example, left[2], right[2], distance[2] all correspond to the same 'node'.
Element 0 from each of the three vectors corresponds to node -1, element 1 to node -2, element 2 to node -3 etc.
See also ms_peptidesummary::getTreeClusterNodes
[in] | tcd | is used to define which method should be used as a measure of the distance between data items. See ms_treecluster::TREE_CLUSTER_DISTANCE. |
[in] | tcm | Specifies which type of hierarchical clustering is used. See ms_mascotresults::TREE_CLUSTER_METHOD |
[in] | weight | Dimension: columns (as passed to the constructor) if transpose is false, or rows (as passed to the constructor) if transpose is true. A zero length array is also accepted, in which case this is replaced by an array of 1s - i.e. all the same weight |
[out] | left | returns an array, size rows -1 (as passed to the constructor) of element and node numbers |
[out] | right | returns an array, size rows -1 (as passed to the constructor) of element and node numbers. |
[out] | distance | returns an array, size rows -1 (as passed to the constructor) of distances between the elements/nodes |
[in] | transpose | indicates whether row-wise or column-wise clustering is being performed. If transpose is false, rows are being clustered. Otherwise, columns are being clustered. |
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
void copyFrom | ( | const ms_treecluster * | right | ) |
Copies all data from another instance of the class.
Called by copy constructor, or may be called directly.
right | is the object to copy values from |
void defaultValues | ( | ) |
Initialises the instance.
Allocates internal memory based on the number of rows and columns passed to the constructor
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
ms_treecluster & operator= | ( | const ms_treecluster & | right | ) |
Assignment operator.
Used from C++
right | is the object to copy values from |
bool setRow | ( | int | row, |
std::vector< double > | datarow, | ||
std::vector< int > | maskrow | ||
) |
Sets the values for the specified row in the data and mask arrays.
For details of how to use the datarow and maskrow parameters, see Using STL vector classes vectori, vectord and VectorString in Perl, Java, Python and C#.
row | is the zero based row number. Must be in the range 0..rows-1 passed to the constructor |
datarow | is an array of the data points for the specified row. The length of the datarow array must be the same as columns passed to the constructor. |
maskrow | is an array which specifies which elements in the data array, (if any), are missing. If mask[i][j]==0, then data[i][j] is missing. An empty array may be passed to show that no elements in the data array are missing. However, if a non empty array is passed, then the length of the maskrow array must be the same as columns passed to the constructor. |