From f15f7092c97277337d4fdd9ef674015c15a13220 Mon Sep 17 00:00:00 2001 From: westcott Date: Mon, 8 Jun 2009 16:14:18 +0000 Subject: [PATCH] added heatmap.sim command and changed heatmap to heatmap.bin --- Mothur.xcodeproj/project.pbxproj | 20 +++- commandfactory.cpp | 4 +- errorchecking.cpp | 4 +- globaldata.cpp | 2 +- heatmap.cpp | 4 +- heatmapsim.cpp | 165 +++++++++++++++++++++++++++++ heatmapsim.h | 40 +++++++ heatmapsimcommand.cpp | 172 +++++++++++++++++++++++++++++++ heatmapsimcommand.h | 40 +++++++ helpcommand.cpp | 12 +-- readotu.cpp | 2 +- validcalculator.cpp | 36 +++++++ validcalculator.h | 2 + validcommands.cpp | 3 +- validparameter.cpp | 5 +- 15 files changed, 492 insertions(+), 19 deletions(-) create mode 100644 heatmapsim.cpp create mode 100644 heatmapsim.h create mode 100644 heatmapsimcommand.cpp create mode 100644 heatmapsimcommand.h diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index f6eeacb..3f1cd99 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -56,6 +56,8 @@ 375AA13A0F9E433D008EF9B8 /* readotu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1350F9E433D008EF9B8 /* readotu.cpp */; }; 375AA13B0F9E433D008EF9B8 /* readphylip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1370F9E433D008EF9B8 /* readphylip.cpp */; }; 377326650FAF16E0007ABB8B /* concensuscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377326630FAF16E0007ABB8B /* concensuscommand.cpp */; }; + 378598660FDD497000EF9D03 /* heatmapsimcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378598650FDD497000EF9D03 /* heatmapsimcommand.cpp */; }; + 378598740FDD4C1500EF9D03 /* heatmapsim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378598730FDD4C1500EF9D03 /* heatmapsim.cpp */; }; 378C1B030FB0644E004D63F5 /* filterseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AEE0FB0644D004D63F5 /* filterseqscommand.cpp */; }; 378C1B040FB0644E004D63F5 /* goodscoverage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AF00FB0644D004D63F5 /* goodscoverage.cpp */; }; 378C1B0A0FB0644E004D63F5 /* sequencedb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */; }; @@ -275,6 +277,10 @@ 375AA1380F9E433D008EF9B8 /* readphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readphylip.h; sourceTree = SOURCE_ROOT; }; 377326630FAF16E0007ABB8B /* concensuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = concensuscommand.cpp; sourceTree = SOURCE_ROOT; }; 377326640FAF16E0007ABB8B /* concensuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concensuscommand.h; sourceTree = SOURCE_ROOT; }; + 378598640FDD497000EF9D03 /* heatmapsimcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapsimcommand.h; sourceTree = ""; }; + 378598650FDD497000EF9D03 /* heatmapsimcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapsimcommand.cpp; sourceTree = ""; }; + 378598720FDD4C1500EF9D03 /* heatmapsim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapsim.h; sourceTree = ""; }; + 378598730FDD4C1500EF9D03 /* heatmapsim.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapsim.cpp; sourceTree = ""; }; 378C1AEE0FB0644D004D63F5 /* filterseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filterseqscommand.cpp; sourceTree = SOURCE_ROOT; }; 378C1AEF0FB0644D004D63F5 /* filterseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filterseqscommand.h; sourceTree = SOURCE_ROOT; }; 378C1AF00FB0644D004D63F5 /* goodscoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = goodscoverage.cpp; sourceTree = SOURCE_ROOT; }; @@ -557,6 +563,8 @@ 373C68BA0FC1C1A600137ACD /* gotohoverlap.cpp */, 375873ED0F7D646F0040F377 /* heatmap.h */, 375873EE0F7D646F0040F377 /* heatmap.cpp */, + 378598720FDD4C1500EF9D03 /* heatmapsim.h */, + 378598730FDD4C1500EF9D03 /* heatmapsim.cpp */, 37D927E60F21331F001D4494 /* inputdata.h */, 37D927E50F21331F001D4494 /* inputdata.cpp */, 7E412F420F8D213C00381DD0 /* libshuff.h */, @@ -738,10 +746,6 @@ 37D928A90F2133E5001D4494 /* commands */ = { isa = PBXGroup; children = ( - 7E09C5340FDA7F65002ECAE5 /* trimseqscommand.h */, - 7E09C5350FDA7F65002ECAE5 /* trimseqscommand.cpp */, - 7E09C5120FDA79C5002ECAE5 /* reversecommand.h */, - 7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */, 37D927CD0F21331F001D4494 /* command.hpp */, 378DC5CD0FBDE1C8003B8607 /* aligncommand.h */, 378DC5CE0FBDE1C8003B8607 /* aligncommand.cpp */, @@ -777,6 +781,8 @@ 3749271C0FD58C840031C06B /* getsabundcommand.cpp */, 375873F10F7D64800040F377 /* heatmapcommand.h */, 375873F00F7D64800040F377 /* heatmapcommand.cpp */, + 378598640FDD497000EF9D03 /* heatmapsimcommand.h */, + 378598650FDD497000EF9D03 /* heatmapsimcommand.cpp */, 37D927E40F21331F001D4494 /* helpcommand.h */, 37D927E30F21331F001D4494 /* helpcommand.cpp */, 375873F40F7D648F0040F377 /* libshuffcommand.h */, @@ -801,6 +807,8 @@ 372E126F0F26365B0095CF7E /* readotucommand.cpp */, 37E5F4900F2A3DA800F8D827 /* readtreecommand.h */, 37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */, + 7E09C5120FDA79C5002ECAE5 /* reversecommand.h */, + 7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */, 371B30B30FD7EE67000414CA /* screenseqscommand.h */, 371B30B20FD7EE67000414CA /* screenseqscommand.cpp */, 3799A94E0FD6A58C00E33EDE /* seqsummarycommand.cpp */, @@ -813,6 +821,8 @@ 37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */, 211C38370F961E1F00FEE541 /* treegroupscommand.h */, 211C38360F961E1F00FEE541 /* treegroupscommand.cpp */, + 7E09C5340FDA7F65002ECAE5 /* trimseqscommand.h */, + 7E09C5350FDA7F65002ECAE5 /* trimseqscommand.cpp */, 3746109B0F40657600460C57 /* unifracunweightedcommand.h */, 3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */, 374610760F40645300460C57 /* unifracweightedcommand.h */, @@ -1103,6 +1113,8 @@ 371B30B40FD7EE67000414CA /* screenseqscommand.cpp in Sources */, 7E09C5140FDA79C5002ECAE5 /* reversecommand.cpp in Sources */, 7E09C5360FDA7F65002ECAE5 /* trimseqscommand.cpp in Sources */, + 378598660FDD497000EF9D03 /* heatmapsimcommand.cpp in Sources */, + 378598740FDD4C1500EF9D03 /* heatmapsim.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/commandfactory.cpp b/commandfactory.cpp index 8056227..8488e65 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -31,6 +31,7 @@ #include "unifracweightedcommand.h" #include "libshuffcommand.h" #include "heatmapcommand.h" +#include "heatmapsimcommand.h" #include "filterseqscommand.h" #include "mothur.h" #include "venncommand.h" @@ -93,7 +94,8 @@ Command* CommandFactory::getCommand(string commandName){ else if(commandName == "get.sabund") { command = new GetSAbundCommand(); } else if(commandName == "get.rabund") { command = new GetRAbundCommand(); } else if(commandName == "libshuff") { command = new LibShuffCommand(); } - else if(commandName == "heatmap") { command = new HeatMapCommand(); } + else if(commandName == "heatmap.bin") { command = new HeatMapCommand(); } + else if(commandName == "heatmap.sim") { command = new HeatMapSimCommand(); } else if(commandName == "filter.seqs") { command = new FilterSeqsCommand(); } else if(commandName == "venn") { command = new VennCommand(); } else if(commandName == "bin.seqs") { command = new BinSeqCommand(); } diff --git a/errorchecking.cpp b/errorchecking.cpp index db16ef3..e77c166 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -270,9 +270,9 @@ bool ErrorCheck::checkInput(string input) { } } - if ((commandName == "heatmap") || (commandName == "venn")) { + if ((commandName == "heatmap.bin") || (commandName == "venn") || (commandName == "heatmap.sim")) { if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) { - cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap or venn commands." << endl; return false; + cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap.bin, heatmap.sim or venn commands." << endl; return false; } } diff --git a/globaldata.cpp b/globaldata.cpp index a3dc757..d24f4b9 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -260,7 +260,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ Estimators.clear(); splitAtDash(calc, Estimators); } - if((commandName == "tree.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared")) { + if((commandName == "tree.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared") || (commandName == "heatmap.sim")) { if((calc == "default") || (calc == "")) { calc = "jclass-thetayc"; } diff --git a/heatmap.cpp b/heatmap.cpp index 3aceef1..8a1837a 100644 --- a/heatmap.cpp +++ b/heatmap.cpp @@ -62,7 +62,7 @@ void HeatMap::getPic(RAbundVector* rabund) { } - string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.bin.svg"; openOutputFile(filenamesvg, outsvg); //svg image @@ -144,7 +144,7 @@ void HeatMap::getPic(vector lookup) { } } - string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.bin.svg"; openOutputFile(filenamesvg, outsvg); //svg image diff --git a/heatmapsim.cpp b/heatmapsim.cpp new file mode 100644 index 0000000..33588e6 --- /dev/null +++ b/heatmapsim.cpp @@ -0,0 +1,165 @@ +/* + * 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(){ + try { + globaldata = GlobalData::getInstance(); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +//********************************************************************************************************************** + +void HeatMapSim::getPic(vector lookup, vector calcs) { + try { + EstOutput data; + vector sims; + + //make file for each calculator selected + for (int m = 0; m < calcs.size(); m++) { + + string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + calcs[m]->getName() + ".heatmap.sim.svg"; + openOutputFile(filenamesvg, outsvg); + + //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; + 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++){ + + vector subset; + subset.push_back(lookup[i]); subset.push_back(lookup[j]); + + //get similairity between groups + data = calcs[m]->getValues(subset); + sims.push_back(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(); + + } + + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSim class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the HeatMapSim class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +//********************************************************************************************************************** + +void HeatMapSim::printLegend(int y, float maxSim) { + try { + + //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 += 1; + } + + float scaler = maxSim / 5.0; + + //prints legend labels + x = 10; + for (int i = 1; i<=5; i++) { + float label = scaler*i; + label = int(label * 1000 + 0.5); + label /= 1000.0; + string text = toString(label, 3); + + outsvg << "" + text + "\n"; + x += 60; + } + } + + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSim class Function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the HeatMapSim class function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +//********************************************************************************************************************** + + + + diff --git a/heatmapsim.h b/heatmapsim.h new file mode 100644 index 0000000..c3ec2a7 --- /dev/null +++ b/heatmapsim.h @@ -0,0 +1,40 @@ +#ifndef HEATMAPSIM_H +#define HEATMAPSIM_H +/* + * heatmapsim.h + * Mothur + * + * Created by Sarah Westcott on 6/8/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + + +#include "sharedrabundvector.h" +#include "datavector.hpp" +#include "globaldata.hpp" +#include "calculator.h" + +/***********************************************************************/ + +class HeatMapSim { + + public: + HeatMapSim(); + ~HeatMapSim(){}; + + void getPic(vector, vector); + + private: + void printLegend(int, float); + + GlobalData* globaldata; + string format, groupComb; + ofstream outsvg; + +}; + +/***********************************************************************/ + +#endif + diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp new file mode 100644 index 0000000..dc3db89 --- /dev/null +++ b/heatmapsimcommand.cpp @@ -0,0 +1,172 @@ +/* + * heatmapsimcommand.cpp + * Mothur + * + * Created by Sarah Westcott on 6/8/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "heatmapsimcommand.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" + + +//********************************************************************************************************************** + +HeatMapSimCommand::HeatMapSimCommand(){ + try { + globaldata = GlobalData::getInstance(); + validCalculator = new ValidCalculators(); + heatmap = new HeatMapSim(); + + int i; + for (i=0; iEstimators.size(); i++) { + if (validCalculator->isValidCalculator("heat", globaldata->Estimators[i]) == true) { + if (globaldata->Estimators[i] == "jabund") { + heatCalculators.push_back(new JAbund()); + }else if (globaldata->Estimators[i] == "sorabund") { + heatCalculators.push_back(new SorAbund()); + }else if (globaldata->Estimators[i] == "jclass") { + heatCalculators.push_back(new Jclass()); + }else if (globaldata->Estimators[i] == "sorclass") { + heatCalculators.push_back(new SorClass()); + }else if (globaldata->Estimators[i] == "jest") { + heatCalculators.push_back(new Jest()); + }else if (globaldata->Estimators[i] == "sorest") { + heatCalculators.push_back(new SorEst()); + }else if (globaldata->Estimators[i] == "thetayc") { + heatCalculators.push_back(new ThetaYC()); + }else if (globaldata->Estimators[i] == "thetan") { + heatCalculators.push_back(new ThetaN()); + }else if (globaldata->Estimators[i] == "morisitahorn") { + heatCalculators.push_back(new MorHorn()); + }else if (globaldata->Estimators[i] == "braycurtis") { + heatCalculators.push_back(new BrayCurtis()); + } + } + } + + //reset calc for next command + globaldata->setCalc(""); + + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function HeatMapSimCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the HeatMapSimCommand class function HeatMapSimCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +//********************************************************************************************************************** + +HeatMapSimCommand::~HeatMapSimCommand(){ + delete input; + delete read; + delete heatmap; +} + +//********************************************************************************************************************** + +int HeatMapSimCommand::execute(){ + try { + int count = 1; + + //if the users entered no valid calculators don't execute command + if (heatCalculators.size() == 0) { cout << "No valid calculators." << endl; return 0; } + + //you have groups + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + lookup = input->getSharedRAbundVectors(); + vector lastLookup = lookup; + + if (lookup.size() < 2) { cout << "You have not provided enough valid groups. I cannot run the command." << endl; return 0;} + + //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label. + set processedLabels; + set userLabels = globaldata->labels; + set userLines = globaldata->lines; + + + //as long as you are not at the end of the file or done wih the lines you want + while((lookup[0] != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { + + if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lookup[0]->getLabel()) == 1){ + + cout << lookup[0]->getLabel() << '\t' << count << endl; + heatmap->getPic(lookup, heatCalculators); + + processedLabels.insert(lookup[0]->getLabel()); + userLabels.erase(lookup[0]->getLabel()); + userLines.erase(count); + } + + if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) { + cout << lastLookup[0]->getLabel() << '\t' << count << endl; + heatmap->getPic(lastLookup, heatCalculators); + + processedLabels.insert(lastLookup[0]->getLabel()); + userLabels.erase(lastLookup[0]->getLabel()); + } + + //prevent memory leak + if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) { delete lastLookup[i]; } } + lastLookup = lookup; + + //get next line to process + lookup = input->getSharedRAbundVectors(); + count++; + } + + //output error messages about any remaining user labels + set::iterator it; + bool needToRun = false; + for (it = userLabels.begin(); it != userLabels.end(); it++) { + cout << "Your file does not include the label "<< *it; + if (processedLabels.count(lastLookup[0]->getLabel()) != 1) { + cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl; + needToRun = true; + }else { + cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl; + } + } + + //run last line if you need to + if (needToRun == true) { + cout << lastLookup[0]->getLabel() << '\t' << count << endl; + heatmap->getPic(lastLookup, heatCalculators); + } + + for (int i = 0; i < lastLookup.size(); i++) { delete lastLookup[i]; } + + //reset groups parameter + globaldata->Groups.clear(); + globaldata->setGroups(""); + + return 0; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the HeatMapSimCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +//********************************************************************************************************************** diff --git a/heatmapsimcommand.h b/heatmapsimcommand.h new file mode 100644 index 0000000..33696a3 --- /dev/null +++ b/heatmapsimcommand.h @@ -0,0 +1,40 @@ +#ifndef HEATMAPSIMCOMMAND_H +#define HEATMAPSIMCOMMAND_H + +/* + * heatmapsimcommand.h + * Mothur + * + * Created by Sarah Westcott on 6/8/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "command.hpp" +#include "inputdata.h" +#include "readotu.h" +#include "validcalculator.h" +#include "heatmapsim.h" + +class GlobalData; + +class HeatMapSimCommand : public Command { + +public: + HeatMapSimCommand(); + ~HeatMapSimCommand(); + int execute(); + +private: + GlobalData* globaldata; + ReadOTUFile* read; + InputData* input; + vector lookup; + vector heatCalculators; + ValidCalculators* validCalculator; + HeatMapSim* heatmap; + +}; + +#endif + diff --git a/helpcommand.cpp b/helpcommand.cpp index a572e76..00cd8dd 100644 --- a/helpcommand.cpp +++ b/helpcommand.cpp @@ -227,19 +227,19 @@ int HelpCommand::execute(){ cout << "The default value for groups is all the groups in your groupfile, iters is 10000, cutoff is 1.0, form is integral and step is 0.01." << "\n"; cout << "The libshuff command output two files: .coverage and .slsummary their descriptions are in the manual." << "\n"; cout << "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters)." << "\n" << "\n"; - }else if (globaldata->helpRequest == "heatmap") { - cout << "The heatmap command can only be executed after a successful read.otu command." << "\n"; - cout << "The heatmap command parameters are groups, sorted, scale, line and label. No parameters are required, but you may not use line and label at the same time." << "\n"; + }else if (globaldata->helpRequest == "heatmap.bin") { + cout << "The heatmap.bin command can only be executed after a successful read.otu command." << "\n"; + cout << "The heatmap.bin command parameters are groups, sorted, scale, line and label. No parameters are required, but you may not use line and label at the same time." << "\n"; cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap." << "\n"; cout << "The sorted parameter allows you to choose to see the file with the shared otus at the top or the otus in the order they appear in your input file. " << "\n"; cout << "The scale parameter allows you to choose the range of color your bin information will be displayed with." << "\n"; cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes." << "\n"; - cout << "The heatmap command should be in the following format: heatmap(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n"; - cout << "Example heatmap(groups=A-B-C, line=1-3-5, sorted=F, scale=log10)." << "\n"; + cout << "The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n"; + cout << "Example heatmap.bin(groups=A-B-C, line=1-3-5, sorted=F, scale=log10)." << "\n"; cout << "The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used." << "\n"; cout << "The default value for sorted is T meaning you want the shared otus on top, you may change it to F meaning the exact representation of your input file." << "\n"; cout << "The default value for scale is log10; your other options are log2 and linear." << "\n"; - cout << "The heatmap command outputs a .svg file for each line or label you specify." << "\n"; + cout << "The heatmap.bin command outputs a .svg file for each line or label you specify." << "\n"; cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n"; }else if (globaldata->helpRequest == "venn") { cout << "The venn command can only be executed after a successful read.otu command." << "\n"; diff --git a/readotu.cpp b/readotu.cpp index 971ed31..455641a 100644 --- a/readotu.cpp +++ b/readotu.cpp @@ -43,7 +43,7 @@ void ReadOTUFile::read(GlobalData* globaldata){ sabund = inputSabund->getSAbundVector(); globaldata->sabund = sabund; //saving to be used by summary command. rabund = inputRabund->getRAbundVector(); - globaldata->rabund = rabund; //saving to be used by heatmap command. + globaldata->rabund = rabund; //saving to be used by heatmap.bin command. list = inputList->getListVector(); globaldata->gListVector = list; }else if (globaldata->getFormat() == "shared") { diff --git a/validcalculator.cpp b/validcalculator.cpp index 25efa1f..c0e5eed 100644 --- a/validcalculator.cpp +++ b/validcalculator.cpp @@ -24,6 +24,7 @@ ValidCalculators::ValidCalculators() { initialBoot(); initialDistance(); initialMatrix(); + initialHeat(); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -158,6 +159,17 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) { } cout << endl; return false; } + }else if (parameter == "heat") { + //is it valid + if ((heat.find(calculator)) != (heat.end())) { + return true; + }else { + cout << calculator << " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are "; + for (it = heat.begin(); it != heat.end(); it++) { + cout << it->first << ", "; + } + cout << endl; + return false; } }else if (parameter == "boot") { //is it valid if ((boot.find(calculator)) != (boot.end())) { @@ -442,6 +454,30 @@ void ValidCalculators::initialTreeGroups() { exit(1); } } +/********************************************************************/ +void ValidCalculators::initialHeat() { + try { + heat["jabund"] = "jabund"; + heat["sorabund"] = "sorabund"; + heat["jclass"] = "jclass"; + heat["sorclass"] = "sorclass"; + heat["jest"] = "jest"; + heat["sorest"] = "sorest"; + heat["thetayc"] = "thetayc"; + heat["thetan"] = "thetan"; + heat["morisitahorn"] = "morisitahorn"; + heat["braycurtis"] = "braycurtis"; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the ValidCalculator class function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + /********************************************************************/ void ValidCalculators::initialMatrix() { try { diff --git a/validcalculator.h b/validcalculator.h index ff93c58..320f982 100644 --- a/validcalculator.h +++ b/validcalculator.h @@ -35,6 +35,7 @@ class ValidCalculators { map vennshared; map treegroup; map matrix; + map heat; map boot; map distance; map::iterator it; @@ -51,6 +52,7 @@ class ValidCalculators { void initialMatrix(); void initialBoot(); void initialDistance(); + void initialHeat(); }; #endif diff --git a/validcommands.cpp b/validcommands.cpp index 936e706..e5f93a9 100644 --- a/validcommands.cpp +++ b/validcommands.cpp @@ -34,7 +34,8 @@ ValidCommands::ValidCommands() { commands["unifrac.unweighted"] = "unifrac.unweighted"; commands["libshuff"] = "libshuff"; commands["tree.shared"] = "tree.shared"; - commands["heatmap"] = "heatmap"; + commands["heatmap.bin"] = "heatmap.bin"; + commands["heatmap.sim"] = "heatmap.sim"; commands["venn"] = "venn"; commands["get.group"] = "get.group"; commands["get.label"] = "get.label"; diff --git a/validparameter.cpp b/validparameter.cpp index ae5fc3f..d6fde63 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -271,7 +271,10 @@ void ValidParameters::initCommandParameters() { commandParameters["unifrac.unweighted"] = addParameters(unifracUnweightedArray, sizeof(unifracUnweightedArray)/sizeof(string)); string heatmapArray[] = {"groups","line","label","sorted","scale"}; - commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string)); + commandParameters["heatmap.bin"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string)); + + string heatmapSimArray[] = {"groups","line","label"}; + commandParameters["heatmap.sim"] = addParameters(heatmapSimArray, sizeof(heatmapSimArray)/sizeof(string)); string filterseqsArray[] = {"fasta", "trump", "soft", "hard", "vertical"}; commandParameters["filter.seqs"] = addParameters(filterseqsArray, sizeof(filterseqsArray)/sizeof(string)); -- 2.39.2