/***********************************************************************/
-AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
- Cluster(rav, lv, dm, c)
+AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+ Cluster(rav, lv, dm, c, s)
{
saveRow = -1;
saveCol = -1;
/***********************************************************************/
-Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-rabund(rav), list(lv), dMatrix(dm)
+Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string m) :
+rabund(rav), list(lv), dMatrix(dm), method(m)
{
/*
cout << "sizeof(MatData): " << sizeof(MatData) << endl;
}
}
//if not merged it you need it for warning
- if (!merged) {
+ if ((!merged) && (method == "average")) {
mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
if (cutOFF > rowCells[i]->dist) { cutOFF = rowCells[i]->dist; mothurOut("changing cutoff to " + toString(cutOFF)); mothurOutEndLine(); }
// could be avoided
for (int i=nColCells-1;i>=0;i--) {
if (foundCol[i] == 0) {
- if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
- mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
- if (cutOFF > colCells[i]->dist) { cutOFF = colCells[i]->dist; mothurOut("changing cutoff to " + toString(cutOFF)); mothurOutEndLine(); }
+ if (method == "average") {
+ if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
+ mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); mothurOutEndLine();
+ if (cutOFF > colCells[i]->dist) { cutOFF = colCells[i]->dist; mothurOut("changing cutoff to " + toString(cutOFF)); mothurOutEndLine(); }
+ }
}
removeCell(colCells[i], -1, i);
}
class Cluster {
public:
- Cluster(RAbundVector*, ListVector*, SparseMatrix*, float);
+ Cluster(RAbundVector*, ListVector*, SparseMatrix*, float, string);
virtual void update(double&);
virtual string getTag() = 0;
virtual void setMapWanted(bool m);
bool mapWanted;
float cutoff;
map<string, int> seq2Bin;
+ string method;
vector<MatVec> seqVec; // contains vectors of cells related to a certain sequence
MatVec rowCells;
class CompleteLinkage : public Cluster {
public:
- CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+ CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
bool updateDistance(MatData& colCell, MatData& rowCell);
string getTag();
class SingleLinkage : public Cluster {
public:
- SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+ SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
void update();
bool updateDistance(MatData& colCell, MatData& rowCell);
string getTag();
class AverageLinkage : public Cluster {
public:
- AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+ AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
bool updateDistance(MatData& colCell, MatData& rowCell);
string getTag();
}
//create cluster
- if (method == "furthest") { cluster = new CompleteLinkage(rabund, list, matrix, cutoff); }
- else if(method == "nearest"){ cluster = new SingleLinkage(rabund, list, matrix, cutoff); }
- else if(method == "average"){ cluster = new AverageLinkage(rabund, list, matrix, cutoff); }
+ if (method == "furthest") { cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
+ else if(method == "nearest"){ cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
+ else if(method == "average"){ cluster = new AverageLinkage(rabund, list, matrix, cutoff, method); }
tag = cluster->getTag();
if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
/***********************************************************************/
-CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
- Cluster(rav, lv, dm, c)
+CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+ Cluster(rav, lv, dm, c, s)
{}
/***********************************************************************/
delete read;
//create cluster
- if (method == "furthest") { cluster = new CompleteLinkage(rabund, list, distMatrix, cutoff); }
- else if(method == "nearest"){ cluster = new SingleLinkage(rabund, list, distMatrix, cutoff); }
- else if(method == "average"){ cluster = new AverageLinkage(rabund, list, distMatrix, cutoff); }
+ if (method == "furthest") { cluster = new CompleteLinkage(rabund, list, distMatrix, cutoff, method); }
+ else if(method == "nearest"){ cluster = new SingleLinkage(rabund, list, distMatrix, cutoff, method); }
+ else if(method == "average"){ cluster = new AverageLinkage(rabund, list, distMatrix, cutoff, method); }
cluster->setMapWanted(true);
//cluster using cluster classes
/***********************************************************************/
-SingleLinkage::SingleLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c) :
-Cluster(rav, lv, dm, c)
+SingleLinkage::SingleLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
+Cluster(rav, lv, dm, c, s)
{}