]> git.donarmstrong.com Git - mothur.git/blob - cooccurrencecommand.cpp
added shannonrange calc.
[mothur.git] / cooccurrencecommand.cpp
1 /*
2  *  cooccurrencecommand.cpp
3  *  Mothur
4  *
5  *  Created by kiverson on 1/2/12.
6  *  Copyright 2012 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "cooccurrencecommand.h"
11
12 //**********************************************************************************************************************
13 vector<string> CooccurrenceCommand::setParameters() {   
14         try { 
15                 CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pshared);              
16                 CommandParameter pmetric("metric", "Multiple", "cscore-checker-combo-vratio", "cscore", "", "", "","",false,false); parameters.push_back(pmetric);
17                 CommandParameter pmatrix("matrixmodel", "Multiple", "sim1-sim2-sim3-sim4-sim5-sim6-sim7-sim8-sim9", "sim2", "", "", "","",false,false); parameters.push_back(pmatrix);
18         CommandParameter pruns("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(pruns);
19                 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
20                 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
21                 CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
22         CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
23
24                 vector<string> myArray;
25                 for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
26                 return myArray;
27         }
28         catch(exception& e) {
29                 m->errorOut(e, "CooccurrenceCommand", "setParameters");
30                 exit(1);
31         }
32 }
33 //**********************************************************************************************************************
34 string CooccurrenceCommand::getHelpString(){    
35         try {
36                 string helpString = "The cooccurrence command calculates four metrics and tests their significance to assess whether presence-absence patterns are different than what one would expect by chance.";
37         helpString += "The cooccurrence command parameters are shared, metric, matrixmodel, iters, label and groups.";
38         helpString += "The matrixmodel parameter options are sim1, sim2, sim3, sim4, sim5, sim6, sim7, sim8 and sim9. Default=sim2";
39         helpString += "The metric parameter options are cscore, checker, combo and vratio. Default=cscore";
40         helpString += "The label parameter is used to analyze specific labels in your input.\n";
41                 helpString += "The groups parameter allows you to specify which of the groups you would like analyzed.\n";
42         helpString += "The cooccurrence command should be in the following format: \n";
43                 helpString += "cooccurrence(shared=yourSharedFile) \n";
44                 helpString += "Example cooccurrence(shared=final.an.shared).\n";
45                 helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourShared).\n";
46                 return helpString;
47         }
48         catch(exception& e) {
49                 m->errorOut(e, "CooccurrenceCommand", "getHelpString");
50                 exit(1);
51         }
52 }
53 //**********************************************************************************************************************
54 string CooccurrenceCommand::getOutputPattern(string type) {
55     try {
56         string pattern = "";
57         
58         if (type == "summary") {  pattern = "[filename],cooccurence.summary"; }
59         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
60         
61         return pattern;
62     }
63     catch(exception& e) {
64         m->errorOut(e, "CooccurrenceCommand", "getOutputPattern");
65         exit(1);
66     }
67 }
68 //**********************************************************************************************************************
69 CooccurrenceCommand::CooccurrenceCommand(){     
70         try {
71                 abort = true; calledHelp = true; 
72                 setParameters();
73         vector<string> tempOutNames;
74                 outputTypes["summary"] = tempOutNames;
75
76         }
77         catch(exception& e) {
78                 m->errorOut(e, "CooccurrenceCommand", "CooccurrenceCommand");
79                 exit(1);
80         }
81 }
82 //**********************************************************************************************************************
83 CooccurrenceCommand::CooccurrenceCommand(string option) {
84         try {
85                 abort = false; calledHelp = false;   
86                 allLines = 1;
87                                 
88                 //allow user to run help
89                 if(option == "help") { help(); abort = true; calledHelp = true; }
90                 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
91                 
92                 else {
93                         vector<string> myArray = setParameters();
94                         
95                         OptionParser parser(option);
96                         map<string,string> parameters = parser.getParameters();
97                         map<string,string>::iterator it;
98                         
99                         ValidParameters validParameter;
100                         
101                         //check to make sure all parameters are valid for command
102                         for (it = parameters.begin(); it != parameters.end(); it++) { 
103                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
104                         }
105
106                         
107                         //if the user changes the input directory command factory will send this info to us in the output parameter 
108                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
109                         if (inputDir == "not found"){   inputDir = "";          }
110                         else {
111                                 string path;
112                                 it = parameters.find("shared");
113                                 //user has given a template file
114                                 if(it != parameters.end()){ 
115                                         path = m->hasPath(it->second);
116                                         //if the user has not given a path then, add inputdir. else leave path alone.
117                                         if (path == "") {       parameters["shared"] = inputDir + it->second;           }
118                                 }
119                         }
120                 
121             vector<string> tempOutNames;
122             outputTypes["summary"] = tempOutNames;
123                 
124                 //check for optional parameter and set defaults
125                         // ...at some point should added some additional type checking...
126                         label = validParameter.validFile(parameters, "label", false);                   
127                         if (label == "not found") { label = ""; }
128                         else { 
129                                 if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
130                                 else { allLines = 1;  }
131                         }
132                         
133                         //get shared file
134                         sharedfile = validParameter.validFile(parameters, "shared", true);
135                         if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
136                         else if (sharedfile == "not found") { 
137                                 //if there is a current shared file, use it
138                                 sharedfile = m->getSharedFile(); 
139                                 if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
140                                 else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
141                         }else { m->setSharedFile(sharedfile); }
142                         
143                         
144                         //if the user changes the output directory command factory will send this info to us in the output parameter 
145                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
146
147                         
148                         metric = validParameter.validFile(parameters, "metric", false);                         if (metric == "not found") { metric = "cscore"; }
149                         
150                         if ((metric != "cscore") && (metric != "checker") && (metric != "combo") && (metric != "vratio")) {
151                                 m->mothurOut("[ERROR]: " + metric + " is not a valid metric option for the cooccurrence command. Choices are cscore, checker, combo, vratio."); m->mothurOutEndLine(); abort = true; 
152                         }
153                         
154                         matrix = validParameter.validFile(parameters, "matrixmodel", false);                            if (matrix == "not found") { matrix = "sim2"; }
155                         
156                         if ((matrix != "sim1") && (matrix != "sim2") && (matrix != "sim3") && (matrix != "sim4") && (matrix != "sim5" ) && (matrix != "sim6" ) && (matrix != "sim7" ) && (matrix != "sim8" ) && (matrix != "sim9" )) {
157                                 m->mothurOut("[ERROR]: " + matrix + " is not a valid matrix option for the cooccurrence command. Choices are sim1, sim2, sim3, sim4, sim5, sim6, sim7, sim8, sim9."); m->mothurOutEndLine(); abort = true; 
158                         }
159             
160             groups = validParameter.validFile(parameters, "groups", false);                     
161                         if (groups == "not found") { groups = "";   }
162                         else { 
163                                 m->splitAtDash(groups, Groups); 
164                         }                       
165                         m->setGroups(Groups);
166             
167             string temp = validParameter.validFile(parameters, "iters", false);                 if (temp == "not found") { temp = "1000"; }
168                         m->mothurConvert(temp, runs); 
169
170                 }
171
172         }
173         catch(exception& e) {
174                 m->errorOut(e, "CooccurrenceCommand", "CooccurrenceCommand");
175                 exit(1);
176         }
177 }
178 //**********************************************************************************************************************
179
180 int CooccurrenceCommand::execute(){
181         try {
182         
183                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
184                 
185                 InputData* input = new InputData(sharedfile, "sharedfile");
186                 vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
187                 string lastLabel = lookup[0]->getLabel();
188                 
189                 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
190                 set<string> processedLabels;
191                 set<string> userLabels = labels;
192
193         ofstream out;
194         map<string, string> variables; 
195         variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
196                 string outputFileName = getOutputFileName("summary", variables);
197         m->openOutputFile(outputFileName, out);
198         outputNames.push_back(outputFileName);  outputTypes["summary"].push_back(outputFileName);
199         out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
200         out << "metric\tlabel\tScore\tzScore\tstandardDeviation\tnp_Pvalue\n";
201
202                 //as long as you are not at the end of the file or done wih the lines you want
203                 while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
204                         
205                         if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
206         
207                         if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
208
209                                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
210                                 
211                                 getCooccurrence(lookup, out);
212                                 
213                                 processedLabels.insert(lookup[0]->getLabel());
214                                 userLabels.erase(lookup[0]->getLabel());
215                         }
216                         
217                         if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
218                                 string saveLabel = lookup[0]->getLabel();
219                         
220                                 for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
221                                 lookup = input->getSharedRAbundVectors(lastLabel);
222                                 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
223                                 getCooccurrence(lookup, out);
224                                 
225                                 processedLabels.insert(lookup[0]->getLabel());
226                                 userLabels.erase(lookup[0]->getLabel());
227                                 
228                                 //restore real lastlabel to save below
229                                 lookup[0]->setLabel(saveLabel);
230                         }
231                         
232                         lastLabel = lookup[0]->getLabel();
233                         //prevent memory leak
234                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
235                         
236                         if (m->control_pressed) {  outputTypes.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
237
238                         //get next line to process
239                         lookup = input->getSharedRAbundVectors();                               
240                 }
241                 
242                 if (m->control_pressed) { delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
243
244                 //output error messages about any remaining user labels
245                 set<string>::iterator it;
246                 bool needToRun = false;
247                 for (it = userLabels.begin(); it != userLabels.end(); it++) {  
248                         m->mothurOut("Your file does not include the label " + *it); 
249                         if (processedLabels.count(lastLabel) != 1) {
250                                 m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
251                                 needToRun = true;
252                         }else {
253                                 m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
254                         }
255                 }
256         
257                 //run last label if you need to
258                 if (needToRun == true)  {
259                         for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
260                         lookup = input->getSharedRAbundVectors(lastLabel);
261                         
262                         m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
263                         
264                         getCooccurrence(lookup, out);
265                         
266                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
267                 }
268         
269         out.close(); 
270         
271                 //reset groups parameter 
272                 delete input; 
273         m->clearGroups(); 
274
275         m->mothurOutEndLine();
276                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
277                 m->mothurOut(outputFileName); m->mothurOutEndLine();    
278                 m->mothurOutEndLine();
279         
280                 return 0;
281         }
282         catch(exception& e) {
283                 m->errorOut(e, "CooccurrenceCommand", "execute");
284                 exit(1);
285         }
286 }
287 //**********************************************************************************************************************
288
289 int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp, ofstream& out){
290     try {
291         int numOTUS = thisLookUp[0]->getNumBins();
292         
293         if(numOTUS < 2) {
294             m->mothurOut("Not enough OTUs for co-occurrence analysis, skipping"); m->mothurOutEndLine();
295             return 0;
296         }
297         
298         vector< vector<int> > co_matrix; co_matrix.resize(thisLookUp[0]->getNumBins());
299         for (int i = 0; i < thisLookUp[0]->getNumBins(); i++) { co_matrix[i].resize((thisLookUp.size()), 0); }
300         vector<int> columntotal; columntotal.resize(thisLookUp.size(), 0);
301         vector<int> rowtotal; rowtotal.resize(numOTUS, 0);
302         
303         for (int i = 0; i < thisLookUp.size(); i++) { //nrows in the shared file
304             for (int j = 0; j < thisLookUp[i]->getNumBins(); j++) { //cols of original shared file
305                 if (m->control_pressed) { return 0; }
306                 int abund = thisLookUp[i]->getAbundance(j);
307                 
308                 if(abund > 0) {
309                     co_matrix[j][i] = 1;
310                     rowtotal[j]++;
311                     columntotal[i]++;
312                 }
313             }
314         }
315         
316         //nrows is ncols of inital matrix. All the functions need this value. They assume the transposition has already taken place and nrows and ncols refer to that matrix.
317         //comatrix and initmatrix are still vectors of vectors of ints as in the original script. The abundancevector is only what was read in ie not a co-occurrence matrix!
318         int nrows = numOTUS;//rows of inital matrix
319         int ncols = thisLookUp.size();//groups
320         double initscore = 0.0;
321        
322         vector<double> stats;
323         vector<double> probabilityMatrix; probabilityMatrix.resize(ncols * nrows, 0);
324         vector<vector<int> > nullmatrix(nrows, vector<int>(ncols, 0));
325        
326         TrialSwap2 trial;
327         
328         int n = accumulate( columntotal.begin(), columntotal.end(), 0 );
329         
330         //============================================================
331         
332         //generate a probability matrix. Only do this once.
333         float start = 0.0;
334         
335         if (matrix == "sim1") {
336             for(int i=0;i<nrows;i++) {
337                 for(int j=0;j<ncols;j++) {
338                     probabilityMatrix[ncols * i + j] = start + 1/double(nrows*ncols);
339                     start = start + 1/double(nrows*ncols);
340                 }
341             }
342         }
343         //don't need a prob matrix because we just shuffle the rows, may use this in the future
344         else if (matrix == "sim2") { }
345 //            for(int i=0;i<nrows;i++) {
346 //                start = 0.0;
347 //                for(int j=0;j<ncols;j++) {
348 //                    probabilityMatrix[ncols * i + j] = start + 1/double(ncols);
349 //                    start = start + 1/double(ncols);
350 //                }
351 //            }
352 //        }
353         
354         else if (matrix == "sim3") {
355             for(int j=0;j<ncols;j++) {
356                 start = 0.0;
357                 for(int i=0;i<nrows;i++) {
358                     probabilityMatrix[ncols * i + j] = start + 1/double(nrows);
359                     start = start + 1/double(nrows);
360                 }
361             }
362         }
363         
364         else if (matrix == "sim4") {
365             for(int i=0;i<nrows;i++) {
366                 start = 0.0;
367                 for(int j=0;j<ncols;j++) {
368                     probabilityMatrix[ncols * i + j] = start + columntotal[j]/double(n);
369                     start = start + columntotal[j]/double(n);
370                 }
371             }
372         }
373         
374         else if (matrix == "sim5") {
375             for(int j=0;j<ncols;j++) {
376                 start = 0.0;
377                 for(int i=0;i<nrows;i++) {
378                     probabilityMatrix[ncols * i + j] = start + rowtotal[i]/double(n);
379                     start = start + rowtotal[i]/double(n);
380                 }
381             }
382         }
383         
384         else if (matrix == "sim6") {
385             for(int i=0;i<nrows;i++) {
386                 for(int j=0;j<ncols;j++) {
387                     probabilityMatrix[ncols * i + j] = start + columntotal[j]/double(n*nrows);
388                     start = start + columntotal[j]/double(n*nrows);
389                 }
390             }
391         }
392         
393         
394         else if (matrix == "sim7") {
395             for(int i=0;i<nrows;i++) {
396                 for(int j=0;j<ncols;j++) {
397                     probabilityMatrix[ncols * i + j] = start + rowtotal[i]/double(n*ncols);
398                     start = start + rowtotal[i]/double(n*ncols);
399                 }
400             }
401         }
402         
403         else if (matrix == "sim8") {
404             for(int i=0;i<nrows;i++) {
405                 for(int j=0;j<ncols;j++) {
406                     probabilityMatrix[ncols * i + j] = start + (rowtotal[i]*columntotal[j])/double(n*n);
407                     start = start + (rowtotal[i]*columntotal[j])/double(n*n);
408                 }
409             }
410         }
411         else if (matrix == "sim9" || matrix == "sim2") { }
412         else {
413             m->mothurOut("[ERROR]: No model selected! \n");
414             m->control_pressed = true;
415         }
416         
417         
418         //co_matrix is the transposed shared file, initmatrix is the original shared file
419         if (metric == "cscore") { initscore = trial.calc_c_score(co_matrix, rowtotal, ncols, nrows); }
420         else if (metric == "checker") { initscore = trial.calc_checker(co_matrix, rowtotal, ncols, nrows); }
421         else if (metric == "vratio") { initscore = trial.calc_vratio(nrows, ncols, rowtotal, columntotal); }
422         else if (metric == "combo") { initscore = trial.calc_combo(nrows, ncols, co_matrix); }
423         else { m->mothurOut("[ERROR]: No metric selected!\n"); m->control_pressed = true; return 1; }
424         
425         m->mothurOut("Initial c score: " + toString(initscore)); m->mothurOutEndLine();
426         
427         double previous;
428         double current;
429         double randnum;
430         int count;
431
432         //burn-in for sim9    
433         if(matrix == "sim9") {
434             for(int i=0;i<10000;i++) trial.swap_checkerboards (co_matrix, ncols, nrows);
435         }
436
437         //populate null matrix from probability matrix, do this a lot.
438         for(int k=0;k<runs;k++){
439             nullmatrix.clear();
440             //zero-fill the null matrix
441             nullmatrix.assign(nrows, vector<int>(ncols, 0));
442             
443             if(matrix == "sim1" || matrix == "sim6" || matrix == "sim8" || matrix == "sim7") {
444                 count = 0;
445                 while(count < n) {
446                     if (m->control_pressed) { return 0; }
447                 nextnum2:
448                     previous = 0.0;
449                     randnum = rand() / double(RAND_MAX);
450                     for(int i=0;i<nrows;i++) {
451                         for(int j=0;j<ncols;j++) {
452                             current = probabilityMatrix[ncols * i + j];
453                             if(randnum <= current && randnum > previous) {
454                                 nullmatrix[i][j] = 1;
455                                 count++;
456                                 if (count > n) break;
457                                 else
458                                     goto nextnum2;
459                             }
460                             previous = current;
461                         }
462                     }
463                 }
464             }
465             
466             else if (matrix == "sim2") {
467                 for(int i=0;i<nrows;i++) {
468                     random_shuffle( co_matrix[i].begin(), co_matrix[i].end() ); 
469                 }
470                 //do this for the scoring since those all have nullmatrix as a parameter
471                 //nullmatrix gets cleared at the begining of each run
472                 nullmatrix = co_matrix;
473             }
474             
475             else if(matrix == "sim4") {
476                 for(int i=0;i<nrows;i++) {
477                     count = 0;
478                     while(count < rowtotal[i]) {
479                         previous = 0.0;
480                         if (m->control_pressed) { return 0; }
481                         randnum = rand() / double(RAND_MAX);
482                         for(int j=0;j<ncols;j++) {
483                             current = probabilityMatrix[ncols * i + j];
484                             if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
485                                 nullmatrix[i][j] = 1;
486                                 count++;
487                                 previous = 0.0;
488                                 break;
489                             }
490                             previous = current;
491                         }
492                     }
493                 }
494             }
495             
496             else if(matrix == "sim3" || matrix == "sim5") {
497                 //columns
498                 for(int j=0;j<ncols;j++) {
499                     count = 0;
500                     while(count < columntotal[j]) {
501                         if (m->control_pressed) { return 0; }
502                         randnum = rand() / double(RAND_MAX);
503                         for(int i=0;i<nrows;i++) {
504                             current = probabilityMatrix[ncols * i + j];
505                             if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
506                                 nullmatrix[i][j] = 1;
507                                 count++;
508                                 previous = 0.0;
509                                 break;
510                             }
511                             previous = current;
512                         }
513                     }
514                 }
515             }
516             
517             //swap_checkerboards takes the original matrix and swaps checkerboards
518             else if(matrix == "sim9") {
519                 trial.swap_checkerboards (co_matrix, ncols, nrows);
520                 nullmatrix = co_matrix;
521             }
522             else {
523                 m->mothurOut("[ERROR]: No null model selected!\n\n"); m->control_pressed = true;
524                 return 1;
525             }
526             
527             //run metric on null matrix and add score to the stats vector
528             if (metric == "cscore"){
529                 stats.push_back(trial.calc_c_score(nullmatrix, rowtotal, ncols, nrows));
530             }
531             else if (metric == "checker") {
532                 stats.push_back(trial.calc_checker(nullmatrix, rowtotal, ncols, nrows));
533             }
534             else if (metric == "vratio") {
535                 stats.push_back(trial.calc_vratio(nrows, ncols, rowtotal, columntotal));
536             }
537             else if (metric == "combo") {
538                 stats.push_back(trial.calc_combo(nrows, ncols, nullmatrix));
539             }
540             else {
541                 m->mothurOut("[ERROR]: No metric selected!\n\n"); m->control_pressed = true;
542                 return 1;
543             }
544             
545         }
546         
547         
548         
549         double total = 0.0;
550         for (int i=0; i<stats.size();i++) { total+=stats[i]; }
551         
552         double nullMean = double (total/(double)stats.size());
553         
554         m->mothurOutEndLine(); m->mothurOut("average metric score: " + toString(nullMean)); m->mothurOutEndLine();
555         
556         //calc_p_value is not a statistical p-value, it's just the average that are either > or < the initscore.
557         //All it does is show what is expected in a competitively structured community
558         //zscore is output so p-value can be looked up in a ztable
559         double pvalue = 0.0;
560         if (metric == "cscore" || metric == "checker") { pvalue = trial.calc_pvalue_greaterthan (stats, initscore); }
561         else{ pvalue = trial.calc_pvalue_lessthan (stats, initscore); }
562
563         double sd = trial.getSD(runs, stats, nullMean);
564
565         double zscore = trial.get_zscore(sd, nullMean, initscore);
566         
567         m->mothurOut("zscore: " + toString(zscore)); m->mothurOutEndLine();
568         m->mothurOut("standard deviation: " + toString(sd)); m->mothurOutEndLine();
569         m->mothurOut("non-parametric p-value: " + toString(pvalue)); m->mothurOutEndLine();
570         out << metric << '\t' << thisLookUp[0]->getLabel() << '\t' << nullMean << '\t' << zscore << '\t' << sd << '\t' << pvalue << endl;
571         
572         return 0;
573     }
574     catch(exception& e) {
575         m->errorOut(e, "CooccurrenceCommand", "Cooccurrence");
576         exit(1);
577     }
578 }
579 //**********************************************************************************************************************
580
581