From ec5c537e869028c49231dab9a37c00a9edf70723 Mon Sep 17 00:00:00 2001 From: pschloss Date: Sat, 26 Feb 2011 20:12:42 +0000 Subject: [PATCH] some minor changes --- Mothur.xcodeproj/project.pbxproj | 8 ++++---- corraxescommand.cpp | 4 ++-- homovacommand.cpp | 11 ++++++----- nmdscommand.cpp | 18 +++++++++++++----- pcoacommand.cpp | 2 +- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 06755bc..8caeba7 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -1625,7 +1625,7 @@ attributes = { ORGANIZATIONNAME = "Schloss Lab"; }; - buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "mothur" */; + buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Mothur" */; compatibilityVersion = "Xcode 3.1"; developmentRegion = English; hasScannedForEncodings = 1; @@ -2001,7 +2001,7 @@ 1DEB928B08733DD80010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; DEPLOYMENT_LOCATION = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -2032,7 +2032,7 @@ "-lreadline", ); PREBINDING = NO; - SDKROOT = macosx10.5; + SDKROOT = ""; }; name = Release; }; @@ -2048,7 +2048,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "mothur" */ = { + 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Mothur" */ = { isa = XCConfigurationList; buildConfigurations = ( 1DEB928A08733DD80010E9CD /* Debug */, diff --git a/corraxescommand.cpp b/corraxescommand.cpp index f47427d..ae6ee3a 100644 --- a/corraxescommand.cpp +++ b/corraxescommand.cpp @@ -860,7 +860,7 @@ int CorrAxesCommand::getMetadata(){ vector groupNames; ifstream in; - m->openInputFile(axesfile, in); + m->openInputFile(metadatafile, in); string headerLine = m->getline(in); m->gobble(in); istringstream iss (headerLine,istringstream::in); @@ -868,7 +868,7 @@ int CorrAxesCommand::getMetadata(){ //read the first label, because it refers to the groups string columnLabel; iss >> columnLabel; m->gobble(iss); - + //save names of columns you are reading while (!iss.eof()) { iss >> columnLabel; m->gobble(iss); diff --git a/homovacommand.cpp b/homovacommand.cpp index 52456b4..defccd3 100644 --- a/homovacommand.cpp +++ b/homovacommand.cpp @@ -216,8 +216,8 @@ int HomovaCommand::execute(){ m->openOutputFile(HOMOVAFileName, HOMOVAFile); outputNames.push_back(HOMOVAFileName); outputTypes["homova"].push_back(HOMOVAFileName); - HOMOVAFile << "HOMOVA\tBValue\tP-value\tSSwithin_values" << endl; - m->mothurOut("HOMOVA\tBValue\tP-value\tSSwithin_values\n"); + HOMOVAFile << "HOMOVA\tBValue\tP-value\tSSwithin/(Ni-1)_values" << endl; + m->mothurOut("HOMOVA\tBValue\tP-value\tSSwithin/(Ni-1)_values\n"); double fullHOMOVAPValue = runHOMOVA(HOMOVAFile, origGroupSampleMap, experimentwiseAlpha); @@ -231,8 +231,7 @@ int HomovaCommand::execute(){ for(itA=origGroupSampleMap.begin();itA!=origGroupSampleMap.end();itA++){ itB = itA;itB++; - for(itB;itB!=origGroupSampleMap.end();itB++){ - + for(;itB!=origGroupSampleMap.end();itB++){ map > pairwiseGroupSampleMap; pairwiseGroupSampleMap[itA->first] = itA->second; pairwiseGroupSampleMap[itB->first] = itB->second; @@ -296,7 +295,7 @@ double HomovaCommand::runHOMOVA(ofstream& HOMOVAFile, map > HOMOVAFile << it->first; m->mothurOut(it->first); it++; - for(it;it!=groupSampleMap.end();it++){ + for(;it!=groupSampleMap.end();it++){ HOMOVAFile << '-' << it->first; m->mothurOut('-' + it->first); } @@ -379,6 +378,8 @@ double HomovaCommand::calcBValue(map > groupSampleMap, vecto secondTermSum += (numSamplesInGroup - 1) * log(ssWithinVector[index] / (double)(numSamplesInGroup - 1)); inverseOneMinusSum += 1.0 / (double)(numSamplesInGroup - 1); + + ssWithinVector[index] /= (double)(numSamplesInGroup - 1); //this line is only for output purposes to scale SSw by the number of samples in the group index++; } diff --git a/nmdscommand.cpp b/nmdscommand.cpp index 6596859..aa1cd66 100644 --- a/nmdscommand.cpp +++ b/nmdscommand.cpp @@ -195,7 +195,7 @@ int NMDSCommand::execute(){ if (axesfile != "") { axes = readAxes(names); } string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.iters"; - string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "stress.nmds"; + string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.stress"; outputNames.push_back(outputFileName); outputTypes["iters"].push_back(outputFileName); outputNames.push_back(stressFileName); outputTypes["stress"].push_back(stressFileName); @@ -208,10 +208,12 @@ int NMDSCommand::execute(){ out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); - out2 << "Dimension\tIter\tStress\tCorr" << endl; + out2 << "Dimension\tIter\tStress\tRsq" << endl; double bestStress = 10000000; + double bestR2 = 10000000; vector< vector > bestConfig; + int bestDim = 0; for (int i = mindim; i <= maxdim; i++) { m->mothurOut("Processing Dimension: " + toString(i)); m->mothurOutEndLine(); @@ -235,21 +237,23 @@ int NMDSCommand::execute(){ if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } //calc correlation between original distances and euclidean distances from this config - double corr = linearCalc.calcPearson(newEuclid, matrix); - corr *= corr; + double rsquared = linearCalc.calcPearson(newEuclid, matrix); + rsquared *= rsquared; if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } //output results out << "Config" << (j+1) << '\t'; for (int k = 0; k < i; k++) { out << "axis" << (k+1) << '\t'; } out << endl; - out2 << i << '\t' << (j+1) << '\t' << stress << '\t' << corr << endl; + out2 << i << '\t' << (j+1) << '\t' << stress << '\t' << rsquared << endl; output(endConfig, names, out); //save best if (stress < bestStress) { + bestDim = i; bestStress = stress; + bestR2 = rsquared; bestConfig = endConfig; } @@ -263,6 +267,10 @@ int NMDSCommand::execute(){ string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.axes"; outputNames.push_back(BestFileName); outputTypes["nmds"].push_back(BestFileName); + m->mothurOut("\nNumber of dimensions:\t" + toString(bestDim) + "\n"); + m->mothurOut("Lowest stress :\t" + toString(bestStress) + "\n"); + m->mothurOut("R-squared for configuration:\t" + toString(bestR2) + "\n"); + ofstream outBest; m->openOutputFile(BestFileName, outBest); outBest.setf(ios::fixed, ios::floatfield); diff --git a/pcoacommand.cpp b/pcoacommand.cpp index d8efb25..4be5ffb 100644 --- a/pcoacommand.cpp +++ b/pcoacommand.cpp @@ -197,7 +197,7 @@ int PCOACommand::execute(){ double corr = linearCalc.calcPearson(EuclidDists, D); //G is the pcoa file, D is the users distance matrix - m->mothurOut("Pearson's coefficient using " + toString(i) + " axis: " + toString(corr)); m->mothurOutEndLine(); + m->mothurOut("Rsq " + toString(i) + " axis: " + toString(corr * corr)); m->mothurOutEndLine(); if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } } -- 2.39.2