5 * Created by Sarah Westcott on 3/25/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
12 //**********************************************************************************************************************
15 globaldata = GlobalData::getInstance();
16 format = globaldata->getFormat();
20 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
24 cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
28 //**********************************************************************************************************************
29 void HeatMap::getPic(OrderVector* order) {
33 rabund = order->getRAbundVector();
35 for (int i = 0; i < rabund.size(); i++) {
36 colorScale[rabund.get(i)] = "";
39 float scaler = 255 / (float) colorScale.size();
41 //go through map and give each score a color value
42 for (it = colorScale.begin(); it != colorScale.end(); it++) {
43 it->second = toHex(int(float(it->first) * scaler));
44 if(it->second.length() == 1) { it->second = "0" + it->second; }
47 string filenamesvg = globaldata->inputFileName + ".heatmap." + order->getLabel() + ".svg";
49 openOutputFile(filenamesvg, outsvg);
51 //scale max rank so the maxrank = bright red
54 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 300 " + toString((rabund.getNumBins()*5 + 15)) + "\">\n";
61 for (int i = 0; i <= rabund.getNumBins(); i++) {
63 color = colorScale[rabund.get(i)];
65 outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
68 outsvg << "</g>\n</svg>\n";
74 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
78 cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
82 //**********************************************************************************************************************
83 void HeatMap::getPic(SharedOrderVector* sharedorder) {
87 //fills vector of sharedsabunds - lookup
88 getSharedVectors(sharedorder);
91 for (int i = 0; i < lookup.size(); i++) {
92 for (int j = 0; j < lookup[i]->size(); j++) {
93 colorScale[lookup[i]->getAbundance(j)] = "";
98 float scaler = 255 / (float) colorScale.size();
100 //go through map and give each score a color value
101 for (it = colorScale.begin(); it != colorScale.end(); it++) {
102 it->second = toHex(int(float(it->first) * scaler));
103 if(it->second.length() == 1) { it->second = "0" + it->second; }
106 string filenamesvg = globaldata->inputFileName + ".heatmap." + sharedorder->getLabel() + "." + groupComb + ".svg";
107 openOutputFile(filenamesvg, outsvg);
110 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((lookup[0]->getNumBins()*5 + 15)) + "\">\n";
117 for (int i = 0; i <= lookup[0]->getNumBins(); i++) {
119 for (int j = 0; j < lookup.size(); j++) {
121 color = colorScale[lookup[j]->getAbundance(i)];
123 outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
129 outsvg << "</g>\n</svg>\n";
136 catch(exception& e) {
137 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
141 cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
145 //**********************************************************************************************************************
146 void HeatMap::getSharedVectors(SharedOrderVector* order){
152 //create and initialize vector of sharedvectors, one for each group
153 for (int i = 0; i < globaldata->Groups.size(); i++) {
154 SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
155 temp->setLabel(order->getLabel());
156 temp->setGroup(globaldata->Groups[i]);
157 groupComb += globaldata->Groups[i];
158 lookup.push_back(temp);
161 int numSeqs = order->size();
162 //sample all the members
163 for(int i=0;i<numSeqs;i++){
165 individual chosen = order->get(i);
168 //set info for sharedvector in chosens group
169 for (int j = 0; j < lookup.size(); j++) {
170 if (chosen.group == lookup[j]->getGroup()) {
171 abundance = lookup[j]->getAbundance(chosen.bin);
172 lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
179 catch(exception& e) {
180 cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
184 cout << "An unknown error has occurred in the HeatMap class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
190 //**********************************************************************************************************************