Permalink
Browse files

Adds numOtus to opti output

  • Loading branch information...
1 parent bab404d commit 303a2d763cc5190d327050e1257cdae081e35426 @mothur-westcott mothur-westcott committed Sep 29, 2016
Showing with 30 additions and 12 deletions.
  1. +8 −10 source/commands/clustercommand.cpp
  2. +21 −2 source/opticluster.cpp
  3. +1 −0 source/opticluster.h
@@ -886,18 +886,17 @@ int ClusterCommand::runOptiCluster(){
cluster.initialize(listVectorMetric, true, initialize);
- ListVector* list = cluster.getList();
+ long long numBins = cluster.getNumBins();
m->mothurOut("\n\niter\ttime\tlabel\tnum_otus\tcutoff\ttp\ttn\tfp\tfn\tsensitivity\tspecificity\tppv\tnpv\tfdr\taccuracy\tmcc\tf1score\n");
outStep << "iter\ttime\tlabel\tnum_otus\tcutoff\ttp\ttn\tfp\tfn\tsensitivity\tspecificity\tppv\tnpv\tfdr\taccuracy\tmcc\tf1score\n";
long long tp, tn, fp, fn;
vector<double> results = cluster.getStats(tp, tn, fp, fn);
- m->mothurOut("0\t0\t" + toString(cutoff) + "\t" + toString(list->getNumBins()) + "\t"+ toString(cutoff) + "\t" + toString(tp) + "\t" + toString(tn) + "\t" + toString(fp) + "\t" + toString(fn) + "\t");
- outStep << "0\t0\t" + toString(cutoff) + "\t" + toString(list->getNumBins()) + "\t" + toString(cutoff) + "\t" << tp << '\t' << tn << '\t' << fp << '\t' << fn << '\t';
+ m->mothurOut("0\t0\t" + toString(cutoff) + "\t" + toString(numBins) + "\t"+ toString(cutoff) + "\t" + toString(tp) + "\t" + toString(tn) + "\t" + toString(fp) + "\t" + toString(fn) + "\t");
+ outStep << "0\t0\t" + toString(cutoff) + "\t" + toString(numBins) + "\t" + toString(cutoff) + "\t" << tp << '\t' << tn << '\t' << fp << '\t' << fn << '\t';
for (int i = 0; i < results.size(); i++) { m->mothurOut(toString(results[i]) + "\t"); outStep << results[i] << "\t"; }
m->mothurOutEndLine();
outStep << endl;
- delete list;
-
+
while ((delta > stableMetric) && (iters < maxIters)) {
int start = time(NULL);
@@ -911,18 +910,17 @@ int ClusterCommand::runOptiCluster(){
iters++;
results = cluster.getStats(tp, tn, fp, fn);
- list = cluster.getList();
+ numBins = cluster.getNumBins();
- m->mothurOut(toString(iters) + "\t" + toString(time(NULL) - start) + "\t" + toString(cutoff) + "\t" + toString(list->getNumBins()) + "\t" + toString(cutoff) + "\t"+ toString(tp) + "\t" + toString(tn) + "\t" + toString(fp) + "\t" + toString(fn) + "\t");
- outStep << (toString(iters) + "\t" + toString(time(NULL) - start) + "\t" + toString(cutoff) + "\t" + toString(list->getNumBins()) + "\t" + toString(cutoff) + "\t") << tp << '\t' << tn << '\t' << fp << '\t' << fn << '\t';
+ m->mothurOut(toString(iters) + "\t" + toString(time(NULL) - start) + "\t" + toString(cutoff) + "\t" + toString(numBins) + "\t" + toString(cutoff) + "\t"+ toString(tp) + "\t" + toString(tn) + "\t" + toString(fp) + "\t" + toString(fn) + "\t");
+ outStep << (toString(iters) + "\t" + toString(time(NULL) - start) + "\t" + toString(cutoff) + "\t" + toString(numBins) + "\t" + toString(cutoff) + "\t") << tp << '\t' << tn << '\t' << fp << '\t' << fn << '\t';
for (int i = 0; i < results.size(); i++) { m->mothurOut(toString(results[i]) + "\t"); outStep << results[i] << "\t"; }
m->mothurOutEndLine();
outStep << endl;
- delete list;
}
m->mothurOutEndLine(); m->mothurOutEndLine();
- list = cluster.getList();
+ ListVector* list = cluster.getList();
list->setLabel(toString(cutoff));
if (!m->printedListHeaders) { m->listBinLabelsInFile.clear(); list->printHeaders(listFile); }
if(countfile != "") { list->print(listFile, counts); }
View
@@ -562,8 +562,8 @@ double OptiCluster::calcFDR( long long tp, long long tn, long long fp, long l
/***********************************************************************/
vector<double> OptiCluster::getStats( long long& tp, long long& tn, long long& fp, long long& fn) {
try {
- long long singletn = matrix->getNumSingletons() + numSingletons;
- long long tempnumSeqs = numSeqs + singletn;
+ long long singletn = matrix->getNumSingletons() + numSingletons;
+ long long tempnumSeqs = numSeqs + singletn;
tp = truePositives;
fp = falsePositives;
@@ -640,6 +640,25 @@ ListVector* OptiCluster::getList() {
}
}
/***********************************************************************/
+long long OptiCluster::getNumBins() {
+ try {
+ long long singletn = matrix->getNumSingletons();
+
+ for (int i = 0; i < bins.size(); i++) {
+ if (bins[i].size() != 0) {
+ singletn++;
+ }
+ }
+
+ return singletn;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "OptiCluster", "getNumBins");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
int OptiCluster::findInsert() {
try {
View
@@ -29,6 +29,7 @@ class OptiCluster : public Cluster {
~OptiCluster() {}
bool updateDistance(PDistCell& colCell, PDistCell& rowCell) { return false; } //inheritance compliant
string getTag() { string tag = "opti_" + metric; return tag; }
+ long long getNumBins();
int initialize(double&, bool, string); //randomize and place in "best" OTUs
bool update(double&); //returns whether list changed and MCC
vector<double> getStats( long long&, long long&, long long&, long long&);

0 comments on commit 303a2d7

Please sign in to comment.