X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=venn.cpp;h=986c68db1f4942e8242aef7514f78441ef0e37e0;hb=2397df97b12cd5d21ea10dc4248c18a5803ddd41;hp=7cb2134fb475b76284c6dcfd857dac5a67f9f4b1;hpb=3abb236c602eb168ee112f080b563ebe2c705029;p=mothur.git diff --git a/venn.cpp b/venn.cpp index 7cb2134..986c68d 100644 --- a/venn.cpp +++ b/venn.cpp @@ -16,7 +16,7 @@ //********************************************************************************************************************** -Venn::Venn(){ +Venn::Venn(string o) : outputDir(o) { try { globaldata = GlobalData::getInstance(); @@ -31,13 +31,13 @@ void Venn::getPic(SAbundVector* sabund, vector vCalcs) { try { for(int i=0;iinputFileName + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); vector data = vCalcs[i]->getValues(sabund); //svg image - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; outsvg << ""; @@ -73,7 +73,7 @@ void Venn::getPic(vector lookup, vector vCalcs //make a file for each calculator for(int i=0;iinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); //in essence you want to run it like a single @@ -88,7 +88,7 @@ void Venn::getPic(vector lookup, vector vCalcs vector data = singleCalc->getValues(sabund); //svg image - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; outsvg << ""; @@ -122,7 +122,7 @@ void Venn::getPic(vector lookup, vector vCalcs //make a file for each calculator for(int i=0;iinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); //get estimates for sharedAB @@ -144,7 +144,7 @@ void Venn::getPic(vector lookup, vector vCalcs vector numB = singleCalc->getValues(sabundB); //image window - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; //draw circles @@ -168,7 +168,7 @@ void Venn::getPic(vector lookup, vector vCalcs }else { outsvg << "\n"; } outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]) + "\n"; - outsvg << "Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))) + "\n"; + outsvg << "Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))*100) + "\n"; outsvg << "The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0])) + "\n"; //close file @@ -191,7 +191,7 @@ void Venn::getPic(vector lookup, vector vCalcs for(int i=0;iinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); if (vCalcs[i]->getName() == "sharedace") { @@ -232,7 +232,7 @@ void Venn::getPic(vector lookup, vector vCalcs //merge BC and estimate with shared with A SharedRAbundVector* merge = new SharedRAbundVector(); for (int j = 0; j < lookup[1]->size(); j++) { - merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), j, ""); + merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), ""); } subset.clear(); @@ -243,7 +243,7 @@ void Venn::getPic(vector lookup, vector vCalcs //merge AC and estimate with shared with B merge = new SharedRAbundVector(); for (int j = 0; j < lookup[0]->size(); j++) { - merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), j, ""); + merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), ""); } subset.clear(); @@ -254,7 +254,7 @@ void Venn::getPic(vector lookup, vector vCalcs //merge AB and estimate with shared with C merge = new SharedRAbundVector(); for (int j = 0; j < lookup[0]->size(); j++) { - merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), j, ""); + merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), ""); } subset.clear(); @@ -284,7 +284,7 @@ void Venn::getPic(vector lookup, vector vCalcs } //image window - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; //draw circles @@ -306,12 +306,12 @@ void Venn::getPic(vector lookup, vector vCalcs outsvg << "" + toString(sharedBC[0] - sharedABC) + "\n"; outsvg << "" + toString(sharedABC) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "\n"; outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); if (numA.size() == 3) { outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; @@ -367,7 +367,7 @@ void Venn::getPic(vector lookup, vector vCalcs vector sharedabc = vCalcs[i]->getValues(subset); //image window - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; //draw circles @@ -389,9 +389,9 @@ void Venn::getPic(vector lookup, vector vCalcs outsvg << "" + toString(sharedbc[0] - sharedabc[0]) + "\n"; outsvg << "" + toString(sharedabc[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "\n"; outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); if (numA.size() == 3) { outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; @@ -446,7 +446,7 @@ void Venn::getPic(vector lookup, vector vCalcs if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); mothurOutEndLine(); } else{ - string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); @@ -536,7 +536,7 @@ void Venn::getPic(vector lookup, vector vCalcs //image window - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; outsvg << ""; outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; @@ -546,17 +546,17 @@ void Venn::getPic(vector lookup, vector vCalcs outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC) + "\n"; outsvg << "The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "\n"; - outsvg << "The number of sepecies shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "\n"; //make adjustments sharedABC = sharedABC - sharedABCD;