X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmap.cpp;h=254b70668f9539929dcd3d60360cd23bd7c6dc2a;hb=a65438a717aba8cad1ff86c53279b191710b8810;hp=367342c7167451402c5879a1f6efd1f83e7a48a4;hpb=a935b75dd890da5ae7f09e5e6179f90ab2955348;p=mothur.git diff --git a/heatmap.cpp b/heatmap.cpp index 367342c..254b706 100644 --- a/heatmap.cpp +++ b/heatmap.cpp @@ -119,7 +119,7 @@ string HeatMap::getPic(vector lookup) { } //sort lookup so shared bins are on top - vector sortedLabels = m->currentBinLabels; + vector sortedLabels = m->currentSharedBinLabels; if (sorted != "none") { sortedLabels = sortSharedVectors(lookup); } vector > scaleRelAbund; @@ -144,12 +144,17 @@ string HeatMap::getPic(vector lookup) { if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0. if (scaler == "log10") { - scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund[i]))) + "0000"; + if (maxRelAbund[i] == 1) { maxRelAbund[i] -= 0.001; } + if (relAbund == 1) { relAbund -= 0.001; } + scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund[i]))) + "0000"; }else if (scaler == "log2") { + if (maxRelAbund[i] == 1) { maxRelAbund[i] -= 0.001; } + if (relAbund == 1) { relAbund -= 0.001; } scaleRelAbund[i][j] = toHex(int(255 * log2(relAbund) / log2(maxRelAbund[i]))) + "0000"; }else if (scaler == "linear") { - scaleRelAbund[i][j] = toHex(int(255 * relAbund / maxRelAbund[i])) + "0000"; + scaleRelAbund[i][j] = toHex(int(255 * relAbund / maxRelAbund[i])) + "0000"; }else { //if user enters invalid scaler option. + if (maxRelAbund[i] == 1) { maxRelAbund[i] += 0.001; } scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund / log10(maxRelAbund[i])))) + "0000"; } }else { scaleRelAbund[i][j] = "FFFFFF"; } @@ -221,7 +226,7 @@ vector HeatMap::sortSharedVectors(vector& lookup){ map place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2. map::iterator it; - vector sortedLabels = m->currentBinLabels; + vector sortedLabels = m->currentSharedBinLabels; /****************** find order of otus **********************/ if (sorted == "shared") { @@ -254,7 +259,7 @@ vector HeatMap::sortSharedVectors(vector& lookup){ int newAbund = looktemp[j]->getAbundance(i); // 1 -> 3 lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group } - sortedLabels[place[i]] = m->currentBinLabels[i]; + sortedLabels[place[i]] = m->currentSharedBinLabels[i]; } //delete looktemp -- Sarah look at - this is causing segmentation faults @@ -430,7 +435,7 @@ string HeatMap::getPic(vector lookup) { } //sort lookup so shared bins are on top - vector sortedLabels = m->currentBinLabels; + vector sortedLabels = m->currentSharedBinLabels; if (sorted != "none") { sortedLabels = sortSharedVectors(lookup); } vector > scaleRelAbund; @@ -455,11 +460,15 @@ string HeatMap::getPic(vector lookup) { if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0. if (scaler == "log10") { + if (maxRelAbund[i] == 1) { maxRelAbund[i] -= 0.001; } + if (relAbund == 1) { relAbund -= 0.001; } scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund[i]))) + "0000"; }else if (scaler == "log2") { + if (maxRelAbund[i] == 1) { maxRelAbund[i] -= 0.001; } + if (relAbund == 1) { relAbund -= 0.001; } scaleRelAbund[i][j] = toHex(int(255 * log2(relAbund) / log2(maxRelAbund[i]))) + "0000"; }else if (scaler == "linear") { - scaleRelAbund[i][j] = toHex(int(255 * relAbund / maxRelAbund[i])) + "0000"; + scaleRelAbund[i][j] = toHex(int(255 * relAbund / maxRelAbund[i])) + "0000"; }else { //if user enters invalid scaler option. scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund / log10(maxRelAbund[i])))) + "0000"; } @@ -532,7 +541,7 @@ vector HeatMap::sortSharedVectors(vector& look map place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2. map::iterator it; - vector sortedLabels = m->currentBinLabels; + vector sortedLabels = m->currentSharedBinLabels; /****************** find order of otus **********************/ if (sorted == "shared") { @@ -564,7 +573,7 @@ vector HeatMap::sortSharedVectors(vector& look for (int j = 0; j < looktemp.size(); j++) { // 3 -> 2 float newAbund = looktemp[j]->getAbundance(i); // 1 -> 3 lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group - sortedLabels[place[i]] = m->currentBinLabels[i]; + sortedLabels[place[i]] = m->currentSharedBinLabels[i]; } }