X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lefsecommand.cpp;h=c478a4d328726b2ee0010b6380cb991ad0e3d507;hb=a0f1fca79d2ddfa7ad36b4485039c68b5704fe8d;hp=e894d5781346802cc5250f0fb956a9d853b0017e;hpb=372fb21ea66ced432b109225851a1b80ef0491a3;p=mothur.git diff --git a/lefsecommand.cpp b/lefsecommand.cpp index e894d57..c478a4d 100644 --- a/lefsecommand.cpp +++ b/lefsecommand.cpp @@ -373,17 +373,16 @@ vector LefseCommand::runKruskalWallis(vector& lookup, } } //********************************************************************************************************************** - +//assumes not neccessarily paired vector LefseCommand::runWilcoxon(vector& lookup, DesignMap& designMap, vector bins) { try { + LinearAlgebra linear; vector significantOtuLabels; //if it exists and meets the following requirements run Wilcoxon /* 1. Subclass members all belong to same main class - 2. Number of groups in each subclass is the same - 3. anything else?? - - */ + anything else + */ vector subclasses; map subclass2Class; map subclassCounts; @@ -411,12 +410,6 @@ vector LefseCommand::runWilcoxon(vector& lookup, Desig } if (error) { return significantOtuLabels; } - else { //check counts to make sure subclasses are the same size - set counts; - for (map::iterator it = subclassCounts.begin(); it != subclassCounts.end(); it++) { counts.insert(it->second); } - if (counts.size() > 1) { m->mothurOut("[ERROR]: subclasses must be the same size. Ignoring wilcoxon.\n"); - return significantOtuLabels; } - } int numBins = lookup[0]->getNumBins(); vector comp; @@ -444,7 +437,6 @@ vector LefseCommand::runWilcoxon(vector& lookup, Desig outputNames.push_back(outputFileName); outputTypes["wilcoxon"].push_back(outputFileName); out << "OTULabel\tComparision\tWilcoxon\tPvalue\n"; - LinearAlgebra linear; for (int i = 0; i < numBins; i++) { if (m->control_pressed) { break; } @@ -454,20 +446,26 @@ vector LefseCommand::runWilcoxon(vector& lookup, Desig //for each subclass comparision for (int j = 0; j < numComp; j++) { //fill x and y with this comparisons data - vector x; vector y; + vector x; vector y; + cout << m->currentBinLabels[i] << '\t' << comp[j].getCombo() << " x <- ("; //fill x and y vector xIndexes = subClass2GroupIndex[comp[j].group1]; //indexes in lookup for this subclass - for (int k = 0; k < xIndexes.size(); k++) { x.push_back(lookup[xIndexes[k]]->getAbundance(i)); } + for (int k = 0; k < xIndexes.size(); k++) { x.push_back(lookup[xIndexes[k]]->getAbundance(i)); cout << lookup[xIndexes[k]]->getAbundance(i) << ", "; } + cout << ")\n"; + + cout << m->currentBinLabels[i] << '\t' << comp[j].getCombo() << " y <- ("; vector yIndexes = subClass2GroupIndex[comp[j].group2]; //indexes in lookup for this subclass - for (int k = 0; k < yIndexes.size(); k++) { y.push_back(lookup[yIndexes[k]]->getAbundance(i)); } + for (int k = 0; k < yIndexes.size(); k++) { y.push_back(lookup[yIndexes[k]]->getAbundance(i)); cout << lookup[yIndexes[k]]->getAbundance(i) << ", ";} + cout << ")\n"; double pValue = 0.0; double H = linear.calcWilcoxon(x, y, pValue); //output H and signifigance - out << m->currentBinLabels[i] << '\t' << comp[j].getCombo() << '\t' << H << '\t' << pValue << endl; + if (!isnan(pValue)) { out << m->currentBinLabels[i] << '\t' << comp[j].getCombo() << '\t' << H << '\t' << pValue << endl; } + else { out << m->currentBinLabels[i] << '\t' << comp[j].getCombo() << '\t' << H << '\t' << "NA" << endl; } //set sig - not sure how yet }