+ int y = 103 + (numBinsToDisplay*5);
+ printLegend(y, superMaxRelAbund);
+
+ y = 70;
+ for (int i = 0; i < numBinsToDisplay; i++) {
+ for (int j = 0; j < scaleRelAbund.size(); j++) {
+ if (m->control_pressed) { outsvg.close(); return "control"; }
+
+ outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
+ x += 300;
+ }
+ x = 0;
+ y += 5;
+ }
+
+ outsvg << "</g>\n</svg>\n";
+ outsvg.close();
+
+ return filenamesvg;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "HeatMap", "getPic");
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+int HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
+ try {
+
+ vector<SharedRAbundVector*> looktemp;
+ map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
+ map<int, int>::iterator it;
+
+ /****************** find order of otus **********************/
+ if (sorted == "shared") {
+ place = orderShared(lookup);
+ }else if (sorted == "topotu") {
+ place = orderTopOtu(lookup);
+ }else if (sorted == "topgroup") {
+ place = orderTopGroup(lookup);
+ }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine(); return 1; }
+
+
+ /******************* create copy of lookup *********************/
+ //create and initialize looktemp as a copy of lookup
+ for (int i = 0; i < lookup.size(); i++) {
+ SharedRAbundVector* temp = new SharedRAbundVector(lookup[i]->getNumBins());
+ temp->setLabel(lookup[i]->getLabel());
+ temp->setGroup(lookup[i]->getGroup());
+ //copy lookup i's info
+ for (int j = 0; j < lookup[i]->size(); j++) {
+ temp->set(j, lookup[i]->getAbundance(j), lookup[i]->getGroup());
+ }
+ looktemp.push_back(temp);
+ }
+
+ /************************ fill lookup in order given by place *********************/
+ //for each bin
+ for (int i = 0; i < looktemp[0]->size(); i++) { //place
+ //fill lookup // 2 -> 1
+ for (int j = 0; j < looktemp.size(); j++) { // 3 -> 2
+ int newAbund = looktemp[j]->getAbundance(i); // 1 -> 3
+ lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
+ }
+ }
+
+ //delete looktemp -- Sarah look at - this is causing segmentation faults
+ for (int j = 0; j < looktemp.size(); j++) {
+// delete looktemp[j];
+ }
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "HeatMap", "sortSharedVectors");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+map<int, int> HeatMap::orderShared(vector<SharedRAbundVector*>& lookup){
+ try {
+
+ map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
+ map<int, int>::iterator it;
+
+ vector<int> sharedBins;
+ vector<int> uniqueBins;
+
+ //for each bin
+ for (int i = 0; i < lookup[0]->size(); i++) {
+ int count = 0;