//allow user to run help
if(option == "help") { help(); abort = true; calledHelp = true; }
+ else if(option == "citation") { citation(); abort = true; calledHelp = true;}
else {
vector<string> myArray = setParameters();
sharedfile = validParameter.validFile(parameters, "shared", true);
if (sharedfile == "not open") { abort = true; }
else if (sharedfile == "not found") { sharedfile = ""; }
- else { inputFileName = sharedfile; }
+ else { inputFileName = sharedfile; m->setSharedFile(sharedfile); }
relabundfile = validParameter.validFile(parameters, "relabund", true);
if (relabundfile == "not open") { abort = true; }
else if (relabundfile == "not found") { relabundfile = ""; }
- else { inputFileName = relabundfile; }
+ else { inputFileName = relabundfile; m->setRelAbundFile(relabundfile); }
metadatafile = validParameter.validFile(parameters, "metadata", true);
if (metadatafile == "not open") { abort = true; }
pickedGroups = true;
m->splitAtDash(groups, Groups);
}
- m->Groups = Groups;
+ m->setGroups(Groups);
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(inputFileName); }
}
string temp;
temp = validParameter.validFile(parameters, "numaxes", false); if (temp == "not found"){ temp = "3"; }
- convert(temp, numaxes);
+ m->mothurConvert(temp, numaxes);
method = validParameter.validFile(parameters, "method", false); if (method == "not found"){ method = "pearson"; }
if (metadatafile == "") { out << "OTU"; }
else { out << "Feature"; }
- for (int i = 0; i < numaxes; i++) { out << '\t' << "axis" << (i+1); }
+ for (int i = 0; i < numaxes; i++) { out << '\t' << "axis" << (i+1) << "\tp-value"; }
out << "\tlength" << endl;
if (method == "pearson") { calcPearson(axes, out); }
double denom = (sqrt(denomTerm1) * sqrt(denomTerm2));
r = numerator / denom;
+
+ if (isnan(r) || isinf(r)) { r = 0.0; }
+
rValues[k] = r;
out << '\t' << r;
+
+ //signifigance calc - http://faculty.vassar.edu/lowry/ch4apx.html
+ double temp = (1- (r*r)) / (double) (lookupFloat.size()-2);
+ temp = sqrt(temp);
+ double sig = r / temp;
+ if (isnan(sig) || isinf(sig)) { sig = 0.0; }
+
+ out << '\t' << sig;
}
double sum = 0;
p = (SX2 + SY2 - di) / (2.0 * sqrt((SX2*SY2)));
+ if (isnan(p) || isinf(p)) { p = 0.0; }
+
out << '\t' << p;
pValues[j] = p;
+
+ //signifigance calc - http://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient
+ double temp = (lookupFloat.size()-2) / (double) (1- (p*p));
+ temp = sqrt(temp);
+ double sig = p*temp;
+ if (isnan(sig) || isinf(sig)) { sig = 0.0; }
+
+ out << '\t' << sig;
+
}
double sum = 0;
}
double p = (numCoor - numDisCoor) / (float) count;
-
+ if (isnan(p) || isinf(p)) { p = 0.0; }
+
out << '\t' << p;
pValues[j] = p;
-
+
+ //calc signif - zA - http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient#Significance_tests
+ double numer = 3.0 * (numCoor - numDisCoor);
+ int n = scores[j].size();
+ double denom = n * (n-1) * (2*n + 5) / (double) 2.0;
+ denom = sqrt(denom);
+ double sig = numer / denom;
+
+ if (isnan(sig) || isinf(sig)) { sig = 0.0; }
+
+ out << '\t' << sig;
}
double sum = 0;
}
//for each bin
+ vector<string> newBinLabels;
+ string snumBins = toString(thislookup[0]->getNumBins());
for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } return 0; }
for (int j = 0; j < thislookup.size(); j++) {
newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
}
+
+ //if there is a bin label use it otherwise make one
+ string binLabel = "Otu";
+ string sbinNumber = toString(i+1);
+ if (sbinNumber.length() < snumBins.length()) {
+ int diff = snumBins.length() - sbinNumber.length();
+ for (int h = 0; h < diff; h++) { binLabel += "0"; }
+ }
+ binLabel += sbinNumber;
+ if (i < m->currentBinLabels.size()) { binLabel = m->currentBinLabels[i]; }
+
+ newBinLabels.push_back(binLabel);
}
}
for (int j = 0; j < thislookup.size(); j++) { delete thislookup[j]; }
thislookup = newLookup;
+ m->currentBinLabels = newBinLabels;
return 0;
//read the first label, because it refers to the groups
string columnLabel;
iss >> columnLabel; m->gobble(iss);
-
+
//save names of columns you are reading
while (!iss.eof()) {
iss >> columnLabel; m->gobble(iss);
metadataLabels.push_back(columnLabel);
}
int count = metadataLabels.size();
-
+
//read rest of file
while (!in.eof()) {
string group = "";
in >> group; m->gobble(in);
groupNames.push_back(group);
-
+
SharedRAbundFloatVector* tempLookup = new SharedRAbundFloatVector();
tempLookup->setGroup(group);
tempLookup->setLabel("1");
for (int i = 0; i < count; i++) {
float temp = 0.0;
in >> temp;
-
tempLookup->push_back(temp, group);
}
//remove any groups the user does not want, and set globaldata->groups with only valid groups
SharedUtil* util;
util = new SharedUtil();
-
- util->setGroups(m->Groups, groupNames);
+ Groups = m->getGroups();
+ util->setGroups(Groups, groupNames);
+ m->setGroups(Groups);
for (int i = 0; i < lookupFloat.size(); i++) {
//if this sharedrabund is not from a group the user wants then delete it.
- if (util->isValidGroup(lookupFloat[i]->getGroup(), m->Groups) == false) {
+ if (util->isValidGroup(lookupFloat[i]->getGroup(), m->getGroups()) == false) {
delete lookupFloat[i]; lookupFloat[i] = NULL;
lookupFloat.erase(lookupFloat.begin()+i);
i--;