]> git.donarmstrong.com Git - mothur.git/blob - heatmapcommand.cpp
1.23.0
[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";
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                 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
87                 
88                 else {
89                         vector<string> myArray = setParameters();
90                         
91                         OptionParser parser(option);
92                         map<string,string> parameters = parser.getParameters();
93                         map<string,string>::iterator it;
94                         
95                         ValidParameters validParameter;
96                         
97                         //check to make sure all parameters are valid for command
98                         for (it = parameters.begin(); it != parameters.end(); it++) { 
99                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
100                         }
101                         
102                         //initialize outputTypes
103                         vector<string> tempOutNames;
104                         outputTypes["svg"] = tempOutNames;
105                 
106                         //if the user changes the input directory command factory will send this info to us in the output parameter 
107                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
108                         if (inputDir == "not found"){   inputDir = "";          }
109                         else {
110                                 string path;
111                                 it = parameters.find("shared");
112                                 //user has given a template file
113                                 if(it != parameters.end()){ 
114                                         path = m->hasPath(it->second);
115                                         //if the user has not given a path then, add inputdir. else leave path alone.
116                                         if (path == "") {       parameters["shared"] = inputDir + it->second;           }
117                                 }
118                                 
119                                 it = parameters.find("rabund");
120                                 //user has given a template file
121                                 if(it != parameters.end()){ 
122                                         path = m->hasPath(it->second);
123                                         //if the user has not given a path then, add inputdir. else leave path alone.
124                                         if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
125                                 }
126                                 
127                                 it = parameters.find("sabund");
128                                 //user has given a template file
129                                 if(it != parameters.end()){ 
130                                         path = m->hasPath(it->second);
131                                         //if the user has not given a path then, add inputdir. else leave path alone.
132                                         if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
133                                 }
134                                 
135                                 it = parameters.find("list");
136                                 //user has given a template file
137                                 if(it != parameters.end()){ 
138                                         path = m->hasPath(it->second);
139                                         //if the user has not given a path then, add inputdir. else leave path alone.
140                                         if (path == "") {       parameters["list"] = inputDir + it->second;             }
141                                 }
142                                 
143                                 it = parameters.find("relabund");
144                                 //user has given a template file
145                                 if(it != parameters.end()){ 
146                                         path = m->hasPath(it->second);
147                                         //if the user has not given a path then, add inputdir. else leave path alone.
148                                         if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
149                                 }
150                         }
151                         
152                         //check for required parameters
153                         listfile = validParameter.validFile(parameters, "list", true);
154                         if (listfile == "not open") { listfile = ""; abort = true; }
155                         else if (listfile == "not found") { listfile = ""; }
156                         else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
157                         
158                         sabundfile = validParameter.validFile(parameters, "sabund", true);
159                         if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
160                         else if (sabundfile == "not found") { sabundfile = ""; }
161                         else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
162                         
163                         rabundfile = validParameter.validFile(parameters, "rabund", true);
164                         if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
165                         else if (rabundfile == "not found") { rabundfile = ""; }
166                         else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
167                         
168                         sharedfile = validParameter.validFile(parameters, "shared", true);
169                         if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
170                         else if (sharedfile == "not found") { sharedfile = ""; }
171                         else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
172                         
173                         relabundfile = validParameter.validFile(parameters, "relabund", true);
174                         if (relabundfile == "not open") { relabundfile = ""; abort = true; }    
175                         else if (relabundfile == "not found") { relabundfile = ""; }
176                         else {  format = "relabund"; inputfile = relabundfile; m->setRelAbundFile(relabundfile); }
177                         
178                         
179                         if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "") && (relabundfile == "")) { 
180                                 //is there are current file available for any of these?
181                                 //give priority to shared, then list, then rabund, then sabund
182                                 //if there is a current shared file, use it
183                                 sharedfile = m->getSharedFile(); 
184                                 if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
185                                 else { 
186                                         listfile = m->getListFile(); 
187                                         if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
188                                         else { 
189                                                 rabundfile = m->getRabundFile(); 
190                                                 if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
191                                                 else { 
192                                                         sabundfile = m->getSabundFile(); 
193                                                         if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
194                                                         else { 
195                                                                 relabundfile = m->getRelAbundFile(); 
196                                                                 if (relabundfile != "") { inputfile = relabundfile; format = "relabund"; m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
197                                                                 else { 
198                                                                         m->mothurOut("No valid current files. You must provide a list, sabund, rabund, relabund or shared file."); m->mothurOutEndLine(); 
199                                                                         abort = true;
200                                                                 }
201                                                         }
202                                                 }
203                                         }
204                                 }
205                         }
206                         
207                         
208                         //if the user changes the output directory command factory will send this info to us in the output parameter 
209                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
210                         
211                         //check for optional parameter and set defaults
212                         // ...at some point should added some additional type checking...
213                         label = validParameter.validFile(parameters, "label", false);                   
214                         if (label == "not found") { label = ""; }
215                         else { 
216                                 if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
217                                 else { allLines = 1;  }
218                         }
219                         
220                         
221                         groups = validParameter.validFile(parameters, "groups", false);                 
222                         if (groups == "not found") { groups = ""; }
223                         else { 
224                                 m->splitAtDash(groups, Groups);
225                                 m->setGroups(Groups);
226                         }
227                         
228                         string temp = validParameter.validFile(parameters, "numotu", false);            if (temp == "not found") { temp = "0"; }
229                         m->mothurConvert(temp, numOTU);
230                         
231                         temp = validParameter.validFile(parameters, "fontsize", false);                         if (temp == "not found") { temp = "24"; }
232                         m->mothurConvert(temp, fontSize);
233                         
234                         sorted = validParameter.validFile(parameters, "sorted", false);                         
235                         if (sorted == "not found") { 
236                                 //if numOTU is used change default
237                                 if (numOTU != 0) { sorted = "topotu"; }
238                                 else { sorted = "shared"; }
239                         }
240                  
241                         scale = validParameter.validFile(parameters, "scale", false);                           if (scale == "not found") { scale = "log10"; }
242                         
243                         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;  }
244                 }
245
246         }
247         catch(exception& e) {
248                 m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
249                 exit(1);
250         }
251 }
252 //**********************************************************************************************************************
253
254 int HeatMapCommand::execute(){
255         try {
256         
257                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
258                 
259                 heatmap = new HeatMap(sorted, scale, numOTU, fontSize, outputDir, inputfile);
260
261                 string lastLabel;
262                 input = new InputData(inputfile, format);
263                 
264                 if (format == "sharedfile") {
265                         //you have groups
266                         lookup = input->getSharedRAbundVectors();
267                         lastLabel = lookup[0]->getLabel();
268         
269                 }else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
270                         //you are using just a list file and have only one group
271                         rabund = input->getRAbundVector();
272                         lastLabel = rabund->getLabel();
273                 }else if (format == "relabund") {
274                         //you have groups
275                         lookupFloat = input->getSharedRAbundFloatVectors();
276                         lastLabel = lookupFloat[0]->getLabel();
277                 }
278                 
279                 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
280                 set<string> processedLabels;
281                 set<string> userLabels = labels;
282
283                 if (format == "sharedfile") {   
284                 
285                         //as long as you are not at the end of the file or done wih the lines you want
286                         while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
287                                 if (m->control_pressed) {
288                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
289                                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
290                                         m->clearGroups(); 
291                                         delete input; delete heatmap; return 0;
292                                 }
293                 
294                                 if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
295         
296                                         m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
297                                         string outputFileName = heatmap->getPic(lookup);
298                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
299                                         
300                                         processedLabels.insert(lookup[0]->getLabel());
301                                         userLabels.erase(lookup[0]->getLabel());
302                                 }
303                                 
304                                 if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
305                                         string saveLabel = lookup[0]->getLabel();
306                         
307                                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
308                         
309                                         lookup = input->getSharedRAbundVectors(lastLabel);
310                                         m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
311                                         
312                                         string outputFileName = heatmap->getPic(lookup);
313                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
314                                         
315                                         processedLabels.insert(lookup[0]->getLabel());
316                                         userLabels.erase(lookup[0]->getLabel());
317                                         
318                                         //restore real lastlabel to save below
319                                         lookup[0]->setLabel(saveLabel);
320                                 }
321                                 
322                                 lastLabel = lookup[0]->getLabel();
323                                 //prevent memory leak
324                                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
325                                                         
326                                 //get next line to process
327                                 lookup = input->getSharedRAbundVectors();                               
328                         }
329                         
330                         
331                         if (m->control_pressed) {
332                                 for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
333                                 m->clearGroups(); 
334                                 delete input; delete heatmap; return 0;
335                         }
336
337                         //output error messages about any remaining user labels
338                         set<string>::iterator it;
339                         bool needToRun = false;
340                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
341                                 m->mothurOut("Your file does not include the label " + *it); 
342                                 if (processedLabels.count(lastLabel) != 1) {
343                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
344                                         needToRun = true;
345                                 }else {
346                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
347                                 }
348                         }
349                 
350                         //run last label if you need to
351                         if (needToRun == true)  {
352                                 for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
353                                 lookup = input->getSharedRAbundVectors(lastLabel);
354                                 
355                                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
356                                 string outputFileName = heatmap->getPic(lookup);
357                                 outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
358                                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
359                         }
360                 
361                         //reset groups parameter
362                         m->clearGroups();  
363                         
364                 }else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
365         
366                         while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
367                                 if (m->control_pressed) {   
368                                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
369                                         delete rabund;  delete input; delete heatmap; return 0; 
370                                 }
371
372                                 if(allLines == 1 || labels.count(rabund->getLabel()) == 1){                     
373         
374                                         m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
375                                         string outputFileName = heatmap->getPic(rabund);
376                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
377                                         
378                                         processedLabels.insert(rabund->getLabel());
379                                         userLabels.erase(rabund->getLabel());
380                                 }
381                                 
382                                 if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
383                                         string saveLabel = rabund->getLabel();
384                                         
385                                         delete rabund;
386                                         rabund = input->getRAbundVector(lastLabel);
387                                         m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
388                                         
389                                         string outputFileName = heatmap->getPic(rabund);
390                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
391                                         
392                                         processedLabels.insert(rabund->getLabel());
393                                         userLabels.erase(rabund->getLabel());
394                                         
395                                         //restore real lastlabel to save below
396                                         rabund->setLabel(saveLabel);
397                                 }               
398                                 
399                                                                 
400                                                                 
401                                 lastLabel = rabund->getLabel();                 
402                                 delete rabund;
403                                 rabund = input->getRAbundVector();
404                         }
405                         
406                         if (m->control_pressed) {
407                                 for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
408                                 delete input; delete heatmap; return 0;
409                         }
410
411                         //output error messages about any remaining user labels
412                         set<string>::iterator it;
413                         bool needToRun = false;
414                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
415                                 m->mothurOut("Your file does not include the label " + *it); 
416                                 if (processedLabels.count(lastLabel) != 1) {
417                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
418                                         needToRun = true;
419                                 }else {
420                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
421                                 }
422                         }
423                 
424                         //run last label if you need to
425                         if (needToRun == true)  {
426                 
427                                 if (rabund != NULL) {   delete rabund;  }
428                                 rabund = input->getRAbundVector(lastLabel);
429                                 m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
430                                         
431                                 string outputFileName = heatmap->getPic(rabund);
432                                 outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
433                                 delete rabund; 
434                         }
435                 
436                 }else {
437                 
438                         //as long as you are not at the end of the file or done wih the lines you want
439                         while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
440                                 if (m->control_pressed) {
441                                         for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
442                                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
443                                         m->clearGroups(); 
444                                         delete input; delete heatmap; return 0;
445                                 }
446                 
447                                 if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){                     
448         
449                                         m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
450                                         string outputFileName = heatmap->getPic(lookupFloat);
451                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
452                                         
453                                         processedLabels.insert(lookupFloat[0]->getLabel());
454                                         userLabels.erase(lookupFloat[0]->getLabel());
455                                 }
456                                 
457                                 if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
458                                         string saveLabel = lookupFloat[0]->getLabel();
459                                 
460                                         for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }  
461                                         lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
462                                         m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
463                                         
464                                         string outputFileName = heatmap->getPic(lookupFloat);
465                                         outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
466                                         
467                                         processedLabels.insert(lookupFloat[0]->getLabel());
468                                         userLabels.erase(lookupFloat[0]->getLabel());
469                                         
470                                         //restore real lastlabel to save below
471                                         lookupFloat[0]->setLabel(saveLabel);
472                                 }
473                                 
474                                 lastLabel = lookupFloat[0]->getLabel();
475                                 //prevent memory leak
476                                 for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i]; lookupFloat[i] = NULL; }
477                                                         
478                                 //get next line to process
479                                 lookupFloat = input->getSharedRAbundFloatVectors();                             
480                         }
481                         
482                         
483                         if (m->control_pressed) {
484                                 for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
485                                 m->clearGroups(); 
486                                 delete input; delete heatmap; return 0;
487                         }
488
489                         //output error messages about any remaining user labels
490                         set<string>::iterator it;
491                         bool needToRun = false;
492                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
493                                 m->mothurOut("Your file does not include the label " + *it); 
494                                 if (processedLabels.count(lastLabel) != 1) {
495                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
496                                         needToRun = true;
497                                 }else {
498                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
499                                 }
500                         }
501                 
502                         //run last label if you need to
503                         if (needToRun == true)  {
504                                 for (int i = 0; i < lookupFloat.size(); i++) { if (lookupFloat[i] != NULL) { delete lookupFloat[i]; } }  
505                                 lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
506                                 
507                                 m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
508                                 string outputFileName = heatmap->getPic(lookupFloat);
509                                 outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
510                                 for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
511                         }
512                 
513                         //reset groups parameter
514                         m->clearGroups();  
515
516                 }
517                 
518                 delete input; 
519                 delete heatmap;
520                 
521                 if (m->control_pressed) {
522                         for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear(); return 0;
523                 }
524                 
525                 m->mothurOutEndLine();
526                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
527                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
528                 m->mothurOutEndLine();
529
530                 return 0;
531         }
532         catch(exception& e) {
533                 m->errorOut(e, "HeatMapCommand", "execute");
534                 exit(1);
535         }
536 }
537
538 //**********************************************************************************************************************
539
540