3 #include "rabundvector.hpp"
4 #include "sparsematrix.hpp"
7 /* This class implements the average UPGMA, average neighbor clustering algorithm */
9 /***********************************************************************/
11 AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
15 /***********************************************************************/
16 //THis function clusters based on the average method
17 void AverageLinkage::update(){
21 vector<int> found(nColCells, 0);
23 int rowBin = rabund->get(smallRow);
24 int colBin = rabund->get(smallCol);
25 int totalBin = rowBin + colBin;
27 for(int i=1;i<nRowCells;i++){
31 if(rowCells[i]->row == smallRow){
32 search = rowCells[i]->column;
35 search = rowCells[i]->row;
38 for(int j=1;j<nColCells;j++){
40 if(colCells[j]->row == search || colCells[j]->column == search){
41 colCells[j]->dist = (colBin * colCells[j]->dist + rowBin * rowCells[i]->dist) / totalBin;
45 if(colCells[j]->vectorMap != NULL){
46 *(colCells[j]->vectorMap) = NULL;
47 colCells[j]->vectorMap = NULL;
54 dMatrix->rmCell(rowCells[i]);
60 for(int i=0;i<nColCells;i++){
62 dMatrix->rmCell(colCells[i]);
67 cout << "Standard Error: " << e.what() << " has occurred in the AverageLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
71 cout << "An unknown error has occurred in the AverageLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
78 /***********************************************************************/