]> git.donarmstrong.com Git - mothur.git/commitdiff
added warning about merging with something above cutoff to cluster. working on chimeras
authorwestcott <westcott>
Tue, 23 Feb 2010 19:41:26 +0000 (19:41 +0000)
committerwestcott <westcott>
Tue, 23 Feb 2010 19:41:26 +0000 (19:41 +0000)
averagelinkage.cpp
cluster.cpp
cluster.hpp
clustercommand.cpp
completelinkage.cpp
mgclustercommand.cpp
singlelinkage.cpp

index 7522d2a3083f9247744f93a5bc147480f0304a72..2acbacc91e53bf25b5c992edad8c970755409dd0 100644 (file)
@@ -11,8 +11,8 @@
 
 /***********************************************************************/
 
-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;
index 4009ed075e63c78e4fb661352c675cff3209e030..e360624dbfc599f94901fe12c1518fe8c11e877d 100644 (file)
@@ -14,8 +14,8 @@
 
 /***********************************************************************/
 
-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;
@@ -212,7 +212,7 @@ void Cluster::update(double& cutOFF){
                                        }               
                                }
                                //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(); }
 
@@ -228,9 +228,11 @@ void Cluster::update(double& cutOFF){
                // 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);
                        }
index 685c843c0199b73083f7eb3a17693b33fe1a4d36..6d7fc470e91eca8dae548ffb5594a4099a203f35 100644 (file)
@@ -13,7 +13,7 @@ typedef vector<MatData> MatVec;
 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);  
@@ -39,6 +39,7 @@ protected:
        bool mapWanted;
        float cutoff;
        map<string, int> seq2Bin;
+       string method;
        
        vector<MatVec> seqVec;          // contains vectors of cells related to a certain sequence
        MatVec rowCells;
@@ -51,7 +52,7 @@ protected:
 
 class CompleteLinkage : public Cluster {
 public:
-       CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+       CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
        bool updateDistance(MatData& colCell, MatData& rowCell);
        string getTag();
        
@@ -63,7 +64,7 @@ private:
 
 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();
@@ -76,7 +77,7 @@ private:
 
 class AverageLinkage : public Cluster {
 public:
-       AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float);
+       AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
        bool updateDistance(MatData& colCell, MatData& rowCell);
        string getTag();
        
index be7cc51d9f4ecf2765cd878a932b3a804e4bf1ba..d14af108d69c36f98617fc2e133c3dcfb537c553 100644 (file)
@@ -84,9 +84,9 @@ ClusterCommand::ClusterCommand(string option){
                                }
                                
                                //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); }
index a09af904fc64e3f901ef48c82b6f20469c48f348..df6371ac8c988ce08b4ff670d0c4da86f6dff85f 100644 (file)
@@ -3,8 +3,8 @@
 
 /***********************************************************************/
 
-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)
 {}
 
 /***********************************************************************/
index fba2959b5f11751ea714ed79d8c2fcdf0ac24bc4..d240de6c73c98a705472e5cb50c689041a7b36dc 100644 (file)
@@ -183,9 +183,9 @@ int MGClusterCommand::execute(){
                        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
index 9f015db7359879be53da5e6001889117c7e5f7c6..17626156013e2994185e9cf6f284f69c2f63367c 100644 (file)
@@ -5,8 +5,8 @@
 
 /***********************************************************************/
 
-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)
 {}