]> git.donarmstrong.com Git - mothur.git/commitdiff
changed unweighted and weighted score cumulatives to be that score or higher instead...
authorwestcott <westcott>
Wed, 18 Feb 2009 17:09:09 +0000 (17:09 +0000)
committerwestcott <westcott>
Wed, 18 Feb 2009 17:09:09 +0000 (17:09 +0000)
unifracunweightedcommand.cpp
unifracunweightedcommand.h
unifracweightedcommand.cpp
unifracweightedcommand.h

index 77069443c2fd26a0cebbabf4dd661e1d37288030..3eedb2ecd99ff2a68342c23ab617639c3c82e312 100644 (file)
@@ -113,12 +113,13 @@ int UnifracUnweightedCommand::execute() {
                        saveRandomScores(); //save all random scores for unweighted file
                        
                        //find the signifigance of the score
-                       float rcumul = 0.0000;
+                       float rcumul = 1.0000;
                        for (it = rscoreFreq.begin(); it != rscoreFreq.end(); it++) { 
+                               rCumul[it->first] = rcumul;
                                //get percentage of random trees with that info
                                rscoreFreq[it->first] /= iters; 
-                               rcumul+= it->second;  
-                               rCumul[it->first] = rcumul;
+                               rcumul-= it->second;  
+                               
                        }
                        
                        //save the signifigance of the users score for printing later
@@ -130,31 +131,29 @@ int UnifracUnweightedCommand::execute() {
                        rCumul.clear();
                }
                
-               float ucumul = 0.0000;
-               float rcumul = 0.0000;
+               float ucumul = 1.0000;
+               float rcumul = 1.0000;
                //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
                for (it = validScores.begin(); it != validScores.end(); it++) { 
                        it2 = uscoreFreq.find(it->first);
-                       //user data has that score 
-                       if (it2 != uscoreFreq.end()) { uscoreFreq[it->first] /= T.size(); ucumul+= it2->second;  }
-                       else { uscoreFreq[it->first] = 0.0000; } //no user trees with that score
                        //make uCumul map
                        uCumul[it->first] = ucumul;
-                       
+                       //user data has that score 
+                       if (it2 != uscoreFreq.end()) { uscoreFreq[it->first] /= T.size(); ucumul-= it2->second;  }
+                       else { uscoreFreq[it->first] = 0.0000; } //no user trees with that score
+                                               
                        //make rscoreFreq map and rCumul
                        it2 = totalrscoreFreq.find(it->first);
+                       rCumul[it->first] = rcumul;
                        //get percentage of random trees with that info
-                       if (it2 != totalrscoreFreq.end()) {  totalrscoreFreq[it->first] /= (iters*T.size()); rcumul+= it2->second;  }
+                       if (it2 != totalrscoreFreq.end()) {  totalrscoreFreq[it->first] /= (iters*T.size()); rcumul-= it2->second;  }
                        else { totalrscoreFreq[it->first] = 0.0000; } //no random trees with that score
-                       rCumul[it->first] = rcumul;
+                       
                }
                
                printUnweightedFile();
                printUWSummaryFile();
                
-               //reset randomTree parameter to 0
-               globaldata->setRandomTree("0");
-               
                delete randT;
                
                return 0;
index cc01aab8505d6c36978a2a5933f9167de565fe99..ecf78f58a981e1f95602ed4e10973bcf7695cf14 100644 (file)
@@ -46,8 +46,8 @@ class UnifracUnweightedCommand : public Command {
                map<float, float> rscoreFreq;  //unweighted score, number of random trees with that score.
                map<float, float> uscoreFreq;  //unweighted, number of user trees with that score.
                map<float, float> totalrscoreFreq;  //unweighted score, number of random trees with that score.
-               map<float, float> rCumul;               //unweighted score, cumulative percentage of number of random trees with that score or lower.
-               map<float, float> uCumul;  //unweighted, cumulative percentage of number of user trees with that score or lower .
+               map<float, float> rCumul;               //unweighted score, cumulative percentage of number of random trees with that score or higher.
+               map<float, float> uCumul;  //unweighted, cumulative percentage of number of user trees with that score or higher .
                map<float, float>::iterator it;
                map<float, float>::iterator it2;
                
index 3b3abf82db928f25bb07a7e3dfdf04f4228a35dd..47b23d667e7b159531b208a49f80666bc7ba48c0 100644 (file)
@@ -151,14 +151,14 @@ int UnifracWeightedCommand::execute() {
                        
                        //find the signifigance of the score for summary file
                        for (int t = 0; t < numComp; t++) {
-                               float rcumul = 0.0000;
+                               float rcumul = 1.0000;
                                for (it = validScores[t].begin(); it != validScores[t].end(); it++) { 
                                        //make rscoreFreq map and rCumul
                                        it2 = rscoreFreq[t].find(it->first);
+                                       rCumul[t][it->first] = rcumul;
                                        //get percentage of random trees with that info
-                                       if (it2 != rscoreFreq[t].end()) {  rscoreFreq[t][it->first] /= iters; rcumul+= it2->second;  }
+                                       if (it2 != rscoreFreq[t].end()) {  rscoreFreq[t][it->first] /= iters; rcumul-= it2->second;  }
                                        else { rscoreFreq[t][it->first] = 0.0000; } //no random trees with that score
-                                       rCumul[t][it->first] = rcumul;
                                }
                        }
                        
@@ -175,24 +175,24 @@ int UnifracWeightedCommand::execute() {
                
                rCumul.resize(numComp);
                for (int b = 0; b < numComp; b++) {
-                       float ucumul = 0.0000;
-                       float rcumul = 0.0000;
+                       float ucumul = 1.0000;
+                       float rcumul = 1.0000;
                        //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
-                       for (it = validScores[b].end(); it == validScores[b].begin(); it--) { 
+                       for (it = validScores[b].begin(); it != validScores[b].end(); it++) { 
                                it2 = uscoreFreq[b].find(it->first);
-                               //user data has that score 
-                               if (it2 != uscoreFreq[b].end()) { uscoreFreq[b][it->first] /= T.size(); ucumul+= it2->second;  }
-                               else { uscoreFreq[b][it->first] = 0.0000; } //no user trees with that score
                                //make uCumul map
                                uCumul[b][it->first] = ucumul;
+                               //user data has that score 
+                               if (it2 != uscoreFreq[b].end()) { uscoreFreq[b][it->first] /= T.size(); ucumul-= it2->second;  }
+                               else { uscoreFreq[b][it->first] = 0.0000; } //no user trees with that score
                        
                                //make rscoreFreq map and rCumul
                                it2 = totalrscoreFreq[b].find(it->first);
+                               rCumul[b][it->first] = rcumul;
                                //get percentage of random trees with that info
-                               if (it2 != totalrscoreFreq[b].end()) {  totalrscoreFreq[b][it->first] /= (iters * T.size()); rcumul+= it2->second;  }
+                               if (it2 != totalrscoreFreq[b].end()) {  totalrscoreFreq[b][it->first] /= (iters * T.size()); rcumul-= it2->second;  }
                                else { totalrscoreFreq[b][it->first] = 0.0000; } //no random trees with that score
-                               rCumul[b][it->first] = rcumul;
-                       }
+                                                       }
                }
                
                printWeightedFile();
index 047c92b2574515e20c439931808dce8dc5a34705..45d3c7cec25d4d80448d32beeaa212a92295d366 100644 (file)
@@ -47,8 +47,8 @@ class UnifracWeightedCommand : public Command {
                vector< map<float, float> > rscoreFreq;  //vector<weighted score, number of random trees with that score.> each group comb has an entry
                vector< map<float, float> > uscoreFreq;  //vector<weighted, number of user trees with that score.> each group comb has an entry
                vector< map<float, float> > totalrscoreFreq;  //vector<weighted score, number of random trees with that score.> each group comb has an entry
-               vector< map<float, float> > rCumul;  //vector<weighted score, number of random trees with that score.> each group comb has an entry
-               vector< map<float, float> > uCumul;  //vector<weighted, cumulative percentage of number of user trees with that score or lower.> each group comb has an entry
+               vector< map<float, float> > rCumul;  //vector<weighted score, number of random trees with that score or higher.> each group comb has an entry
+               vector< map<float, float> > uCumul;  //vector<weighted, cumulative percentage of number of user trees with that score or higher.> each group comb has an entry
                map<float, float>::iterator it;
                map<float, float>::iterator it2;