7 #include "rabundvector.hpp"
8 #include "sparsematrix.hpp"
10 /* This class implements the average UPGMA, average neighbor clustering algorithm */
12 /***********************************************************************/
14 AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
15 Cluster(rav, lv, dm, c)
22 /***********************************************************************/
23 //This function returns the tag of the method.
24 string AverageLinkage::getTag() {
29 /***********************************************************************/
30 //This function updates the distance based on the average linkage method.
31 bool AverageLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
33 if ((saveRow != smallRow) || (saveCol != smallCol)) {
34 rowBin = rabund->get(smallRow);
35 colBin = rabund->get(smallCol);
36 totalBin = rowBin + colBin;
41 float oldColCell = colCell->dist;
43 colCell->dist = (colBin * colCell->dist + rowBin * rowCell->dist) / totalBin;
45 //warn user if merge with value above cutoff produces a value below cutoff
46 if ((colCell->dist < cutoff) && ((oldColCell > cutoff) || (rowCell->dist > cutoff)) ) {
47 mothurOut("Warning: merging " + toString(oldColCell) + " with " + toString(rowCell->dist) + ", new value = " + toString(colCell->dist) + ". Results will differ from those if cutoff was used in the read.dist command."); mothurOutEndLine();
53 errorOut(e, "AverageLinkage", "updateDistance");
58 /***********************************************************************/
61 /***********************************************************************/