delete newCt;
delete subSampleTree;
- if((thisIter+1) % 100 == 0){ m->mothurOut(toString(thisIter+1)); m->mothurOutEndLine(); }
+ if((thisIter+1) % 100 == 0){ m->mothurOutJustToScreen(toString(thisIter+1)+"\n"); }
}
if (subsample) { m->mothurOut("It took " + toString(time(NULL) - startSubsample) + " secs to run the subsampling."); m->mothurOutEndLine(); }
try {
//we need to find the average distance and standard deviation for each groups distance
//finds sum
- vector<double> averages; //averages.resize(numComp, 0.0);
- for (int i = 0; i < numComp; i++) { averages.push_back(0.0); }
-
- if (m->debug) { m->mothurOut("[DEBUG]: numcomparisons = " + toString(numComp) + ", subsampleIters = " + toString(subsampleIters) + "\n"); }
-
- for (int thisIter = 0; thisIter < subsampleIters; thisIter++) {
- for (int i = 0; i < dists[thisIter].size(); i++) {
- averages[i] += dists[thisIter][i];
- }
- }
-
- if (m->debug) { m->mothurOut("[DEBUG]: numcomparisons = " + toString(numComp) + ", subsampleIters = " + toString(subsampleIters) + "\n"); }
-
- //finds average.
- for (int i = 0; i < averages.size(); i++) {
- averages[i] /= (float) subsampleIters;
- if (m->debug) { m->mothurOut("[DEBUG]: i = " + toString(i) + ", averages[i] = " + toString(averages[i]) + "\n"); }
- }
+ vector<double> averages = m->getAverages(dists);
//find standard deviation
- vector<double> stdDev; //stdDev.resize(numComp, 0.0);
- for (int i = 0; i < numComp; i++) { stdDev.push_back(0.0); }
-
- for (int thisIter = 0; thisIter < subsampleIters; thisIter++) { //compute the difference of each dist from the mean, and square the result of each
- for (int j = 0; j < dists[thisIter].size(); j++) {
- stdDev[j] += ((dists[thisIter][j] - averages[j]) * (dists[thisIter][j] - averages[j]));
- }
- }
- for (int i = 0; i < stdDev.size(); i++) {
- stdDev[i] /= (float) subsampleIters;
- stdDev[i] = sqrt(stdDev[i]);
- if (m->debug) { m->mothurOut("[DEBUG]: i = " + toString(i) + ", stdDev[i] = " + toString(stdDev[i]) + "\n"); }
- }
+ vector<double> stdDev = m->getStandardDeviation(dists, averages);
//make matrix with scores in it
vector< vector<double> > avedists; //avedists.resize(m->getNumGroups());
float rcumul = 1.0000;
//this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
- for (map<float,float>::iterator it = validScores.begin(); it != validScores.end(); it++) {
+ for (map<float,float>::iterator it = validScores.begin(); it != validScores.end(); it++) {
//make rscoreFreq map and rCumul
map<float,float>::iterator it2 = rscoreFreq[a].find(it->first);
rCumul[a][it->first] = rcumul;