X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmapsim.cpp;fp=heatmapsim.cpp;h=0000000000000000000000000000000000000000;hb=4a877efa127e56e81a21f53cfdbbfd3bfbe8c4ff;hp=62965f9a3291d0052b6c216b6a800d6c97072f46;hpb=a6cf29fa4dac0909c7582cb1094151d34093ee76;p=mothur.git diff --git a/heatmapsim.cpp b/heatmapsim.cpp deleted file mode 100644 index 62965f9..0000000 --- a/heatmapsim.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * heatmapsim.cpp - * Mothur - * - * Created by Sarah Westcott on 6/8/09. - * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. - * - */ - -#include "heatmapsim.h" -#include "sharedjabund.h" -#include "sharedsorabund.h" -#include "sharedjclass.h" -#include "sharedsorclass.h" -#include "sharedjest.h" -#include "sharedsorest.h" -#include "sharedthetayc.h" -#include "sharedthetan.h" -#include "sharedmorisitahorn.h" -#include "sharedbraycurtis.h" - -//********************************************************************************************************************** -HeatMapSim::HeatMapSim(string dir, string i, int f) : outputDir(dir), inputfile(i), fontSize(f) { - m = MothurOut::getInstance(); -} -//********************************************************************************************************************** -vector HeatMapSim::getPic(vector lookup, vector calcs) { - try { - EstOutput data; - vector sims; - vector outputNames; - - //make file for each calculator selected - for (int k = 0; k < calcs.size(); k++) { - - if (m->control_pressed) { return outputNames; } - - string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + calcs[k]->getName() + ".heatmap.sim.svg"; - m->openOutputFile(filenamesvg, outsvg); - outputNames.push_back(filenamesvg); - - //svg image - outsvg << "\n"; - outsvg << "\n"; - - //white backround - outsvg << ""; - outsvg << "Heatmap at distance " + lookup[0]->getLabel() + "\n"; - - //column labels - for (int h = 0; h < lookup.size(); h++) { - outsvg << "getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "\n"; - outsvg << "getGroup().length() / 2)) + "\" x=\"50\">" + lookup[h]->getGroup() + "\n"; - } - - sims.clear(); -// double biggest = -1; - double biggest = 1; - float scaler; - - //get sim for each comparison and save them so you can find the relative similairity - for(int i = 0; i < (lookup.size()-1); i++){ - for(int j = (i+1); j < lookup.size(); j++){ - - if (m->control_pressed) { outsvg.close(); return outputNames; } - - vector subset; - subset.push_back(lookup[i]); subset.push_back(lookup[j]); - - //get similairity between groups - data = calcs[k]->getValues(subset); - sims.push_back(1.0 - data[0]); - - //save biggest similairity to set relative sim -// if (data[0] > biggest) { biggest = data[0]; } - } - } - - //map biggest similairity found to red - scaler = 255.0 / biggest; - - int count = 0; - //output similairites to file - for(int i = 0; i < (lookup.size()-1); i++){ - for(int j = (i+1); j < lookup.size(); j++){ - - //find relative color - int color = scaler * sims[count]; - //draw box - outsvg << "\n"; - count++; - } - } - - int y = ((lookup.size() * 150) + 120); - printLegend(y, biggest); - - outsvg << "\n\n"; - outsvg.close(); - - } - - return outputNames; - } - catch(exception& e) { - m->errorOut(e, "HeatMapSim", "getPic"); - exit(1); - } -} -//********************************************************************************************************************** -string HeatMapSim::getPic(vector< vector > dists, vector groups) { - try { - - vector sims; - - string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "heatmap.sim.svg"; - m->openOutputFile(filenamesvg, outsvg); - - //svg image - outsvg << "\n"; - outsvg << "\n"; - - //white backround - outsvg << ""; - outsvg << "Heatmap for " + inputfile + "\n"; - - //column labels - for (int h = 0; h < groups.size(); h++) { - outsvg << "" + groups[h] + "\n"; - outsvg << "" + groups[h] + "\n"; - } - - double biggest = -1; - float scaler; - - //get sim for each comparison and save them so you can find the relative similairity - for(int i = 0; i < (dists.size()-1); i++){ - for(int j = (i+1); j < dists.size(); j++){ - - if (m->control_pressed) { outsvg.close(); return filenamesvg; } - - float sim = 1.0 - dists[i][j]; - sims.push_back(sim); - - //save biggest similairity to set relative sim - if (sim > biggest) { biggest = sim; } - } - } - - //map biggest similairity found to red - scaler = 255.0 / biggest; - - int count = 0; - //output similairites to file - for(int i = 0; i < (dists.size()-1); i++){ - for(int j = (i+1); j < dists.size(); j++){ - - //find relative color - int color = scaler * sims[count]; - //draw box - outsvg << "\n"; - count++; - } - } - - int y = ((dists.size() * 150) + 120); - printLegend(y, biggest); - - outsvg << "\n\n"; - outsvg.close(); - - return filenamesvg; - - } - catch(exception& e) { - m->errorOut(e, "HeatMapSim", "getPic"); - exit(1); - } -} - -//********************************************************************************************************************** - -void HeatMapSim::printLegend(int y, float maxSim) { - try { - maxSim = 1; - - //output legend and color labels - //go through map and give each score a color value - string color; - int x = 10; - - //prints legend - for (int i = 1; i < 255; i++) { - color = toHex(int((float)(i))); - outsvg << "\n"; - x += 3; - } - - float scaler = maxSim / 5.0; - - //prints legend labels - x = 0; - for (int i = 0; i<=5; i++) { - float label = scaler*i; - label = int(label * 1000 + 0.5); - label /= 1000.0; - string text = toString(label, 1); - - outsvg << "" + text + "\n"; - x += 153; - } - } - - catch(exception& e) { - m->errorOut(e, "HeatMapSim", "printLegend"); - exit(1); - } -} - -//********************************************************************************************************************** - - - -