]> git.donarmstrong.com Git - mothur.git/blob - lefsecommand.h
working on pam
[mothur.git] / lefsecommand.h
1 //
2 //  lefsecommand.h
3 //  Mothur
4 //
5 //  Created by SarahsWork on 6/12/13.
6 //  Copyright (c) 2013 Schloss Lab. All rights reserved.
7 //
8
9 #ifndef __Mothur__lefsecommand__
10 #define __Mothur__lefsecommand__
11
12 #include "command.hpp"
13
14 /* 
15  Columns = groups, rows are OTUs, class = design
16  
17  From http://huttenhower.sph.harvard.edu/galaxy/root?tool_id=lefse_upload
18  Input data consist of a collection of m samples (columns) each made up of n numerical features (rows, typically normalized per-sample, red representing high values and green low). These samples are labeled with a class (taking two or more possible values) that represents the main biological hypothesis under investigation; they may also have one or more subclass labels reflecting within-class groupings.
19  
20  Step 1: the Kruskall-Wallis test analyzes all features, testing whether the values in different classes are differentially distributed. Features violating the null hypothesis are further analyzed in Step 2.
21  Step 2: the pairwise Wilcoxon test checks whether all pairwise comparisons between subclasses within different classes significantly agree with the class level trend.
22  Step 3: the resulting subset of vectors is used to build a Linear Discriminant Analysis model from which the relative difference among classes is used to rank the features. The final output thus consists of a list of features that are discriminative with respect to the classes, consistent with the subclass grouping within classes, and ranked according to the effect size with which they differentiate classes.
23 */
24
25
26 #include "command.hpp"
27 #include "inputdata.h"
28 #include "designmap.h"
29
30 /**************************************************************************************************/
31
32 class LefseCommand : public Command {
33 public:
34     LefseCommand(string);
35     LefseCommand();
36     ~LefseCommand(){}
37     
38     vector<string> setParameters();
39     string getCommandName()                     { return "lefse";                       }
40     string getCommandCategory()         { return "OTU-Based Approaches";                }
41     
42     string getOutputPattern(string);
43         string getHelpString();
44     string getCitation() { return "Segata, N., J. Izard, L. Waldron, D. Gevers, L. Miropolsky, W. S. Garrett, and C. Huttenhower. 2011. Metagenomic biomarker discovery and explanation. Genome Biol 12:R60, http://www.mothur.org/wiki/Lefse"; }
45     string getDescription()             { return "brief description"; }
46     
47     int execute();
48     void help() { m->mothurOut(getHelpString()); }
49     
50 private:
51     bool abort, allLines, wilc, wilcsamename, curv, subject, normMillion;
52     string outputDir, sharedfile, designfile, mclass, subclass, rankTec, multiClassStrat;
53     vector<string> outputNames;
54     set<string> labels;
55     double anovaAlpha, wilcoxonAlpha, fBoots, ldaThreshold;
56     int nlogs, iters, strict, minC;
57     
58     int process(vector<SharedRAbundFloatVector*>&, DesignMap&);
59     int normalize(vector<SharedRAbundFloatVector*>&);
60     map<int, double> runKruskalWallis(vector<SharedRAbundFloatVector*>&, DesignMap&);
61     map<int, double> runWilcoxon(vector<SharedRAbundFloatVector*>&, DesignMap&, map<int, double>, map<string, set<string> >& class2SubClasses, map<string, vector<int> >& subClass2GroupIndex, map<string, string>);
62     bool testOTUWilcoxon(map<string, set<string> >& class2SubClasses, vector<float> abunds, map<string, vector<int> >& subClass2GroupIndex, map<string, string>);
63     map<int, double> testLDA(vector<SharedRAbundFloatVector*>&, map<int, double>, map<string, vector<int> >& class2GroupIndex, map<string, vector<int> >&);
64     bool contastWithinClassesOrFewPerClass(vector< vector<double> >&, vector<int> rands, int minCl, map<string, vector<int> > class2GroupIndex,  map<int, string> indexToClass);
65     vector< vector<double> > lda(vector< vector<double> >& adjustedLookup, vector<int> rand_s, map<int, string>& indexToClass, vector<string>);
66     vector< vector<double> > getMeans(vector<SharedRAbundFloatVector*>& lookup, map<string, vector<int> >& class2GroupIndex);
67     int printResults(vector< vector<double> >, map<int, double>, map<int, double>, string, vector<string>);
68     
69     //for testing
70     bool printToCoutForRTesting(vector< vector<double> >& adjustedLookup, vector<int> rand_s, map<string, vector<int> >& class2GroupIndex, map<int, double> bins, map<string, vector<int> >&, vector<string>);
71     int makeShared(int);
72 };
73
74 /**************************************************************************************************/
75
76
77
78
79 #endif /* defined(__Mothur__lefsecommand__) */