]> git.donarmstrong.com Git - mothur.git/blob - heatmapcommand.cpp
removed read.dist, read.otu, read.tree and globaldata. added current to defaults...
[mothur.git] / heatmapcommand.cpp
1 /*
2  *  heatmapcommand.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 3/25/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "heatmapcommand.h"
11
12 //**********************************************************************************************************************
13 vector<string> HeatMapCommand::setParameters(){ 
14         try {
15                 CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
16                 CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
17                 CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
18                 CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
19                 CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
20                 CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
21                 CommandParameter pscale("scale", "Multiple", "log10-log2-linear", "log10", "", "", "",false,false); parameters.push_back(pscale);
22                 CommandParameter psorted("sorted", "Multiple", "none-shared-topotu-topgroup", "shared", "", "", "",false,false); parameters.push_back(psorted);
23                 CommandParameter pnumotu("numotu", "Number", "", "0", "", "", "",false,false); parameters.push_back(pnumotu);
24                 CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
25                 CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
26                 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
27                 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
28                 
29                 vector<string> myArray;
30                 for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
31                 return myArray;
32         }
33         catch(exception& e) {
34                 m->errorOut(e, "HeatMapCommand", "setParameters");
35                 exit(1);
36         }
37 }
38 //**********************************************************************************************************************
39 string HeatMapCommand::getHelpString(){ 
40         try {
41                 string helpString = "";
42                 helpString += "The heatmap.bin command parameters are shared, relabund, list, rabund, sabund, groups, sorted, scale, numotu, fontsize and label.  shared, relabund, list, rabund or sabund is required unless you have a valid current file.\n";
43                 helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n";
44                 helpString += "The sorted parameter allows you to order the otus displayed, default=shared, meaning display the shared otus first. Other options for sorted are none, meaning the exact representation of your otus, \n";
45                 helpString += "topotu, meaning the otus with the greatest abundance when totaled across groups, topgroup, meaning the top otus for each group. \n";
46                 helpString += "The scale parameter allows you to choose the range of color your bin information will be displayed with.\n";
47                 helpString += "The numotu parameter allows you to display only the top N otus, by default all the otus are displayed. You could choose to look at the top 10, by setting numotu=10. The default for sorted is topotu when numotu is used.\n";
48                 helpString += "The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and are also separated by dashes.\n";
49                 helpString += "The fontsize parameter allows you to adjust the font size of the picture created, default=24.\n";
50                 helpString += "The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, label=yourLabels).\n";
51                 helpString += "Example heatmap.bin(groups=A-B-C, sorted=none, scale=log10).\n";
52                 helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
53                 helpString += "The default value for scale is log10; your other options are log2 and linear.\n";
54                 helpString += "The heatmap.bin command outputs a .svg file for each label you specify.\n";
55                 helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n";
56                 return helpString;
57         }
58         catch(exception& e) {
59                 m->errorOut(e, "HeatMapCommand", "getHelpString");
60                 exit(1);
61         }
62 }
63
64 //**********************************************************************************************************************
65 HeatMapCommand::HeatMapCommand(){       
66         try {
67                 abort = true; calledHelp = true; 
68                 setParameters();
69                 vector<string> tempOutNames;
70                 outputTypes["svg"] = tempOutNames;
71         }
72         catch(exception& e) {
73                 m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
74                 exit(1);
75         }
76 }
77 //**********************************************************************************************************************
78
79 HeatMapCommand::HeatMapCommand(string option) {
80         try {
81                 abort = false; calledHelp = false;   
82                 allLines = 1;
83                 
84                 //allow user to run help
85                 if(option == "help") { help(); abort = true; calledHelp = true; }
86                 
87                 else {
88                         vector<string> myArray = setParameters();
89                         
90                         OptionParser parser(option);
91                         map<string,string> parameters = parser.getParameters();
92                         map<string,string>::iterator it;
93                         
94                         ValidParameters validParameter;
95                         
96                         //check to make sure all parameters are valid for command
97                         for (it = parameters.begin(); it != parameters.end(); it++) { 
98                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
99                         }
100                         
101                         //initialize outputTypes
102                         vector<string> tempOutNames;
103                         outputTypes["svg"] = tempOutNames;
104                 
105                         //if the user changes the input directory command factory will send this info to us in the output parameter 
106                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
107                         if (inputDir == "not found"){   inputDir = "";          }
108                         else {
109                                 string path;
110                                 it = parameters.find("shared");
111                                 //user has given a template file
112                                 if(it != parameters.end()){ 
113                                         path = m->hasPath(it->second);
114                                         //if the user has not given a path then, add inputdir. else leave path alone.
115                                         if (path == "") {       parameters["shared"] = inputDir + it->second;           }
116                                 }
117                                 
118                                 it = parameters.find("rabund");
119                                 //user has given a template file
120                                 if(it != parameters.end()){ 
121                                         path = m->hasPath(it->second);
122                                         //if the user has not given a path then, add inputdir. else leave path alone.
123                                         if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
124                                 }
125                                 
126                                 it = parameters.find("sabund");
127                                 //user has given a template file
128                                 if(it != parameters.end()){ 
129                                         path = m->hasPath(it->second);
130                                         //if the user has not given a path then, add inputdir. else leave path alone.
131                                         if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
132                                 }
133                                 
134                                 it = parameters.find("list");
135                                 //user has given a template file
136                                 if(it != parameters.end()){ 
137                                         path = m->hasPath(it->second);
138                                         //if the user has not given a path then, add inputdir. else leave path alone.
139                                         if (path == "") {       parameters["list"] = inputDir + it->second;             }
140                                 }
141                                 
142                                 it = parameters.find("relabund");
143                                 //user has given a template file
144                                 if(it != parameters.end()){ 
145                                         path = m->hasPath(it->second);
146                                         //if the user has not given a path then, add inputdir. else leave path alone.
147                                         if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
148                                 }
149                         }
150                         
151                         //check for required parameters
152                         listfile = validParameter.validFile(parameters, "list", true);
153                         if (listfile == "not open") { listfile = ""; abort = true; }
154                         else if (listfile == "not found") { listfile = ""; }
155                         else {  format = "list"; inputfile = listfile; }
156                         
157                         sabundfile = validParameter.validFile(parameters, "sabund", true);
158                         if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
159                         else if (sabundfile == "not found") { sabundfile = ""; }
160                         else {  format = "sabund"; inputfile = sabundfile; }
161                         
162                         rabundfile = validParameter.validFile(parameters, "rabund", true);
163                         if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
164                         else if (rabundfile == "not found") { rabundfile = ""; }
165                         else {  format = "rabund"; inputfile = rabundfile; }
166                         
167                         sharedfile = validParameter.validFile(parameters, "shared", true);
168                         if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
169                         else if (sharedfile == "not found") { sharedfile = ""; }
170                         else {  format = "sharedfile"; inputfile = sharedfile; }
171                         
172                         relabundfile = validParameter.validFile(parameters, "relabund", true);
173                         if (relabundfile == "not open") { relabundfile = ""; abort = true; }    
174                         else if (relabundfile == "not found") { relabundfile = ""; }
175                         else {  format = "relabund"; inputfile = relabundfile; }
176                         
177                         
178                         if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "") && (relabundfile == "")) { 
179                                 //is there are current file available for any of these?
180                                 //give priority to shared, then list, then rabund, then sabund
181                                 //if there is a current shared file, use it
182                                 sharedfile = m->getSharedFile(); 
183                                 if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
184                                 else { 
185                                         listfile = m->getListFile(); 
186                                         if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
187                                         else { 
188                                                 rabundfile = m->getRabundFile(); 
189                                                 if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
190                                                 else { 
191                                                         sabundfile = m->getSabundFile(); 
192                                                         if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
193                                                         else { 
194                                                                 relabundfile = m->getRelAbundFile(); 
195                                                                 if (relabundfile != "") { inputfile = relabundfile; format = "relabund"; m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
196                                                                 else { 
197                                                                         m->mothurOut("No valid current files. You must provide a list, sabund, rabund, relabund or shared file."); m->mothurOutEndLine(); 
198                                                                         abort = true;
199                                                                 }
200                                                         }
201                                                 }
202                                         }
203                                 }
204                         }
205                         
206                         
207                         //if the user changes the output directory command factory will send this info to us in the output parameter 
208                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
209                         
210                         //check for optional parameter and set defaults
211                         // ...at some point should added some additional type checking...
212                         label = validParameter.validFile(parameters, "label", false);                   
213                         if (label == "not found") { label = ""; }
214                         else { 
215                                 if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
216                                 else { allLines = 1;  }
217                         }
218                         
219                         
220                         groups = validParameter.validFile(parameters, "groups", false);                 
221                         if (groups == "not found") { groups = ""; }
222                         else { 
223                                 m->splitAtDash(groups, Groups);
224                                 m->Groups = Groups;
225                         }
226                         
227                         string temp = validParameter.validFile(parameters, "numotu", false);            if (temp == "not found") { temp = "0"; }
228                         convert(temp, numOTU);
229                         
230                         temp = validParameter.validFile(parameters, "fontsize", false);                         if (temp == "not found") { temp = "24"; }
231                         convert(temp, fontSize);
232                         
233                         sorted = validParameter.validFile(parameters, "sorted", false);                         
234                         if (sorted == "not found") { 
235                                 //if numOTU is used change default
236                                 if (numOTU != 0) { sorted = "topotu"; }
237                                 else { sorted = "shared"; }
238                         }
239                  
240                         scale = validParameter.validFile(parameters, "scale", false);                           if (scale == "not found") { scale = "log10"; }
241                         
242                         if ((sorted != "none") && (sorted != "shared") && (sorted != "topotu") && (sorted != "topgroup")) { m->mothurOut(sorted + " is not a valid sorting option. Sorted options are: none, shared, topotu, topgroup"); m->mothurOutEndLine(); abort=true;  }
243                 }
244
245         }
246         catch(exception& e) {
247                 m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
248                 exit(1);
249         }
250 }
251 //**********************************************************************************************************************
252
253 int HeatMapCommand::execute(){
254         try {
255         
256                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
257                 
258                 heatmap = new HeatMap(sorted, scale, numOTU, fontSize, outputDir, inputfile);
259
260                 string lastLabel;
261                 input = new InputData(inputfile, format);
262                 
263                 if (format == "sharedfile") {
264                         //you have groups
265                         lookup = input->getSharedRAbundVectors();
266                         lastLabel = lookup[0]->getLabel();
267         
268                 }else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
269                         //you are using just a list file and have only one group
270                         rabund = input->getRAbundVector();
271                         lastLabel = rabund->getLabel();
272                 }else if (format == "relabund") {
273                         //you have groups
274                         lookupFloat = input->getSharedRAbundFloatVectors();
275                         lastLabel = lookupFloat[0]->getLabel();
276                 }
277                 
278                 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
279                 set<string> processedLabels;
280                 set<string> userLabels = labels;
281
282                 if (format == "sharedfile") {   
283                 
284                         //as long as you are not at the end of the file or done wih the lines you want
285                         while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
286                                 if (m->control_pressed) {
287                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
288                                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
289                                         m->Groups.clear(); 
290                                         delete input; delete heatmap; return 0;
291                                 }
292                 
293                                 if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
294         
295                                         m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
296                                         string outputFileName = heatmap->getPic(lookup);
297                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
298                                         
299                                         processedLabels.insert(lookup[0]->getLabel());
300                                         userLabels.erase(lookup[0]->getLabel());
301                                 }
302                                 
303                                 if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
304                                         string saveLabel = lookup[0]->getLabel();
305                         
306                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
307                         
308                                         lookup = input->getSharedRAbundVectors(lastLabel);
309                                         m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
310                                         
311                                         string outputFileName = heatmap->getPic(lookup);
312                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
313                                         
314                                         processedLabels.insert(lookup[0]->getLabel());
315                                         userLabels.erase(lookup[0]->getLabel());
316                                         
317                                         //restore real lastlabel to save below
318                                         lookup[0]->setLabel(saveLabel);
319                                 }
320                                 
321                                 lastLabel = lookup[0]->getLabel();
322                                 //prevent memory leak
323                                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
324                                                         
325                                 //get next line to process
326                                 lookup = input->getSharedRAbundVectors();                               
327                         }
328                         
329                         
330                         if (m->control_pressed) {
331                                 for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
332                                 m->Groups.clear(); 
333                                 delete input; delete heatmap; return 0;
334                         }
335
336                         //output error messages about any remaining user labels
337                         set<string>::iterator it;
338                         bool needToRun = false;
339                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
340                                 m->mothurOut("Your file does not include the label " + *it); 
341                                 if (processedLabels.count(lastLabel) != 1) {
342                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
343                                         needToRun = true;
344                                 }else {
345                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
346                                 }
347                         }
348                 
349                         //run last label if you need to
350                         if (needToRun == true)  {
351                                 for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
352                                 lookup = input->getSharedRAbundVectors(lastLabel);
353                                 
354                                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
355                                 string outputFileName = heatmap->getPic(lookup);
356                                 outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
357                                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
358                         }
359                 
360                         //reset groups parameter
361                         m->Groups.clear();  
362                         
363                 }else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
364         
365                         while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
366                                 if (m->control_pressed) {   
367                                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
368                                         delete rabund;  delete input; delete heatmap; return 0; 
369                                 }
370
371                                 if(allLines == 1 || labels.count(rabund->getLabel()) == 1){                     
372         
373                                         m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
374                                         string outputFileName = heatmap->getPic(rabund);
375                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
376                                         
377                                         processedLabels.insert(rabund->getLabel());
378                                         userLabels.erase(rabund->getLabel());
379                                 }
380                                 
381                                 if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
382                                         string saveLabel = rabund->getLabel();
383                                         
384                                         delete rabund;
385                                         rabund = input->getRAbundVector(lastLabel);
386                                         m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
387                                         
388                                         string outputFileName = heatmap->getPic(rabund);
389                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
390                                         
391                                         processedLabels.insert(rabund->getLabel());
392                                         userLabels.erase(rabund->getLabel());
393                                         
394                                         //restore real lastlabel to save below
395                                         rabund->setLabel(saveLabel);
396                                 }               
397                                 
398                                                                 
399                                                                 
400                                 lastLabel = rabund->getLabel();                 
401                                 delete rabund;
402                                 rabund = input->getRAbundVector();
403                         }
404                         
405                         if (m->control_pressed) {
406                                 for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
407                                 delete input; delete heatmap; return 0;
408                         }
409
410                         //output error messages about any remaining user labels
411                         set<string>::iterator it;
412                         bool needToRun = false;
413                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
414                                 m->mothurOut("Your file does not include the label " + *it); 
415                                 if (processedLabels.count(lastLabel) != 1) {
416                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
417                                         needToRun = true;
418                                 }else {
419                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
420                                 }
421                         }
422                 
423                         //run last label if you need to
424                         if (needToRun == true)  {
425                 
426                                 if (rabund != NULL) {   delete rabund;  }
427                                 rabund = input->getRAbundVector(lastLabel);
428                                 m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
429                                         
430                                 string outputFileName = heatmap->getPic(rabund);
431                                 outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
432                                 delete rabund; 
433                         }
434                 
435                 }else {
436                 
437                         //as long as you are not at the end of the file or done wih the lines you want
438                         while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
439                                 if (m->control_pressed) {
440                                         for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
441                                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
442                                         m->Groups.clear(); 
443                                         delete input; delete heatmap; return 0;
444                                 }
445                 
446                                 if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){                     
447         
448                                         m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
449                                         string outputFileName = heatmap->getPic(lookupFloat);
450                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
451                                         
452                                         processedLabels.insert(lookupFloat[0]->getLabel());
453                                         userLabels.erase(lookupFloat[0]->getLabel());
454                                 }
455                                 
456                                 if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
457                                         string saveLabel = lookupFloat[0]->getLabel();
458                                 
459                                         for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }  
460                                         lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
461                                         m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
462                                         
463                                         string outputFileName = heatmap->getPic(lookupFloat);
464                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
465                                         
466                                         processedLabels.insert(lookupFloat[0]->getLabel());
467                                         userLabels.erase(lookupFloat[0]->getLabel());
468                                         
469                                         //restore real lastlabel to save below
470                                         lookupFloat[0]->setLabel(saveLabel);
471                                 }
472                                 
473                                 lastLabel = lookupFloat[0]->getLabel();
474                                 //prevent memory leak
475                                 for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i]; lookupFloat[i] = NULL; }
476                                                         
477                                 //get next line to process
478                                 lookupFloat = input->getSharedRAbundFloatVectors();                             
479                         }
480                         
481                         
482                         if (m->control_pressed) {
483                                 for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
484                                 m->Groups.clear(); 
485                                 delete input; delete heatmap; return 0;
486                         }
487
488                         //output error messages about any remaining user labels
489                         set<string>::iterator it;
490                         bool needToRun = false;
491                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
492                                 m->mothurOut("Your file does not include the label " + *it); 
493                                 if (processedLabels.count(lastLabel) != 1) {
494                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
495                                         needToRun = true;
496                                 }else {
497                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
498                                 }
499                         }
500                 
501                         //run last label if you need to
502                         if (needToRun == true)  {
503                                 for (int i = 0; i < lookupFloat.size(); i++) { if (lookupFloat[i] != NULL) { delete lookupFloat[i]; } }  
504                                 lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
505                                 
506                                 m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
507                                 string outputFileName = heatmap->getPic(lookupFloat);
508                                 outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
509                                 for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
510                         }
511                 
512                         //reset groups parameter
513                         m->Groups.clear();  
514
515                 }
516                 
517                 delete input; 
518                 delete heatmap;
519                 
520                 if (m->control_pressed) {
521                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear(); return 0;
522                 }
523                 
524                 m->mothurOutEndLine();
525                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
526                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
527                 m->mothurOutEndLine();
528
529                 return 0;
530         }
531         catch(exception& e) {
532                 m->errorOut(e, "HeatMapCommand", "execute");
533                 exit(1);
534         }
535 }
536
537 //**********************************************************************************************************************
538
539