]> git.donarmstrong.com Git - mothur.git/commitdiff
This is mothur v 1.2.0 - the April ~24, 2009 release
authorpschloss <pschloss>
Fri, 24 Apr 2009 21:58:56 +0000 (21:58 +0000)
committerpschloss <pschloss>
Fri, 24 Apr 2009 21:58:56 +0000 (21:58 +0000)
bootstrapsharedcommand.cpp
sharedbraycurtis.cpp
sharedmorisitahorn.cpp
sharedthetayc.cpp
summarysharedcommand.cpp
treegroupscommand.cpp
validcalculator.cpp

index 5c2e1714d97612bb595044fc566d61bd47c540ec..9051dd8ea6b11311921e19a1d194bbc7856d3f14 100644 (file)
@@ -17,6 +17,7 @@
 #include "sharedthetayc.h"
 #include "sharedthetan.h"
 #include "sharedmorisitahorn.h"
+#include "sharedbraycurtis.h"
 
 
 //**********************************************************************************************************************
@@ -51,6 +52,8 @@ BootSharedCommand::BootSharedCommand(){
                                        treeCalculators.push_back(new ThetaN());
                                }else if (globaldata->Estimators[i] == "morisitahorn") { 
                                        treeCalculators.push_back(new MorHorn());
+                               }else if (globaldata->Estimators[i] == "braycurtis") { 
+                                       treeCalculators.push_back(new BrayCurtis());
                                }
                        }
                }
index 0f29b2393f76b80f74cec7b59cb971fc58dd4a68..d1b401eb78038aaa8d462678fe7bcbc3d2b13903 100644 (file)
 #include "sharedbraycurtis.h"
 
 /***********************************************************************/
-//This is used by SharedJAbund and SharedSorAbund
+
 EstOutput BrayCurtis::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
        try {   
-               EstOutput data;
                data.resize(1,0);
                
                int sumSharedA, sumSharedB, sumSharedAB, tempA, tempB;
                sumSharedA = 0; sumSharedB = 0; sumSharedAB = 0; 
                
                /*Xi, Yi = abundance of the ith shared OTU in A and B 
-               sumSharedA = the sum of all shared otus in A
+               sumSharedA = the number of otus in A
                sumSharedB = the sum of all shared otus in B
                sumSharedAB = the sum of the minimum otus int all shared otus in AB.
                */
@@ -29,16 +28,13 @@ EstOutput BrayCurtis::getValues(SharedRAbundVector* shared1, SharedRAbundVector*
                        //store in temps to avoid multiple repetitive function calls
                        tempA = shared1->getAbundance(i);
                        tempB = shared2->getAbundance(i);
-
                        
-                       if ((tempA != 0) && (tempB != 0)) {//they are shared
-                               sumSharedA += tempA;
-                               sumSharedB += tempB;
+                       sumSharedA += tempA;
+                       sumSharedB += tempB;
                                
-                               //sum the min of tempA and tempB
-                               if (tempA < tempB) { sumSharedAB += tempA; }
-                               else  { sumSharedAB += tempB; }                         
-                       }
+                       //sum the min of tempA and tempB
+                       if (tempA < tempB) { sumSharedAB += tempA; }
+                       else  { sumSharedAB += tempB; }                         
                }
                
                data[0] = (2 * sumSharedAB) / (float)( sumSharedA + sumSharedB);
index 579f56a80da8733fa68ea507f9346d32a8760d59..8c5cf9263f32910aaf4f577a9a252e34dcd865d0 100644 (file)
@@ -32,18 +32,16 @@ EstOutput MorHorn::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sh
                        tempA = shared1->getAbundance(j);
                        tempB = shared2->getAbundance(j);
                        
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {
-                               if (Atotal != 0)        { sumSharedA = (tempA / (float)Atotal); }
-                               if (Btotal != 0)        { sumSharedB = (tempB / (float)Btotal); }
-                       
-                               a += sumSharedA * sumSharedA;
-                               b += sumSharedB * sumSharedB;
-                               d += sumSharedA * sumSharedB;
-                       }
+                       a += tempA * tempA;
+                       b += tempB * tempB;
+                       d += tempA * tempB;
                }
 
-               morhorn = (2 * d) / (float) (a + b);
+               a /= double(Atotal * Atotal);
+               b /= double(Btotal * Btotal);
+               d /= double(Atotal * Btotal);
+               
+               morhorn = (2 * d) / (a + b);
                
                if (isnan(morhorn) || isinf(morhorn)) { morhorn = 0; }
                
index 1357cb611b407319de5c093ca2d0e99e14be7ead..2567110a79fde8ef9499c048927b246b49109ccd 100644 (file)
@@ -14,10 +14,13 @@ EstOutput ThetaYC::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sh
        try {   
                data.resize(1,0);
                
-               int Atotal, Btotal, tempA, tempB;
-               Atotal = 0; Btotal = 0; 
-               float thetaYC, sumSharedA, sumSharedB, a, b, d;
-               thetaYC = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
+               int Atotal = 0;
+               int Btotal = 0;
+               float thetaYC = 0;
+               float relA = 0;
+               float relB = 0;
+               float a = 0;
+               float b = 0;
                
                //get the total values we need to calculate the theta denominator sums
                for (int i = 0; i < shared1->size(); i++) {
@@ -29,21 +32,14 @@ EstOutput ThetaYC::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sh
                //calculate the theta denominator sums
                for (int j = 0; j < shared1->size(); j++) {
                        //store in temps to avoid multiple repetitive function calls
-                       tempA = shared1->getAbundance(j);
-                       tempB = shared2->getAbundance(j);
-                       
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {
-                               if (Atotal != 0)        { sumSharedA = (tempA / (float)Atotal); }
-                               if (Btotal != 0)        { sumSharedB = (tempB / (float)Btotal); }
-                       
-                               a += sumSharedA * sumSharedA;
-                               b += sumSharedB * sumSharedB;
-                               d += sumSharedA * sumSharedB;
-                       }
+                       relA = shared1->getAbundance(j) / (float)Atotal;
+                       relB = shared2->getAbundance(j) / (float)Btotal;
+                                       
+                       a += relA * relB;
+                       b += pow((relA-relB),2);
                }
 
-               thetaYC = d / (float) (a + b - d);
+               thetaYC = a / (float) (b+a);
                
                if (isnan(thetaYC) || isinf(thetaYC)) { thetaYC = 0; }
                
index e6a7d9a7363a5d9a71d32fad38d6172248b0934a..eca2033ed6b0f675374e4e855933a8142a6435c5 100644 (file)
@@ -85,8 +85,7 @@ SummarySharedCommand::SummarySharedCommand(){
                                        sumCalculators.push_back(new MorHorn());
                                }else if (globaldata->Estimators[i] == "braycurtis") { 
                                        sumCalculators.push_back(new BrayCurtis());
-                               }
-                               else if (globaldata->Estimators[i] == "whittaker") { 
+                               }else if (globaldata->Estimators[i] == "whittaker") { 
                                        sumCalculators.push_back(new Whittaker());
                                }
                                
index 7791d5ecd913c431114a9de5afb2ca651ec1232c..e50fbaad53f0438a44bc25bf5b7c55fbf9146b83 100644 (file)
@@ -17,6 +17,7 @@
 #include "sharedthetayc.h"
 #include "sharedthetan.h"
 #include "sharedmorisitahorn.h"
+#include "sharedbraycurtis.h"
 
 
 //**********************************************************************************************************************
@@ -49,6 +50,8 @@ TreeGroupCommand::TreeGroupCommand(){
                                        treeCalculators.push_back(new ThetaN());
                                }else if (globaldata->Estimators[i] == "morisitahorn") { 
                                        treeCalculators.push_back(new MorHorn());
+                               }else if (globaldata->Estimators[i] == "braycurtis") { 
+                                       treeCalculators.push_back(new BrayCurtis());
                                }
                        }
                }
index 72d404147a3b71bf9a6b1efe82098f943558adf4..70299cb23dca8910e47c9fc8589e8f3d7543f18a 100644 (file)
@@ -398,6 +398,7 @@ void ValidCalculators::initialTreeGroups() {
                treegroup["thetayc"]                            = "thetayc";
                treegroup["thetan"]                                     = "thetan";
                treegroup["morisitahorn"]                       = "morisitahorn";
+               treegroup["braycurtis"]                 = "braycurtis";
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -420,6 +421,7 @@ void ValidCalculators::initialBoot() {
                boot["thetayc"]                         = "thetayc";
                boot["thetan"]                          = "thetan";
                boot["morisitahorn"]            = "morisitahorn";
+               boot["braycurtis"]                      = "braycurtis";
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";