]> git.donarmstrong.com Git - mothur.git/commitdiff
Merge remote-tracking branch 'origin/master'
authorSarah Westcott <mothur.westcott@gmail.com>
Thu, 13 Dec 2012 21:36:13 +0000 (16:36 -0500)
committerSarah Westcott <mothur.westcott@gmail.com>
Thu, 13 Dec 2012 21:36:13 +0000 (16:36 -0500)
Mothur.xcodeproj/project.pbxproj
cooccurrencecommand.cpp
forest.cpp
regularizeddecisiontree.cpp [new file with mode: 0644]
regularizeddecisiontree.h [new file with mode: 0644]
regularizedrandomforest.cpp [new file with mode: 0644]
regularizedrandomforest.h [new file with mode: 0644]
trialSwap2.cpp

index 064019cb0e6b56f19eb6a3d1f2280f8505c8c33b..b689e036afa54c8fdd767cdd8673c45697378f30 100644 (file)
@@ -10,6 +10,8 @@
                219C1DE01552C4BD004209F9 /* newcommandtemplate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DDF1552C4BD004209F9 /* newcommandtemplate.cpp */; };
                219C1DE41559BCCF004209F9 /* getcoremicrobiomecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DE31559BCCD004209F9 /* getcoremicrobiomecommand.cpp */; };
                7E6BE10A12F710D8007ADDBE /* refchimeratest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */; };
+               834D9D581656D7C400E7FAB9 /* regularizedrandomforest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834D9D561656D7C400E7FAB9 /* regularizedrandomforest.cpp */; };
+               834D9D5C1656DEC800E7FAB9 /* regularizeddecisiontree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834D9D5A1656DEC700E7FAB9 /* regularizeddecisiontree.cpp */; };
                83F25B0C163B031200ABE73D /* forest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83F25B0A163B031200ABE73D /* forest.cpp */; };
                8DD76FB00486AB0100D96B5E /* mothur.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A0FF2C0290799A04C91782 /* mothur.1 */; };
                A70056E6156A93D000924A2D /* getotulabelscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70056E5156A93D000924A2D /* getotulabelscommand.cpp */; };
                7E6BE10812F710D8007ADDBE /* refchimeratest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = refchimeratest.h; sourceTree = "<group>"; };
                7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = refchimeratest.cpp; sourceTree = "<group>"; };
                7E78911B135F3E8600E725D2 /* eachgapdistignorens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdistignorens.h; sourceTree = "<group>"; };
+               834D9D561656D7C400E7FAB9 /* regularizedrandomforest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = regularizedrandomforest.cpp; sourceTree = "<group>"; };
+               834D9D571656D7C400E7FAB9 /* regularizedrandomforest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regularizedrandomforest.h; sourceTree = "<group>"; };
+               834D9D5A1656DEC700E7FAB9 /* regularizeddecisiontree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = regularizeddecisiontree.cpp; sourceTree = "<group>"; };
+               834D9D5B1656DEC700E7FAB9 /* regularizeddecisiontree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regularizeddecisiontree.h; sourceTree = "<group>"; };
                83F25B0A163B031200ABE73D /* forest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = forest.cpp; sourceTree = "<group>"; };
                83F25B0B163B031200ABE73D /* forest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = forest.h; sourceTree = "<group>"; };
                8DD76FB20486AB0100D96B5E /* mothur */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mothur; sourceTree = BUILT_PRODUCTS_DIR; };
                                A77E193A161B289600DB1A2A /* rftreenode.cpp */,
                                83F25B0A163B031200ABE73D /* forest.cpp */,
                                83F25B0B163B031200ABE73D /* forest.h */,
+                               834D9D561656D7C400E7FAB9 /* regularizedrandomforest.cpp */,
+                               834D9D571656D7C400E7FAB9 /* regularizedrandomforest.h */,
+                               834D9D5A1656DEC700E7FAB9 /* regularizeddecisiontree.cpp */,
+                               834D9D5B1656DEC700E7FAB9 /* regularizeddecisiontree.h */,
                        );
                        name = randomforest;
                        sourceTree = "<group>";
                                A721AB72161C572A009860A1 /* kmertree.cpp in Sources */,
                                A721AB77161C573B009860A1 /* taxonomynode.cpp in Sources */,
                                83F25B0C163B031200ABE73D /* forest.cpp in Sources */,
+                               834D9D581656D7C400E7FAB9 /* regularizedrandomforest.cpp in Sources */,
+                               834D9D5C1656DEC800E7FAB9 /* regularizeddecisiontree.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 78be06f28bd4e6d9b476f9bc92a1fcbb4c9d8365..48fba8c9727b4df62b7a37cbb629a55c7c082d74 100644 (file)
@@ -197,7 +197,7 @@ int CooccurrenceCommand::execute(){
         m->openOutputFile(outputFileName, out);
         outputNames.push_back(outputFileName);  outputTypes["summary"].push_back(outputFileName);
         out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-        out << "metric\tlabel\tScore\tzScore\tstandardDeviation\n";
+        out << "metric\tlabel\tScore\tzScore\tstandardDeviation\tnp_Pvalue\n";
 
                //as long as you are not at the end of the file or done wih the lines you want
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
@@ -566,7 +566,8 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
         
         m->mothurOut("zscore: " + toString(zscore)); m->mothurOutEndLine();
         m->mothurOut("standard deviation: " + toString(sd)); m->mothurOutEndLine();
-        out << metric << '\t' << thisLookUp[0]->getLabel() << '\t' << nullMean << '\t' << zscore << '\t' << sd << endl;
+        m->mothurOut("non-parametric p-value: " + toString(pvalue)); m->mothurOutEndLine();
+        out << metric << '\t' << thisLookUp[0]->getLabel() << '\t' << nullMean << '\t' << zscore << '\t' << sd << '\t' << pvalue << endl;
         
         return 0;
     }
index 58c7f7e7d4d780b54d4c757e4653a368a60f6a74..179ecef19d26de2a61f68776445dfdfc72132f07 100644 (file)
@@ -16,10 +16,10 @@ Forest::Forest(const std::vector < std::vector<int> > dataSet,
 numDecisionTrees(numDecisionTrees),
 numSamples((int)dataSet.size()),
 numFeatures((int)(dataSet[0].size() - 1)),
-globalDiscardedFeatureIndices(getGlobalDiscardedFeatureIndices()),
 globalVariableImportanceList(numFeatures, 0),
 treeSplitCriterion(treeSplitCriterion) {
     m = MothurOut::getInstance();
+    globalDiscardedFeatureIndices = getGlobalDiscardedFeatureIndices();
     // TODO: double check if the implemenatation of 'globalOutOfBagEstimates' is correct
 }
 
diff --git a/regularizeddecisiontree.cpp b/regularizeddecisiontree.cpp
new file mode 100644 (file)
index 0000000..e95848a
--- /dev/null
@@ -0,0 +1,9 @@
+//
+//  regularizeddecisiontree.cpp
+//  Mothur
+//
+//  Created by Kathryn Iverson on 11/16/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#include "regularizeddecisiontree.h"
diff --git a/regularizeddecisiontree.h b/regularizeddecisiontree.h
new file mode 100644 (file)
index 0000000..47bb4c4
--- /dev/null
@@ -0,0 +1,16 @@
+//
+//  regularizeddecisiontree.h
+//  Mothur
+//
+//  Created by Kathryn Iverson on 11/16/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#ifndef __Mothur__regularizeddecisiontree__
+#define __Mothur__regularizeddecisiontree__
+
+#include <iostream>
+#include "rftreenode.hpp"
+#include "abstractdecisiontree.hpp"
+
+#endif /* defined(__Mothur__regularizeddecisiontree__) */
diff --git a/regularizedrandomforest.cpp b/regularizedrandomforest.cpp
new file mode 100644 (file)
index 0000000..55a8dc4
--- /dev/null
@@ -0,0 +1,57 @@
+//
+//  regularizedrandomforest.cpp
+//  Mothur
+//
+//  Created by Kathryn Iverson on 11/16/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#include "regularizedrandomforest.h"
+
+RegularizedRandomForest::RegularizedRandomForest(const vector <vector<int> > dataSet,const int numDecisionTrees,
+                           const string treeSplitCriterion = "informationGain") : Forest(dataSet, numDecisionTrees, treeSplitCriterion) {
+    m = MothurOut::getInstance();
+}
+
+int RegularizedRandomForest::calcForrestErrorRate() {
+    //
+    try {
+        return 0;
+    }
+    catch(exception& e) {
+               m->errorOut(e, "RegularizedRandomForest", "calcForrestErrorRate");
+               exit(1);
+       }
+}
+
+int RegularizedRandomForest::calcForrestVariableImportance(string filename) {
+    //
+    try {
+        return 0;
+    }
+    catch(exception& e) {
+               m->errorOut(e, "RegularizedRandomForest", "calcForrestVariableImportance");
+               exit(1);
+       }
+}
+
+int RegularizedRandomForest::populateDecisionTrees() {
+    //
+    try {
+        return 0;
+    }
+    catch(exception& e) {
+               m->errorOut(e, "RegularizedRandomForest", "populateDecisionTrees");
+               exit(1);
+       }
+}
+
+int RegularizedRandomForest::updateGlobalOutOfBagEstimates(DecisionTree *decisionTree) {
+    try {
+        return 0;
+    }
+    catch(exception& e) {
+               m->errorOut(e, "RegularizedRandomForest", "updateGlobalOutOfBagEstimates");
+               exit(1);
+       }
+}
\ No newline at end of file
diff --git a/regularizedrandomforest.h b/regularizedrandomforest.h
new file mode 100644 (file)
index 0000000..94bd624
--- /dev/null
@@ -0,0 +1,30 @@
+//
+//  regularizedrandomforest.h
+//  Mothur
+//
+//  Created by Kathryn Iverson on 11/16/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#ifndef __Mothur__regularizedrandomforest__
+#define __Mothur__regularizedrandomforest__
+
+#include "forest.h"
+#include "decisiontree.hpp"
+
+class RegularizedRandomForest: public Forest {
+public:
+    //
+    RegularizedRandomForest(const vector <vector<int> > dataSet,const int numDecisionTrees, const string);
+    
+    int calcForrestErrorRate();
+    int calcForrestVariableImportance(string);
+    int populateDecisionTrees();
+    int updateGlobalOutOfBagEstimates(DecisionTree* decisionTree);
+    
+private:
+    //
+    MothurOut* m;
+};
+
+#endif /* defined(__Mothur__regularizedrandomforest__) */
index 71c3027db2c8bbe97265cb40af839c6a81a17b33..4cff4260ad5754fb4c0347747d20d0439df3f5d6 100644 (file)
@@ -50,9 +50,10 @@ double TrialSwap2::calc_c_score (vector<vector<int> > &co_matrix, vector<int> ro
             }
         }
         
-        cscore = cscore/(double)(nrows*(nrows-1)/2);
+        //cscore = cscore/(double)(nrows*(nrows-1)/2);  //not normalized
         //cout << "normalized c score: " << normcscore/nonzeros << endl;
-        
+        cscore = normcscore/(double)nonzeros;
+
         return cscore;
     }
     catch(exception& e) {