5 * Created by Sarah Westcott on 3/30/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
15 #include "sharedchao1.h"
16 #include "sharedsobscollectsummary.h"
19 //**********************************************************************************************************************
20 Venn::Venn(string o, bool n, string f, int fs, bool so) : outputDir(o), nseqs(n), inputfile(f), fontSize(fs), sharedOtus(so) {
22 m = MothurOut::getInstance();
25 m->errorOut(e, "Venn", "Venn");
29 //**********************************************************************************************************************
30 vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
33 vector<string> outputNames;
35 for(int i=0;i<vCalcs.size();i++){
36 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
37 outputNames.push_back(filenamesvg);
38 m->openOutputFile(filenamesvg, outsvg);
40 if (m->control_pressed) { outsvg.close(); return outputNames; }
42 vector<double> data = vCalcs[i]->getValues(sabund);
48 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(height) + " \" >\n";
51 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
52 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
53 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" + toString(int(0.50 * width)) + "\" cy=\"" + toString(int(0.29 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
54 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString((width / 2) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(data[0]) + "</text>\n";
56 if (data.size() == 3) {
57 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.60 * height)) + "\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
58 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.645 * height)) + "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
62 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.70 * height)) + "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
65 outsvg << "</g>\n</svg>\n";
72 m->errorOut(e, "Venn", "getPic");
76 //**********************************************************************************************************************
77 vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
80 vector<SharedRAbundVector*> subset;
81 vector<string> outputNames;
86 /******************* 1 Group **************************/
87 if (lookup.size() == 1) {
90 s = lookup[0]->getSAbundVector(); SAbundVector* sabund = &s;
92 //make a file for each calculator
93 for(int i=0;i<vCalcs.size();i++){
94 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
95 outputNames.push_back(filenamesvg);
96 m->openOutputFile(filenamesvg, outsvg);
98 if (m->control_pressed) { outsvg.close(); return outputNames; }
100 //in essence you want to run it like a single
101 if (vCalcs[i]->getName() == "sharedsobs") {
102 singleCalc = new Sobs();
103 }else if (vCalcs[i]->getName() == "sharedchao") {
104 singleCalc = new Chao1();
105 }else if (vCalcs[i]->getName() == "sharedace") {
106 singleCalc = new Ace(10);
109 vector<double> data = singleCalc->getValues(sabund);
112 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(height) + " \">\n";
115 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
116 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
117 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" + toString(int(0.50 * width)) + "\" cy=\"" + toString(int(0.29 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
118 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.50 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
119 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.50 * width) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(data[0]) + "</text>\n";
121 if (data.size() == 3) {
122 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.60 * height)) + "\" >The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
123 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.645 * height)) + "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
127 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.70 * height)) + "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
130 outsvg << "</g>\n</svg>\n";
135 /******************* 2 Groups **************************/
137 }else if (lookup.size() == 2) {
138 //get sabund vector pointers so you can use the single calculators
141 SAbundVector* sabundA; SAbundVector* sabundB;
142 sabundA = new SAbundVector(lookup[0]->getSAbundVector());// sabundA = &sA;
143 sabundB = new SAbundVector(lookup[1]->getSAbundVector());// sabundB = &sB;
146 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
148 //make a file for each calculator
149 for(int i=0;i<vCalcs.size();i++){
150 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
152 outputNames.push_back(filenamesvg);
153 m->openOutputFile(filenamesvg, outsvg);
155 if (m->control_pressed) { outsvg.close(); return outputNames; }
157 //get estimates for sharedAB
158 vector<string> labels;
159 vector<double> shared = vCalcs[i]->getValues(subset, labels);
161 //in essence you want to run it like a single
162 if (vCalcs[i]->getName() == "sharedsobs") {
163 singleCalc = new Sobs();
164 if (sharedOtus && (labels.size() != 0)) {
165 string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
167 outputNames.push_back(filenameShared);
169 m->openOutputFile(filenameShared, outShared);
170 outShared << "Groups\tNumShared\tOTULabels\n";
171 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t' << labels.size() << '\t';
172 for (int k = 0; k < labels.size()-1; k++) {
173 outShared << labels[k] << ",";
175 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
179 }else if (vCalcs[i]->getName() == "sharedchao") {
180 singleCalc = new Chao1();
183 int sharedVal, numSeqsA, numSeqsB, uniqSeqsToA, uniqSeqsToB;
185 NSeqs* nseqsCalc = new NSeqs();
186 vector<double> data = nseqsCalc->getValues(lookup);
187 cout << data[0] << '\t' << data[1] << endl;
188 sharedVal = data[0] + data[1];
189 numSeqsA = sabundA->getNumSeqs();
190 numSeqsB = sabundB->getNumSeqs();
191 uniqSeqsToA = numSeqsA-data[0];
192 uniqSeqsToB = numSeqsB-data[1];
198 //get estimates for numA
199 vector<double> numA = singleCalc->getValues(sabundA);
201 //get estimates for numB
202 vector<double> numB = singleCalc->getValues(sabundB);
205 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(height) + " \" >\n";
209 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
210 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
211 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.36 * width)) + "\" cy=\"" + toString(int(0.29 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
212 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.62 * width)) + "\" cy=\"" + toString(int(0.29 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
213 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(numA[0] - shared[0]) + "</text>\n";
214 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(numB[0] - shared[0]) + "</text>\n";
215 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
216 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
217 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(shared[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(shared[0]) + "</text>\n";
218 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.66 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
219 if (numA.size() == 3) {
220 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
222 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA) + "; " + toString(uniqSeqsToA) + " sequences are not shared"; }
223 outsvg << "</text>\n";
225 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.69 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
226 if (numB.size() == 3) {
227 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
229 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB) + "; " + toString(uniqSeqsToB) + " sequences are not shared"; }
230 outsvg << "</text>\n";
232 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.72 * height)) + "\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]);
233 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal) + "; " + toString((sharedVal / (float)(numSeqsA + numSeqsB))*100) + "% of these sequences are shared"; }
234 outsvg << "</text>\n";
236 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">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) + "</text>\n";
238 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.78 * height)) + "\">The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0]))+ "</text>\n";;
242 outsvg << "</g>\n</svg>\n";
246 /******************* 3 Groups **************************/
248 }else if (lookup.size() == 3) {
251 int windowSize = height;
254 //get sabund vector pointers so you can use the single calculators
256 SAbundVector sA, sB, sC;
257 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
258 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
259 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
260 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
262 //make a file for each calculator
263 for(int i=0;i<vCalcs.size();i++){
265 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
267 outputNames.push_back(filenamesvg);
268 m->openOutputFile(filenamesvg, outsvg);
270 if (m->control_pressed) { outsvg.close(); return outputNames; }
272 int sharedVal, sharedABVal, sharedACVal, sharedBCVal, numSeqsA, numSeqsB, numSeqsC, uniqSeqsToA, uniqSeqsToB, uniqSeqsToC;
275 NSeqs* nseqsCalc = new NSeqs();
276 vector<double> sharedData = nseqsCalc->getValues(lookup);
278 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
279 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
281 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
282 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
284 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
285 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
287 sharedVal = sharedData[0] + sharedData[1] + sharedData[2];
288 sharedABVal = sharedAB[0] + sharedAB[1];
289 sharedACVal = sharedAC[0] + sharedAC[1];
290 sharedBCVal = sharedBC[0] + sharedBC[1];
291 numSeqsA = sabundA->getNumSeqs();
292 numSeqsB = sabundB->getNumSeqs();
293 numSeqsC = sabundC->getNumSeqs();
294 uniqSeqsToA = numSeqsA-sharedData[0];
295 uniqSeqsToB = numSeqsC-sharedData[1];
296 uniqSeqsToC = numSeqsB-sharedData[1];
302 if (vCalcs[i]->getName() == "sharedace") {
304 singleCalc = new Ace(10);
306 //get estimates for numA
307 vector<double> numA = singleCalc->getValues(sabundA);
309 //get estimates for numB
310 vector<double> numB = singleCalc->getValues(sabundB);
312 //get estimates for numC
313 vector<double> numC = singleCalc->getValues(sabundC);
316 //get estimates for sharedAB, sharedAC and sharedBC
318 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
319 vector<double> sharedAB = vCalcs[i]->getValues(subset);
322 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
323 vector<double> sharedAC = vCalcs[i]->getValues(subset);
326 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
327 vector<double> sharedBC = vCalcs[i]->getValues(subset);
329 vector<double> sharedAwithBC;
330 vector<double> sharedBwithAC;
331 vector<double> sharedCwithAB;
333 //find possible sharedABC values
334 float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
336 if (vCalcs[i]->getMultiple() == false) {
337 //merge BC and estimate with shared with A
338 SharedRAbundVector* merge = new SharedRAbundVector();
339 for (int j = 0; j < lookup[1]->size(); j++) {
340 merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
344 subset.push_back(lookup[0]); subset.push_back(merge);
345 sharedAwithBC = vCalcs[i]->getValues(subset);
348 //merge AC and estimate with shared with B
349 merge = new SharedRAbundVector();
350 for (int j = 0; j < lookup[0]->size(); j++) {
351 merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
355 subset.push_back(merge); subset.push_back(lookup[1]);
356 sharedBwithAC = vCalcs[i]->getValues(subset);
359 //merge AB and estimate with shared with C
360 merge = new SharedRAbundVector();
361 for (int j = 0; j < lookup[0]->size(); j++) {
362 merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
366 subset.push_back(lookup[2]); subset.push_back(merge);
367 sharedCwithAB = vCalcs[i]->getValues(subset);
370 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
371 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
372 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
374 //if any of the possible m's are - throw them out
375 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
376 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
377 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
379 //sharedABC is the minimum of the 3 possibilities
380 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
381 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
382 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }
384 vector<double> data = vCalcs[i]->getValues(lookup);
386 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
387 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
388 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
392 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(windowSize) + " \" >\n";
396 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
397 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.44 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
398 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.33 * width)) + "\" cy=\"" + toString(int(0.25 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
399 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.65 * width)) + "\" cy=\"" + toString(int(0.25 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
400 outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.5 * width)) + "\" cy=\"" + toString(int(0.5 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
402 //place labels within overlaps
403 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.33 * width) - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n";
404 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.33 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
405 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB[0] - sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(sharedAB[0] - sharedABC) + "</text>\n";
406 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]-sharedBwithAC[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numB[0]-sharedBwithAC[0]) + "</text>\n";
407 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
408 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedAC[0] - sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedAC[0] - sharedABC) + "</text>\n";
409 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedCwithAB[0]).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(numC[0]-sharedCwithAB[0]) + "</text>\n";
410 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.52 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
411 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.58 * width) - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";
412 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.34 * height)) + "\">" + toString(sharedABC) + "</text>\n";
414 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.825 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]);
415 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
416 outsvg << "</text>\n";
417 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.85 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]);
418 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
419 outsvg << "</text>\n";
420 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.875 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]);
421 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
422 outsvg << "</text>\n";
423 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
424 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.925 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
425 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.95 * height)) + "\">The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
426 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.725 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
427 if (numA.size() == 3) {
428 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
430 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA) + "; " + toString(uniqSeqsToA) + " sequences are not shared"; }
431 outsvg << "</text>\n";
433 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
434 if (numB.size() == 3) {
435 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
437 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB) + "; " + toString(uniqSeqsToB) + " sequences are not shared"; }
438 outsvg << "</text>\n";
440 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.775 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
441 if (numC.size() == 3) {
442 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
444 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC) + "; " + toString(uniqSeqsToC) + " sequences are not shared"; }
445 outsvg << "</text>\n";
447 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.80 * height)) + "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "</text>\n";
448 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.975 * height)) + "\">The total shared richness is " + toString(sharedABC);
449 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
450 outsvg << "</text>\n";
454 }else { //sharedchao and sharedsobs are multigroup
457 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
458 string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
460 outputNames.push_back(filenameShared);
462 m->openOutputFile(filenameShared, outShared);
463 outShared << "Groups\tNumShared\tOTULabels\n";
465 vector<SharedRAbundVector*> subset;
467 //get estimates for numA
468 subset.push_back(lookup[0]);
469 vector<double> numA = vCalcs[i]->getValues(subset);
471 //get estimates for numB
473 subset.push_back(lookup[1]);
474 vector<double> numB = vCalcs[i]->getValues(subset);
476 //get estimates for numC
478 subset.push_back(lookup[2]);
479 vector<double> numC = vCalcs[i]->getValues(subset);
482 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
483 vector<string> labels;
484 vector<double> sharedab = vCalcs[i]->getValues(subset, labels);
485 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
486 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t' << labels.size() << '\t';
487 for (int k = 0; k < labels.size()-1; k++) {
488 outShared << labels[k] << ",";
490 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
495 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
496 vector<double> sharedac = vCalcs[i]->getValues(subset, labels);
497 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
498 outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
499 for (int k = 0; k < labels.size()-1; k++) {
500 outShared << labels[k] << ",";
502 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
507 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
508 vector<double> sharedbc = vCalcs[i]->getValues(subset, labels);
509 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
510 outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
511 for (int k = 0; k < labels.size()-1; k++) {
512 outShared << labels[k] << ",";
514 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
520 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
521 vector<double> sharedabc = vCalcs[i]->getValues(subset, labels);
522 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
523 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
524 for (int k = 0; k < labels.size()-1; k++) {
525 outShared << labels[k] << ",";
527 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
533 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(windowSize) + " \" >\n";
537 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
538 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
539 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.33 * width)) + "\" cy=\"" + toString(int(0.25 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
540 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.65 * width)) + "\" cy=\"" + toString(int(0.25 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
541 outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"" + toString(int(0.5 * width)) + "\" cy=\"" + toString(int(0.5 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
543 //place labels within overlaps
544 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "</text>\n";
545 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
546 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedab[0] - sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(sharedab[0] - sharedabc[0]) + "</text>\n";
547 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.68 * width) - ((int)toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
548 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.68 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
549 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedac[0] - sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedac[0] - sharedabc[0]) + "</text>\n";
550 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
551 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.51 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
552 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.59 * width) - ((int)toString(sharedbc[0] - sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedbc[0] - sharedabc[0]) + "</text>\n";
553 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.35 * height)) + "\">" + toString(sharedabc[0]) + "</text>\n";
555 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.825 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]);
556 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
557 outsvg << "</text>\n";
558 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.85 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]);
559 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
560 outsvg << "</text>\n";
561 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.875 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]);
562 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
563 outsvg << "</text>\n";
565 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.725 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
566 if (numA.size() == 3) {
567 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
569 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
570 outsvg << "</text>\n";
572 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
573 if (numB.size() == 3) {
574 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
576 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
577 outsvg << "</text>\n";
579 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.775 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
580 if (numC.size() == 3) {
581 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
583 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
584 outsvg << "</text>\n";
586 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.8 * height)) + "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedab[0] - sharedac[0] - sharedbc[0] + sharedabc[0]) + "</text>\n";
587 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The total shared richness is " + toString(sharedabc[0]);
588 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
589 outsvg << "</text>\n";
594 outsvg << "</g>\n</svg>\n";
600 /******************* 4 Groups **************************/
602 }else if (lookup.size() == 4) {
606 int windowSize = height;
608 //calc the shared otu
609 float sharedABCD = 0;
610 float numA = 0; float numB = 0; float numC = 0; float numD = 0;
611 float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
612 float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
614 //get sabund vector pointers so you can use the single calculators
616 SAbundVector sA, sB, sC, sD;
617 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
618 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
619 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
620 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
621 sD = lookup[3]->getSAbundVector(); sabundD = &sD;
623 //A = red, B = green, C = blue, D = yellow
625 //make a file for each calculator
626 for(int i=0;i<vCalcs.size();i++){
628 if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { m->mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); m->mothurOutEndLine(); }
630 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
631 outputNames.push_back(filenamesvg);
632 m->openOutputFile(filenamesvg, outsvg);
634 if (m->control_pressed) { outsvg.close(); return outputNames; }
636 //in essence you want to run it like a single
637 if (vCalcs[i]->getName() == "sharedsobs") {
638 singleCalc = new Sobs();
639 }else if (vCalcs[i]->getName() == "sharedchao") {
640 singleCalc = new Chao1();
643 //get estimates for numA
644 data = singleCalc->getValues(sabundA);
646 //cout << "num a = " << numA << endl;
648 //get estimates for numB
649 data = singleCalc->getValues(sabundB);
651 //cout << "num b = " << numB << endl;
652 //get estimates for numC
653 data = singleCalc->getValues(sabundC);
655 //cout << "num c = " << numC << endl;
656 //get estimates for numD
657 data = singleCalc->getValues(sabundD);
659 //cout << "num d = " << numD << endl;
662 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
663 string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
665 outputNames.push_back(filenameShared);
667 m->openOutputFile(filenameShared, outShared);
668 outShared << "Groups\tNumShared\tOTULabels\n";
671 //get estimates for pairs
673 vector<string> labels;
674 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
675 data = vCalcs[i]->getValues(subset, labels);
677 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
678 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t'<< labels.size() << '\t';
679 for (int k = 0; k < labels.size()-1; k++) {
680 outShared << labels[k] << ",";
682 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
685 //cout << "num ab = " << sharedAB << endl;
687 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
688 data = vCalcs[i]->getValues(subset, labels);
690 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
691 outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
692 for (int k = 0; k < labels.size()-1; k++) {
693 outShared << labels[k] << ",";
695 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
698 //cout << "num ac = " << sharedAC << endl;
700 subset.push_back(lookup[0]); subset.push_back(lookup[3]);
701 data = vCalcs[i]->getValues(subset, labels);
703 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
704 outShared << lookup[0]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
705 for (int k = 0; k < labels.size()-1; k++) {
706 outShared << labels[k] << ",";
708 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
711 //cout << "num ad = " << sharedAD << endl;
713 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
714 data = vCalcs[i]->getValues(subset, labels);
716 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
717 outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
718 for (int k = 0; k < labels.size()-1; k++) {
719 outShared << labels[k] << ",";
721 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
724 //cout << "num bc = " << sharedBC << endl;
726 subset.push_back(lookup[1]); subset.push_back(lookup[3]);
727 data = vCalcs[i]->getValues(subset, labels);
729 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
730 outShared << lookup[1]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
731 for (int k = 0; k < labels.size()-1; k++) {
732 outShared << labels[k] << ",";
734 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
737 //cout << "num bd = " << sharedBD << endl;
739 subset.push_back(lookup[2]); subset.push_back(lookup[3]);
740 data = vCalcs[i]->getValues(subset, labels);
742 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
743 outShared << lookup[2]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
744 for (int k = 0; k < labels.size()-1; k++) {
745 outShared << labels[k] << ",";
747 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
751 //cout << "num cd = " << sharedCD << endl;
752 //get estimates for combos of 3
754 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
755 data = vCalcs[i]->getValues(subset, labels);
757 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
758 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup()+ "-" + lookup[2]->getGroup()<< '\t'<< labels.size() << '\t';
759 for (int k = 0; k < labels.size()-1; k++) {
760 outShared << labels[k] << ",";
762 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
765 //cout << "num abc = " << sharedABC << endl;
767 subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
768 data = vCalcs[i]->getValues(subset, labels);
770 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
771 outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
772 for (int k = 0; k < labels.size()-1; k++) {
773 outShared << labels[k] << ",";
775 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
778 //cout << "num acd = " << sharedACD << endl;
780 subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
781 data = vCalcs[i]->getValues(subset,labels);
783 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
784 outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
785 for (int k = 0; k < labels.size()-1; k++) {
786 outShared << labels[k] << ",";
788 outShared << labels[labels.size()-1];
791 //cout << "num bcd = " << sharedBCD << endl;
793 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
794 data = vCalcs[i]->getValues(subset, labels);
796 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
797 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
798 for (int k = 0; k < labels.size()-1; k++) {
799 outShared << labels[k] << ",";
801 outShared << labels[labels.size()-1];
804 //cout << "num abd = " << sharedABD << endl;
805 //get estimate for all four
806 data = vCalcs[i]->getValues(lookup, labels);
807 sharedABCD = data[0];
808 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
809 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
810 for (int k = 0; k < labels.size()-1; k++) {
811 outShared << labels[k] << ",";
813 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
817 //cout << "num abcd = " << sharedABCD << endl << endl;
818 int sharedVal, sharedABCVal, sharedABDVal, sharedACDVal, sharedBCDVal, sharedABVal, sharedACVal, sharedADVal, sharedBCVal, sharedBDVal, sharedCDVal, numSeqsA, numSeqsB, numSeqsC, numSeqsD;
821 NSeqs* nseqsCalc = new NSeqs();
822 vector<double> sharedData = nseqsCalc->getValues(lookup);
824 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
825 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
827 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
828 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
830 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[3]);
831 vector<double> sharedAD = nseqsCalc->getValues(mysubset);
833 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
834 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
836 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
837 vector<double> sharedBD = nseqsCalc->getValues(mysubset);
839 mysubset.clear(); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
840 vector<double> sharedCD = nseqsCalc->getValues(mysubset);
842 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
843 vector<double> sharedABC = nseqsCalc->getValues(mysubset);
845 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
846 vector<double> sharedABD = nseqsCalc->getValues(mysubset);
848 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
849 vector<double> sharedACD = nseqsCalc->getValues(mysubset);
851 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
852 vector<double> sharedBCD = nseqsCalc->getValues(mysubset);
854 sharedVal = sharedData[0] + sharedData[1] + sharedData[2] + sharedData[3];
855 sharedABCVal = sharedABC[0] + sharedABC[1] + sharedABC[2];
856 sharedABDVal = sharedABD[0] + sharedABD[1] + sharedABD[2];
857 sharedACDVal = sharedACD[0] + sharedACD[1] + sharedACD[2];
858 sharedBCDVal = sharedBCD[0] + sharedBCD[1] + sharedBCD[2];
859 sharedABVal = sharedAB[0] + sharedAB[1];
860 sharedACVal = sharedAC[0] + sharedAC[1];
861 sharedADVal = sharedAD[0] + sharedAD[1];
862 sharedBCVal = sharedBC[0] + sharedBC[1];
863 sharedBDVal = sharedBD[0] + sharedBD[1];
864 sharedCDVal = sharedCD[0] + sharedCD[1];
865 numSeqsA = sabundA->getNumSeqs();
866 numSeqsB = sabundB->getNumSeqs();
867 numSeqsC = sabundC->getNumSeqs();
868 numSeqsD = sabundD->getNumSeqs();
875 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(windowSize) + " \" >\n";
877 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(windowSize) + "\"/>";
878 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\" >Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
880 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.625 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA);
881 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
882 outsvg << "</text>\n";
883 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.65 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB);
884 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
885 outsvg << "</text>\n";
886 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.675 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC);
887 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
888 outsvg << "</text>\n";
889 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.7 * height)) + "\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD);
890 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsD); }
891 outsvg << "</text>\n";
893 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.725 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB);
894 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
895 outsvg << "</text>\n";
896 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC);
897 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
898 outsvg << "</text>\n";
899 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.775 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD);
900 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedADVal); }
901 outsvg << "</text>\n";
902 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.8 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC);
903 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
904 outsvg << "</text>\n";
905 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.825 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD);
906 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBDVal); }
907 outsvg << "</text>\n";
908 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.85 * height)) + "\">The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD);
909 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedCDVal); }
910 outsvg << "</text>\n";
912 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.875 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC);
913 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABCVal); }
914 outsvg << "</text>\n";
915 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD);
916 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABDVal); }
917 outsvg << "</text>\n";
918 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.925 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD);
919 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACDVal); }
920 outsvg << "</text>\n";
921 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.95 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD);
922 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCDVal); }
923 outsvg << "</text>\n";
926 sharedABC = sharedABC - sharedABCD;
927 //cout << "num abc = " << sharedABC << endl;
928 sharedABD = sharedABD - sharedABCD;
929 //cout << "num abd = " << sharedABD << endl;
930 sharedACD = sharedACD - sharedABCD;
931 //cout << "num acd = " << sharedACD << endl;
932 sharedBCD = sharedBCD - sharedABCD;
933 //cout << "num bcd = " << sharedBCD << endl;
935 sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD; //cout << "num ab = " << sharedAB << endl;
936 sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD; //cout << "num ac = " << sharedAC << endl;
937 sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD; //cout << "num ad = " << sharedAD << endl;
938 sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD; //cout << "num bc = " << sharedBC << endl;
939 sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl;
940 sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD; //cout << "num cd = " << sharedCD << endl;
942 numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
943 //cout << "num a = " << numA << endl;
944 numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
945 //cout << "num b = " << numB << endl;
946 numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
947 //cout << "num c = " << numC << endl;
948 numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
949 //cout << "num d = " << numD << endl;
952 outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 " + toString(int(0.51 * width)) + " " + toString(int(0.27 * height)) + ") \" cx=\"" + toString(int(0.51 * width)) + "\" cy=\"" + toString(int(0.27 * height)) + "\" rx=\"" + toString(int(0.29 * width)) + "\" ry=\"" + toString(int(0.14 * height)) + "\"/>\n ";
953 outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 " + toString(int(0.51 * width)) + " " + toString(int(0.27 * height)) + ") \" cx=\"" + toString(int(0.51 * width)) + "\" cy=\"" + toString(int(0.27 * height)) + "\" rx=\"" + toString(int(0.29 * width)) + "\" ry=\"" + toString(int(0.14 * height)) + "\"/>\n ";
954 outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 " + toString(int(0.63 * width)) + " " + toString(int(0.36 * height)) + ") \" cx=\"" + toString(int(0.63 * width)) + "\" cy=\"" + toString(int(0.36 * height)) + "\" rx=\"" + toString(int(0.29 * width)) + "\" ry=\"" + toString(int(0.14 * height)) + "\"/>\n ";
955 outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 " + toString(int(0.36 * width)) + " " + toString(int(0.36 * height)) + ") \" cx=\"" + toString(int(0.36 * width)) + "\" cy=\"" + toString(int(0.36 * height)) + "\" rx=\"" + toString(int(0.29 * width)) + "\" ry=\"" + toString(int(0.14 * height)) + "\"/>\n ";
957 //A = red, B = green, C = blue, D = yellow
959 //place labels within overlaps
960 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.66 * width) - ((int)toString(numA).length() / 2)) + "\" y=\"" + toString(int(0.14 * height)) + "\">" + toString(numA) + "</text>\n";
961 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.66 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
962 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB).length() / 2)) + "\" y=\"" + toString(int(0.2 * height)) + "\">" + toString(sharedAB) + "</text>\n";
963 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.36 * width) - ((int)toString(numB).length() / 2)) + "\" y=\"" + toString(int(0.14 * height)) + "\">" + toString(numB) + "</text>\n";
964 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.36 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
965 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(sharedAC).length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + toString(sharedAC) + "</text>\n";
966 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.785 * width) - ((int)toString(numC).length() / 2)) + "\" y=\"" + toString(int(0.29 * height)) + "\">" + toString(numC) + "</text>\n";
967 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.785 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
968 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.31 * width) - ((int)toString(sharedBD).length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + toString(sharedBD) + "</text>\n";
969 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.22 * width) - ((int)toString(numD).length() / 2)) + "\" y=\"" + toString(int(0.29 * height)) + "\">" + toString(numD) + "</text>\n";
970 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.22 * width) - ((int)lookup[3]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[3]->getGroup() + "</text>\n";
971 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.34 * width) - ((int)toString(sharedAD).length() / 2)) + "\" y=\"" + toString(int(0.41 * height)) + "\">" + toString(sharedAD) + "</text>\n";
972 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.675 * width) - ((int)toString(sharedBC).length() / 2)) + "\" y=\"" + toString(int(0.41 * height)) + "\">" + toString(sharedBC) + "</text>\n";
973 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedCD).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(sharedCD) + "</text>\n";
974 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.39 * width) - ((int)toString(sharedABD).length() / 2)) + "\" y=\"" + toString(int(0.3 * height)) + "\">" + toString(sharedABD) + "</text>\n";
975 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.57 * width) - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"" + toString(int(0.45 * height)) + "\">" + toString(sharedBCD) + "</text>\n";
976 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.435 * width) - ((int)toString(sharedACD).length() / 2)) + "\" y=\"" + toString(int(0.45 * height)) + "\">" + toString(sharedACD) + "</text>\n";
977 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.63 * width) - ((int)toString(sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.3 * height)) + "\">" + toString(sharedABC) + "</text>\n";
978 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABCD).length() / 2)) + "\" y=\"" + toString(int(0.4 * height)) + "\">" + toString(sharedABCD) + "</text>\n";
980 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.975 * height)) + "\">The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD));
981 if (nseqs) { outsvg << ", and the number of squences in the otus shared by all groups is " + toString(sharedVal); }
982 outsvg << "</text>\n";
984 outsvg << "</g>\n</svg>\n";
994 catch(exception& e) {
995 m->errorOut(e, "Venn", "getPic");