]> git.donarmstrong.com Git - mothur.git/blobdiff - getmetacommunitycommand.cpp
fixed bug in make.biom with picrust that didn’t allow for unclassified OTUs. fixed...
[mothur.git] / getmetacommunitycommand.cpp
index b3160749e9031072ceafdea29b92a33a2909cff6..047f176fa6be9b1c11108f0e007391dae33040c7 100644 (file)
@@ -18,7 +18,7 @@ vector<string> GetMetaCommunityCommand::setParameters(){
         CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","outputType",false,true); parameters.push_back(pshared);
         CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
-        CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson-jsd", "jsd", "", "", "","",false,false,true); parameters.push_back(pcalc);
+        CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson-jsd-rjsd", "rjsd", "", "", "","",false,false,true); parameters.push_back(pcalc);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
         CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
         CommandParameter pminpartitions("minpartitions", "Number", "", "5", "", "", "","",false,false,true); parameters.push_back(pminpartitions);
@@ -46,9 +46,9 @@ string GetMetaCommunityCommand::getHelpString(){
         helpString += "The label parameter is used to analyze specific labels in your input. labels are separated by dashes.\n";
                helpString += "The groups parameter allows you to specify which of the groups in your shared file you would like analyzed.  Group names are separated by dashes.\n";
         helpString += "The method parameter allows to select the method you would like to use.  Options are dmm, kmeans and pam. Default=dmm.\n";
-        helpString += "The calc parameter allows to select the calculator you would like to use to calculate the distance matrix used by the pam method. By default the jsd calculator is used.\n";
-        helpString += "The iters parameter allows you to choose the number of times you would like to run the subsample while calculating the distance matirx for the pam method.\n";
-        helpString += "The subsample parameter allows you to enter the size pergroup of the sample or you can set subsample=T and mothur will use the size of your smallest group while calculating the distance matrix for the pam method.\n";
+        helpString += "The calc parameter allows to select the calculator you would like to use to calculate the distance matrix used by the pam and kmeans method. By default the rjsd calculator is used.\n";
+        helpString += "The iters parameter allows you to choose the number of times you would like to run the subsample while calculating the distance matrix for the pam and kmeans method.\n";
+        helpString += "The subsample parameter allows you to enter the size pergroup of the sample or you can set subsample=T and mothur will use the size of your smallest group while calculating the distance matrix for the pam and kmeans methods.\n";
                helpString += "The minpartitions parameter is used to .... Default=5.\n";
         helpString += "The maxpartitions parameter is used to .... Default=10.\n";
         helpString += "The optimizegap parameter is used to .... Default=3.\n";
@@ -66,12 +66,12 @@ string GetMetaCommunityCommand::getOutputPattern(string type) {
     try {
         string pattern = "";
         
-        if (type == "fit")              {  pattern = "[filename],[distance],mix.fit"; }
-        else if (type == "relabund")    {  pattern = "[filename],[distance],[tag],mix.relabund"; }
-        else if (type == "design")      {  pattern = "[filename],[distance],mix.design"; }
-        else if (type == "matrix")      {  pattern = "[filename],[distance],[tag],mix.posterior"; }
-        else if (type == "parameters")  {  pattern = "[filename],[distance],mix.parameters"; }
-        else if (type == "summary")  {  pattern = "[filename],[distance],mix.summary"; }
+        if (type == "fit")              {  pattern = "[filename],[distance],[method],mix.fit"; }
+        else if (type == "relabund")    {  pattern = "[filename],[distance],[method],[tag],mix.relabund"; }
+        else if (type == "design")      {  pattern = "[filename],[distance],[method],mix.design"; }
+        else if (type == "matrix")      {  pattern = "[filename],[distance],[method],[tag],mix.posterior"; }
+        else if (type == "parameters")  {  pattern = "[filename],[distance],[method],mix.parameters"; }
+        else if (type == "summary")  {  pattern = "[filename],[distance],[method],mix.summary"; }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         
         return pattern;
@@ -190,9 +190,9 @@ GetMetaCommunityCommand::GetMetaCommunityCommand(string option)  {
                        else { m->mothurOut("[ERROR]: " + method + " is not a valid method.  Valid algorithms are dmm, kmeans and pam."); m->mothurOutEndLine(); abort = true; }
             
             calc = validParameter.validFile(parameters, "calc", false);
-                       if (calc == "not found") { calc = "jsd";  }
+                       if (calc == "not found") { calc = "rjsd";  }
                        else {
-                if (calc == "default")  {  calc = "jsd";  }
+                if (calc == "default")  {  calc = "rjsd";  }
                        }
                        m->splitAtDash(calc, Estimators);
                        if (m->inUsersGroups("citation", Estimators)) {
@@ -366,6 +366,7 @@ int GetMetaCommunityCommand::createProcesses(vector<SharedRAbundVector*>& thislo
         map<string, string> variables;
         variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
         variables["[distance]"] = thislookup[0]->getLabel();
+        variables["[method]"] = method;
                string outputFileName = getOutputFileName("fit", variables);
         outputNames.push_back(outputFileName); outputTypes["fit"].push_back(outputFileName);
                 
@@ -611,6 +612,12 @@ int GetMetaCommunityCommand::processDriver(vector<SharedRAbundVector*>& thislook
                 finder = new qFinderDMM(sharedMatrix, numPartitions);
             }
             
+            string relabund = relabunds[i];
+            string matrixName = matrix[i];
+            outputNames.push_back(matrixName); outputTypes["matrix"].push_back(matrixName);
+            
+            finder->printZMatrix(matrixName, thisGroups);
+            
             double chi; vector<double> silhouettes;
             if (method == "dmm") {
                 double laplace = finder->getLaplace();
@@ -627,11 +634,6 @@ int GetMetaCommunityCommand::processDriver(vector<SharedRAbundVector*>& thislook
                     minSilhouettes = silhouettes;
                 }
             }
-            string relabund = relabunds[i];
-            string matrixName = matrix[i];
-            outputNames.push_back(matrixName); outputTypes["matrix"].push_back(matrixName);
-            
-            finder->printZMatrix(matrixName, thisGroups);
             
             if (method == "dmm") {
                 finder->printFitData(cout, minLaplace);
@@ -754,6 +756,7 @@ int GetMetaCommunityCommand::generateSummaryFile(int numPartitions, map<string,s
         map<string, string> variables;
         variables["[filename]"] = v["[filename]"];
         variables["[distance]"] = v["[distance]"];
+        variables["[method]"] = method;
         variables["[tag]"] = "1";
         string reference = getOutputFileName("relabund", variables);
         m->openInputFile(reference, referenceFile); //((fileRoot + label + ".1mix.relabund").c_str());
@@ -961,6 +964,8 @@ vector<vector<double> > GetMetaCommunityCommand::generateDistanceMatrix(vector<S
                 matrixCalculator = new MemPearson();
             }else if (Estimators[i] == "jsd") {
                 matrixCalculator = new JSD();
+            }else if (Estimators[i] == "rjsd") {
+                matrixCalculator = new RJSD();
             }else {
                 m->mothurOut("[ERROR]: " + Estimators[i] + " is not a valid calculator, please correct.\n"); m->control_pressed = true; return results;
             }