]> git.donarmstrong.com Git - mothur.git/blobdiff - libshuffcommand.cpp
added log10 and log2 scalers for heatmap
[mothur.git] / libshuffcommand.cpp
index a51b3270f855062a0e2ee92fab63779b38b50877..33a1a3ba0c4bf35e1ad005396a48b2a9c5c93add 100644 (file)
@@ -103,9 +103,11 @@ int LibShuffCommand::execute(){
                deltaValues.clear();
                deltaValues.resize(dist.size());                        
                
-               coverage->getValues(matrix, cValues, dist, "user");
+               coverage->getValues(matrix, cValues, dist);
                
-               //loop through each distance and load rsumdelta
+               float distDiff = 0;
+               
+               //loop through each distance and load sumdelta
                for (int p = 0; p < cValues.size(); p++) {      
                        //find delta values
                        int count = 0;
@@ -113,13 +115,16 @@ int LibShuffCommand::execute(){
                                for (int j = 0; j < numGroups; j++) {
                                        //don't save AA to AA
                                        if (i != j) {
-                                               //(Caa - Cab)^2
-                                               deltaValues[p].push_back((cValues[p][i][i]-cValues[p][i][j]) * (cValues[p][i][i]-cValues[p][i][j]));
+                                               //(Caa - Cab)^2 * distDiff
+                                               deltaValues[p].push_back(((cValues[p][i][i]-cValues[p][i][j]) * (cValues[p][i][i]-cValues[p][i][j])) * distDiff); //* distDiff
                                                sumDelta[count] += deltaValues[p][count];
                                                count++;
                                        }
                                }
                        }
+                       if (p < cValues.size() - 1) {
+                               distDiff = dist[p+1] - dist[p]; 
+                       }
                }
                        
                printCoverageFile();
@@ -151,13 +156,12 @@ int LibShuffCommand::execute(){
                                        for (int j = 0; j < numGroups; j++) {
                                                //don't save AA to AA
                                                if (i != j) {
-                                                       //(Caa - Cab)^2
-                                                       rsumDelta[count][m] += ((cValues[p][i][i]-cValues[p][i][j]) * (cValues[p][i][i]-cValues[p][i][j]));
+                                                       //rsumDelta[3][500] = the sum of the delta scores for BB-BC for random matrix # 500.
+                                                       rsumDelta[count][m] += cValues[p][i][j];  // where cValues[p][0][1] = delta value at distance p of AA-AB, cValues[p][1][2] = delta value at distance p of BB-BC. 
                                                        count++;
                                                }
                                        }
                                }
-                               
                        }
 
                        //clear out old Values
@@ -320,6 +324,10 @@ void LibShuffCommand::setGroups() {
                //sort so labels match
                sort(globaldata->Groups.begin(), globaldata->Groups.end());
                
+               //sort
+               sort(globaldata->gGroupmap->namesOfGroups.begin(), globaldata->gGroupmap->namesOfGroups.end());
+
+               
                // number of comparisons i.e. with groups A,B,C = AA, AB, AC, BA, BB, BC...;
                for (int i=0; i<numGroups; i++) { 
                        for (int l = 0; l < numGroups; l++) {