374610830F40652400460C57 /* unweighted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374610820F40652400460C57 /* unweighted.cpp */; };
3746109D0F40657600460C57 /* unifracunweightedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */; };
37519A6B0F80E6EB00FED5E8 /* sharedanderbergs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37519A6A0F80E6EB00FED5E8 /* sharedanderbergs.cpp */; };
+ 37519AA10F810D0200FED5E8 /* venncommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37519AA00F810D0200FED5E8 /* venncommand.cpp */; };
+ 37519AB50F810FAE00FED5E8 /* venn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37519AB40F810FAE00FED5E8 /* venn.cpp */; };
375873E70F7D63E90040F377 /* coverage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375873E50F7D63E90040F377 /* coverage.cpp */; };
375873EC0F7D64520040F377 /* fullmatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375873EB0F7D64520040F377 /* fullmatrix.cpp */; };
375873EF0F7D646F0040F377 /* heatmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375873EE0F7D646F0040F377 /* heatmap.cpp */; };
EB6F015B0F6AC1670048081A /* sharedbdiversity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB6F015A0F6AC1670048081A /* sharedbdiversity.cpp */; };
EB9303EB0F534D9400E8EF26 /* logsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB9303EA0F534D9400E8EF26 /* logsd.cpp */; };
EB9303F90F53517300E8EF26 /* geom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB9303F80F53517300E8EF26 /* geom.cpp */; };
- EBC564190F81479000A5AC46 /* sharedjackknife.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBC564180F81479000A5AC46 /* sharedjackknife.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unifracunweightedcommand.cpp; sourceTree = "<group>"; };
37519A690F80E6EB00FED5E8 /* sharedanderbergs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedanderbergs.h; sourceTree = "<group>"; };
37519A6A0F80E6EB00FED5E8 /* sharedanderbergs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedanderbergs.cpp; sourceTree = "<group>"; };
+ 37519A9F0F810D0200FED5E8 /* venncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = venncommand.h; sourceTree = "<group>"; };
+ 37519AA00F810D0200FED5E8 /* venncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = venncommand.cpp; sourceTree = "<group>"; };
+ 37519AB30F810FAE00FED5E8 /* venn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = venn.h; sourceTree = "<group>"; };
+ 37519AB40F810FAE00FED5E8 /* venn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = venn.cpp; sourceTree = "<group>"; };
375873E50F7D63E90040F377 /* coverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = coverage.cpp; sourceTree = "<group>"; };
375873E60F7D63E90040F377 /* coverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coverage.h; sourceTree = "<group>"; };
375873EA0F7D64520040F377 /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullmatrix.h; sourceTree = "<group>"; };
EB9303EA0F534D9400E8EF26 /* logsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logsd.cpp; sourceTree = "<group>"; };
EB9303F70F53517300E8EF26 /* geom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = geom.h; sourceTree = "<group>"; };
EB9303F80F53517300E8EF26 /* geom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = geom.cpp; sourceTree = "<group>"; };
- EBC564170F81479000A5AC46 /* sharedjackknife.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedjackknife.h; sourceTree = "<group>"; };
- EBC564180F81479000A5AC46 /* sharedjackknife.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedjackknife.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
37D928480F21331F001D4494 /* summarydata.h */,
37D928490F21331F001D4494 /* summarydisplay.h */,
37D9284C0F21331F001D4494 /* utilities.hpp */,
+ 37519AB30F810FAE00FED5E8 /* venn.h */,
+ 37519AB40F810FAE00FED5E8 /* venn.cpp */,
);
name = Source;
sourceTree = "<group>";
37D928240F21331F001D4494 /* sharedchao1.cpp */,
37D928290F21331F001D4494 /* sharedjabund.h */,
37D928280F21331F001D4494 /* sharedjabund.cpp */,
- EBC564170F81479000A5AC46 /* sharedjackknife.h */,
- EBC564180F81479000A5AC46 /* sharedjackknife.cpp */,
37D9282B0F21331F001D4494 /* sharedjclass.h */,
37D9282A0F21331F001D4494 /* sharedjclass.cpp */,
37D9282D0F21331F001D4494 /* sharedjest.h */,
37D9282C0F21331F001D4494 /* sharedjest.cpp */,
EB1217210F61C9AC004A865F /* sharedkstest.h */,
EB1217220F61C9AC004A865F /* sharedkstest.cpp */,
- 375873FE0F7D64EF0040F377 /* sharedkulczynski.cpp */,
- 375873FF0F7D64EF0040F377 /* sharedlennon.cpp */,
375874000F7D64EF0040F377 /* sharedkulczynski.h */,
- 375874010F7D64EF0040F377 /* sharedlennon.h */,
- 375874020F7D64EF0040F377 /* sharedkulczynskicody.cpp */,
+ 375873FE0F7D64EF0040F377 /* sharedkulczynski.cpp */,
375874030F7D64EF0040F377 /* sharedkulczynskicody.h */,
+ 375874020F7D64EF0040F377 /* sharedkulczynskicody.cpp */,
+ 375874010F7D64EF0040F377 /* sharedlennon.h */,
+ 375873FF0F7D64EF0040F377 /* sharedlennon.cpp */,
375874070F7D64FC0040F377 /* sharedmorisitahorn.h */,
375874080F7D64FC0040F377 /* sharedmorisitahorn.cpp */,
375874090F7D64FC0040F377 /* sharedochiai.h */,
- 3758740A0F7D64FC0040F377 /* sharednseqs.h */,
3758740B0F7D64FC0040F377 /* sharedochiai.cpp */,
+ 3758740A0F7D64FC0040F377 /* sharednseqs.h */,
37D928350F21331F001D4494 /* sharedsobs.h */,
37D928340F21331F001D4494 /* sharedsobs.cpp */,
37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */,
A70B53A60F4CD7AD0064797E /* getlabelcommand.cpp */,
A70B53A90F4CD7AD0064797E /* getlinecommand.h */,
A70B53A80F4CD7AD0064797E /* getlinecommand.cpp */,
- 375873F00F7D64800040F377 /* heatmapcommand.cpp */,
375873F10F7D64800040F377 /* heatmapcommand.h */,
+ 375873F00F7D64800040F377 /* heatmapcommand.cpp */,
37D927E40F21331F001D4494 /* helpcommand.h */,
37D927E30F21331F001D4494 /* helpcommand.cpp */,
375873F30F7D648F0040F377 /* libshuffcommand.cpp */,
3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */,
374610760F40645300460C57 /* unifracweightedcommand.h */,
374610770F40645300460C57 /* unifracweightedcommand.cpp */,
+ 37519A9F0F810D0200FED5E8 /* venncommand.h */,
+ 37519AA00F810D0200FED5E8 /* venncommand.cpp */,
);
name = commands;
sourceTree = "<group>";
3758740C0F7D64FC0040F377 /* sharedmorisitahorn.cpp in Sources */,
3758740D0F7D64FC0040F377 /* sharedochiai.cpp in Sources */,
37519A6B0F80E6EB00FED5E8 /* sharedanderbergs.cpp in Sources */,
- EBC564190F81479000A5AC46 /* sharedjackknife.cpp in Sources */,
+ 37519AA10F810D0200FED5E8 /* venncommand.cpp in Sources */,
+ 37519AB50F810FAE00FED5E8 /* venn.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "unifracweightedcommand.h"
#include "libshuffcommand.h"
#include "heatmapcommand.h"
+#include "venncommand.h"
#include "mothur.h"
#include "nocommands.h"
else if(commandName == "get.line") { command = new GetlineCommand(); }
else if(commandName == "libshuff") { command = new LibShuffCommand(); }
else if(commandName == "heatmap") { command = new HeatMapCommand(); }
+ else if(commandName == "venn") { command = new VennCommand(); }
else { command = new NoCommand(); }
return command;
}
}
- if (commandName == "heatmap"){
+ if ((commandName == "heatmap") || (commandName == "venn")) {
if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
- cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap command." << endl; return false;
+ cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap or venn commands." << endl; return false;
}
}
cout << "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters)." << "\n" << "\n";
}else if (globaldata->helpRequest == "heatmap") {
cout << "The heatmap command can only be executed after a successful read.otu command." << "\n";
- cout << "The heatmap command parameters are groups, line and label. No parameters are required, but you may not use line and label at the same time." << "\n";
+ cout << "The heatmap command parameters are groups, sorted, line and label. No parameters are required, but you may not use line and label at the same time." << "\n";
cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap." << "\n";
+ cout << "The sorted parameter allows you to choose to see the file with the shared otus at the top or the exact representation of your input file. " << "\n";
cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes." << "\n";
- cout << "The heatmap command should be in the following format: heatmap(groups=yourGroups, line=yourLines, label=yourLabels)." << "\n";
- cout << "Example heatmap(groups=A-B-C, line=1-3-5)." << "\n";
+ cout << "The heatmap command should be in the following format: heatmap(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n";
+ cout << "Example heatmap(groups=A-B-C, line=1-3-5, sorted=0)." << "\n";
cout << "The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used." << "\n";
+ cout << "The default value for sorted is 1 meaning you want the shared otus on top, you may change it to 0 meaning the exact representation of your input file." << "\n";
cout << "The heatmap command outputs a .svg file for each line or label you specify." << "\n";
cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
}else if (globaldata->helpRequest == "quit") {
commands["unifrac.unweighted"] = "unifrac.unweighted";
commands["libshuff"] = "libshuff";
commands["heatmap"] = "heatmap";
+ commands["venn"] = "venn";
commands["get.group"] = "get.group";
commands["get.label"] = "get.label";
commands["get.line"] = "get.line";
string heatmapArray[] = {"group","line","label","sorted"};
commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string));
+ string vennArray[] = {"group","line","label"};
+ commandParameters["venn"] = addParameters(vennArray, sizeof(vennArray)/sizeof(string));
+
string quitArray[] = {};
commandParameters["quit"] = addParameters(quitArray, sizeof(quitArray)/sizeof(string));
--- /dev/null
+/*
+ * venn.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/30/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "venn.h"
+
+//**********************************************************************************************************************
+Venn::Venn(){
+ try {
+ globaldata = GlobalData::getInstance();
+ format = globaldata->getFormat();
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Venn class function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+void Venn::getPic(OrderVector* order) {
+ try {
+
+ rabund = order->getRAbundVector();
+
+ string filenamesvg = globaldata->inputFileName + ".venn." + order->getLabel() + ".svg";
+
+ openOutputFile(filenamesvg, outsvg);
+
+
+ //svg image
+ outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 200 200\" >\n";
+ outsvg << "<g>\n";
+
+ outsvg << "<circle fill=\"red\" stroke=\"black\" cx=\"150\" cy=\"150\" r=\"100\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"140\" y=\"150\">" + toString(rabund.getNumBins()) + "</text>\n";
+ outsvg << "</g>\n</svg>\n";
+
+ outsvg.close();
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Venn class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+void Venn::getPic(SharedOrderVector* sharedorder) {
+ try {
+
+ //fills vector of sharedsabunds - lookup
+ getSharedVectors(sharedorder);
+
+ string filenamesvg = globaldata->inputFileName + ".venn." + sharedorder->getLabel() + "." + groupComb + ".svg";
+ openOutputFile(filenamesvg, outsvg);
+
+ //image window
+ outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
+ outsvg << "<g>\n";
+
+ if (lookup.size() == 1) {
+ outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"150\" cy=\"150\" r=\"100\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"140\" y=\"150\">" + toString(lookup[0]->getNumBins()) + "</text>\n";
+ outsvg << "</g>\n</svg>\n";
+
+ }else if (lookup.size() == 2) {
+ //calc the shared otu
+ int shared = 0;
+ int numA = 0;
+ int numB = 0;
+
+ float rScaler;
+
+ //for each bin
+ for (int i = 0; i < lookup[0]->size(); i++) {
+ if (lookup[0]->getAbundance(i) != 0) { numA++; }
+ if (lookup[1]->getAbundance(i) != 0) { numB++; }
+ //are they shared
+ if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0)) { shared++; }
+ }
+
+ if (numA > numB) { rScaler = 150 / float(numA); }
+ else { rScaler = 150 / float(numB); }
+
+ //to determine how far over to overlap b onto a.
+ float percentOverlap = shared / (float) numA;
+
+ int bx = 200 + (numA * rScaler) - ((2 * (numA * rScaler)) * percentOverlap) + (numB * rScaler);
+ int leftedgeB = bx - (numB * rScaler); //center b - b's radius
+ int leftedgeA = 200 - (numA * rScaler); //center a - a's radius
+ int rightedgeB = bx + (numB * rScaler); //center b + b's radius
+ int rightedgeA = 200 + (numA * rScaler); //center a + a's radius
+
+ int mida = leftedgeA + ((leftedgeB - leftedgeA) / 2);
+ int midb = rightedgeA + ((rightedgeB - rightedgeA) / 2);
+ int midab = leftedgeB + ((rightedgeA - leftedgeB) / 2);
+
+ //draw circles
+ outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(leftedgeA + ((rightedgeB - leftedgeA) / 2) - 70) + "\" y=\"50\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n";
+ outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".5\" stroke=\"black\" cx=\"200\" cy=\"250\" r=\"" + toString(numA * rScaler) + "\"/>";
+ outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".5\" stroke=\"black\" cx=\"" + toString(bx) + "\" cy=\"250\" r=\"" + toString(numB * rScaler) + "\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(mida) + "\" y=\"250\">" + toString(numA-shared) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(midab) + "\" y=\"250\">" + toString(shared) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(midb) + "\" y=\"250\">" + toString(numB-shared) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(mida) + "\" y=\"500\">Percentage of species that are shared is " + toString((shared / (float)(numA + numB - shared))) + "</text>\n";
+
+ }else if (lookup.size() == 3) {
+ //calc the shared otu
+ int sharedABC = 0;
+ int numA = 0; int numB = 0; int numC = 0;
+ int sharedAB = 0; int sharedAC = 0; int sharedBC = 0;
+
+ //float scalerB;
+
+ //for each bin
+ for (int i = 0; i < lookup[0]->size(); i++) {
+ if (lookup[0]->getAbundance(i) != 0) { numA++; }
+ if (lookup[1]->getAbundance(i) != 0) { numB++; }
+ if (lookup[2]->getAbundance(i) != 0) { numC++; }
+ //are they shared by 2
+ if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0)) { sharedAB++; }
+ if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0)) { sharedAC++; }
+ if ((lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0)) { sharedBC++; }
+
+ //are they shared by all
+ if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0)) { sharedABC++; }
+ }
+
+ //draw circles
+ outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n";
+ outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>";
+ outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>";
+ outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>";
+
+ //place labels within overlaps
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA-sharedAB-sharedAC+sharedABC).length() / 2)) + "\" y=\"170\">" + toString(numA-sharedAB-sharedAC+sharedABC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedAB).length() / 2)) + "\" y=\"170\">" + toString(sharedAB) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)toString(numB-sharedAB-sharedBC+sharedABC).length() / 2)) + "\" y=\"170\">" + toString(numB-sharedAB-sharedBC+sharedABC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(268 - ((int)toString(sharedAC).length() / 2)) + "\" y=\"305\">" + toString(sharedAC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(numC-sharedAC-sharedBC+sharedABC).length() / 2)) + "\" y=\"430\">" + toString(numC-sharedAC-sharedBC+sharedABC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"305\">" + toString(sharedBC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedABC).length() / 2)) + "\" y=\"280\">" + toString(sharedABC) + "</text>\n";
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"580\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString((sharedAB / (float)(numA + numB - sharedAB))) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"610\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString((sharedAC / (float)(numA + numC - sharedAC))) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"640\">Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString((sharedBC / (float)(numB + numC - sharedBC))) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"670\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString((sharedABC / (float)(numA + numB + numC - sharedAB - sharedAC - sharedBC - (2 * sharedABC)))) + "</text>\n";
+ }
+
+ outsvg << "</g>\n</svg>\n";
+ outsvg.close();
+
+
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Venn class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+void Venn::getSharedVectors(SharedOrderVector* order){
+ try {
+
+ //delete lookup
+ for (int j = 0; j < lookup.size(); j++) {
+ delete lookup[j];
+ }
+
+ lookup.clear();
+
+ groupComb = "";
+
+ //create and initialize vector of sharedvectors, one for each group
+ for (int i = 0; i < globaldata->Groups.size(); i++) {
+ SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
+ temp->setLabel(order->getLabel());
+ temp->setGroup(globaldata->Groups[i]);
+ groupComb += globaldata->Groups[i];
+ lookup.push_back(temp);
+ }
+
+ int numSeqs = order->size();
+ //sample all the members
+ for(int i=0;i<numSeqs;i++){
+ //get first sample
+ individual chosen = order->get(i);
+ int abundance;
+
+ //set info for sharedvector in chosens group
+ for (int j = 0; j < lookup.size(); j++) {
+ if (chosen.group == lookup[j]->getGroup()) {
+ abundance = lookup[j]->getAbundance(chosen.bin);
+ lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
+ break;
+ }
+ }
+ }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Venn class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+//**********************************************************************************************************************
+
+
+
--- /dev/null
+#ifndef VENN_H
+#define VENN_H
+/*
+ * venn.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/30/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+using namespace std;
+
+#include "ordervector.hpp"
+#include "rabundvector.hpp"
+#include "sharedrabundvector.h"
+#include "sharedordervector.h"
+#include "datavector.hpp"
+#include "globaldata.hpp"
+
+/***********************************************************************/
+
+class Venn {
+
+ public:
+ Venn();
+ ~Venn(){};
+
+ void getPic(OrderVector*);
+ void getPic(SharedOrderVector*);
+
+ private:
+ void getSharedVectors(SharedOrderVector*);
+
+ RAbundVector rabund;
+ GlobalData* globaldata;
+ vector<SharedRAbundVector*> lookup;
+ string format, groupComb;
+ ofstream outsvg;
+
+
+};
+/***********************************************************************/
+
+#endif
+
--- /dev/null
+/*
+ * venncommand.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/30/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "venncommand.h"
+
+//**********************************************************************************************************************
+
+VennCommand::VennCommand(){
+ try {
+ globaldata = GlobalData::getInstance();
+ venn = new Venn();
+ format = globaldata->getFormat();
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function VennCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the VennCommand class function VennCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+VennCommand::~VennCommand(){
+ delete input;
+ delete read;
+ delete venn;
+}
+
+//**********************************************************************************************************************
+
+int VennCommand::execute(){
+ try {
+ int count = 1;
+
+ if (format == "sharedfile") {
+ //you have groups
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ order = input->getSharedOrderVector();
+ }else if (format == "shared") {
+ //you are using a list and a groupfile
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
+ }else if (format == "list") {
+ //you are using just a list file and have only one group
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ ordersingle = globaldata->gorder;
+ input = globaldata->ginput;
+ }
+
+
+ if (format != "list") {
+
+ setGroups();
+
+ while(order != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+
+ cout << order->getLabel() << '\t' << count << endl;
+ venn->getPic(order);
+
+ }
+
+ //get next line to process
+ if (format == "sharedfile") {
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ SharedList = input->getSharedListVector(); //get new list vector to process
+ if (SharedList != NULL) {
+ order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
+ }else {
+ break;
+ }
+ }
+ count++;
+ }
+
+ //reset groups parameter
+ globaldata->Groups.clear(); globaldata->setGroups("");
+
+ }else{
+ while(ordersingle != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(ordersingle->getLabel()) == 1){
+
+ cout << ordersingle->getLabel() << '\t' << count << endl;
+ venn->getPic(ordersingle);
+
+ }
+
+ ordersingle = (input->getOrderVector());
+ count++;
+ }
+ }
+
+ return 0;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the VennCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+void VennCommand::setGroups() {
+ try {
+ //if the user has not entered specific groups to analyze then do them all
+ if (globaldata->Groups.size() != 0) {
+ if (globaldata->Groups[0] != "all") {
+ //check that groups are valid
+ for (int i = 0; i < globaldata->Groups.size(); i++) {
+ if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) {
+ cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl;
+ // erase the invalid group from globaldata->Groups
+ globaldata->Groups.erase(globaldata->Groups.begin()+i);
+ }
+ }
+
+ //if the user only entered invalid groups
+ if (globaldata->Groups.size() == 0) {
+ cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first three groups in your groupfile." << endl;
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+ globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+ }
+ }
+ }else{//user has enter "all" and wants the default groups
+ globaldata->Groups.clear();
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+ globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+ }
+ globaldata->setGroups("");
+ }
+ }else {
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+ globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+ }
+ }
+
+
+ //check to make sure their are only 3 groups
+ if (globaldata->Groups.size() > 3) {
+ cout << "You may only use 3 groups at a time with this command. I will choose the first three and disregard the rest." << endl;
+ for (int i = 3; i < globaldata->Groups.size(); i++) {
+ globaldata->Groups.erase(globaldata->Groups.begin()+i);
+ }
+ }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the VennCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************/
+
--- /dev/null
+#ifndef VENNCOMMAND_H
+#define VENNCOMMAND_H
+/*
+ * venncommand.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/30/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+#include "inputdata.h"
+#include "readmatrix.hpp"
+#include "sharedlistvector.h"
+#include "venn.h"
+
+
+class GlobalData;
+
+
+class VennCommand : public Command {
+
+public:
+ VennCommand();
+ ~VennCommand();
+ int execute();
+
+private:
+ GlobalData* globaldata;
+ ReadMatrix* read;
+ InputData* input;
+ SharedListVector* SharedList;
+ SharedOrderVector* order;
+ OrderVector* ordersingle;
+ Venn* venn;
+ string format;
+
+ void setGroups();
+
+};
+
+
+
+#endif
\ No newline at end of file