]> git.donarmstrong.com Git - mothur.git/commitdiff
working on pam
authorSarah Westcott <mothur.westcott@gmail.com>
Tue, 21 Jan 2014 15:58:06 +0000 (10:58 -0500)
committerSarah Westcott <mothur.westcott@gmail.com>
Tue, 21 Jan 2014 15:58:06 +0000 (10:58 -0500)
pam.cpp

diff --git a/pam.cpp b/pam.cpp
index 2c70f58f5770135d93e97dbe06a7392816b37197..bcc51fc7e87e93c6ed67b741b4e0335ea380327f 100644 (file)
--- a/pam.cpp
+++ b/pam.cpp
@@ -339,6 +339,33 @@ double Pam::calcCHIndex(vector< vector<double> > dists){ //countMatrix = [numSam
             }
         }
         
+        //make countMatrix a relabund
+        vector<vector<double> > relativeAbundance(numSamples);
+        //get relative abundance
+        for(int i=0;i<numSamples;i++){
+            if (m->control_pressed) {  return 0; }
+            int groupTotal = 0;
+            
+            relativeAbundance[i].assign(numOTUs, 0.0);
+            
+            for(int j=0;j<numOTUs;j++){
+                groupTotal += countMatrix[i][j];
+            }
+            for(int j=0;j<numOTUs;j++){
+                relativeAbundance[i][j] = countMatrix[i][j] / (double)groupTotal;
+            }
+        }
+        
+        //find centers
+        vector<vector<double> > centers; centers.resize(numPartitions);
+        int countPartitions = 0;
+        for (set<int>::iterator it = medoids.begin(); it != medoids.end(); it++) {
+            for (int j = 0; j < numOTUs; j++) {
+                centers[countPartitions].push_back(relativeAbundance[*it][j]); //save the relative abundance of the medoid for this partition for this OTU
+            }
+            countPartitions++;
+        }
+        
         double sumBetweenCluster = 0.0;
         double sumWithinClusters = 0.0;