5 * Created by Sarah Westcott on 3/30/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
14 #include "sharedchao1.h"
15 #include "sharedsobscollectsummary.h"
18 //**********************************************************************************************************************
21 globaldata = GlobalData::getInstance();
25 errorOut(e, "Venn", "Venn");
29 //**********************************************************************************************************************
30 void Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
33 for(int i=0;i<vCalcs.size();i++){
34 string filenamesvg = globaldata->inputFileName + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg";
35 openOutputFile(filenamesvg, outsvg);
37 vector<double> data = vCalcs[i]->getValues(sabund);
40 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
43 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
44 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
45 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>";
46 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(data[0]).length() / 2)) + "\" y=\"195\">" + toString(data[0]) + "</text>\n";
48 if (data.size() == 3) {
49 outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"380\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
50 outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"410\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
53 outsvg << "</g>\n</svg>\n";
58 errorOut(e, "Venn", "getPic");
62 //**********************************************************************************************************************
63 void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
66 vector<SharedRAbundVector*> subset;
68 /******************* 1 Group **************************/
69 if (lookup.size() == 1) {
72 s = lookup[0]->getSAbundVector(); SAbundVector* sabund = &s;
74 //make a file for each calculator
75 for(int i=0;i<vCalcs.size();i++){
76 string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
77 openOutputFile(filenamesvg, outsvg);
79 //in essence you want to run it like a single
80 if (vCalcs[i]->getName() == "sharedsobs") {
81 singleCalc = new Sobs();
82 }else if (vCalcs[i]->getName() == "sharedchao") {
83 singleCalc = new Chao1();
84 }else if (vCalcs[i]->getName() == "sharedace") {
85 singleCalc = new Ace(10);
88 vector<double> data = singleCalc->getValues(sabund);
91 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
94 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
95 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
96 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>";
97 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"165\">" + lookup[0]->getGroup() + "</text>\n";
98 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(data[0]).length() / 2)) + "\" y=\"195\">" + toString(data[0]) + "</text>\n";
100 if (data.size() == 3) {
101 outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"380\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
102 outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"410\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
105 outsvg << "</g>\n</svg>\n";
110 /******************* 2 Groups **************************/
112 }else if (lookup.size() == 2) {
113 //get sabund vector pointers so you can use the single calculators
116 SAbundVector* sabundA; SAbundVector* sabundB;
117 sabundA = new SAbundVector(lookup[0]->getSAbundVector());// sabundA = &sA;
118 sabundB = new SAbundVector(lookup[1]->getSAbundVector());// sabundB = &sB;
121 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
123 //make a file for each calculator
124 for(int i=0;i<vCalcs.size();i++){
125 string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
126 openOutputFile(filenamesvg, outsvg);
128 //get estimates for sharedAB
129 vector<double> shared = vCalcs[i]->getValues(subset);
131 //in essence you want to run it like a single
132 if (vCalcs[i]->getName() == "sharedsobs") {
133 singleCalc = new Sobs();
134 }else if (vCalcs[i]->getName() == "sharedchao") {
135 singleCalc = new Chao1();
136 }else if (vCalcs[i]->getName() == "sharedace") {
137 singleCalc = new Ace(10);
140 //get estimates for numA
141 vector<double> numA = singleCalc->getValues(sabundA);
143 //get estimates for numB
144 vector<double> numB = singleCalc->getValues(sabundB);
147 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
151 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
152 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
153 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"250\" cy=\"200\" r=\"150\"/>";
154 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"435\" cy=\"200\" r=\"150\"/>";
155 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]).length() / 2)) + "\" y=\"195\">" + toString(numA[0] - shared[0]) + "</text>\n";
156 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(numB[0]).length() / 2)) + "\" y=\"195\">" + toString(numB[0] - shared[0]) + "</text>\n";
157 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"175\">" + lookup[0]->getGroup() + "</text>\n";
158 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"175\">" + lookup[1]->getGroup() + "</text>\n";
159 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(shared[0]).length() / 2)) + "\" y=\"195\">" + toString(shared[0]) + "</text>\n";
160 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"460\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
161 if (numA.size() == 3) {
162 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
163 }else { outsvg << "</text>\n"; }
165 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"480\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
166 if (numB.size() == 3) {
167 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
168 }else { outsvg << "</text>\n"; }
170 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"500\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]) + "</text>\n";
171 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"520\">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]))) + "</text>\n";
172 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"540\">The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0])) + "</text>\n";
175 outsvg << "</g>\n</svg>\n";
179 /******************* 3 Groups **************************/
181 }else if (lookup.size() == 3) {
182 //get sabund vector pointers so you can use the single calculators
184 SAbundVector sA, sB, sC;
185 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
186 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
187 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
188 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
190 //make a file for each calculator
191 for(int i=0;i<vCalcs.size();i++){
193 //in essence you want to run it like a single
194 if (vCalcs[i]->getName() == "sharedsobs") {
195 singleCalc = new Sobs();
196 }else if (vCalcs[i]->getName() == "sharedchao") {
197 singleCalc = new Chao1();
198 }else if (vCalcs[i]->getName() == "sharedace") {
199 singleCalc = new Ace(10);
202 //get estimates for numA
203 vector<double> numA = singleCalc->getValues(sabundA);
205 //get estimates for numB
206 vector<double> numB = singleCalc->getValues(sabundB);
208 //get estimates for numC
209 vector<double> numC = singleCalc->getValues(sabundC);
212 string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
213 openOutputFile(filenamesvg, outsvg);
215 //get estimates for sharedAB, sharedAC and sharedBC
217 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
218 vector<double> sharedAB = vCalcs[i]->getValues(subset);
221 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
222 vector<double> sharedAC = vCalcs[i]->getValues(subset);
225 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
226 vector<double> sharedBC = vCalcs[i]->getValues(subset);
228 vector<double> sharedAwithBC;
229 vector<double> sharedBwithAC;
230 vector<double> sharedCwithAB;
232 //find possible sharedABC values
233 float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
235 if (vCalcs[i]->getMultiple() == false) {
236 //merge BC and estimate with shared with A
237 SharedRAbundVector* merge = new SharedRAbundVector();
238 for (int j = 0; j < lookup[1]->size(); j++) {
239 merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), j, "");
243 subset.push_back(lookup[0]); subset.push_back(merge);
244 sharedAwithBC = vCalcs[i]->getValues(subset);
247 //merge AC and estimate with shared with B
248 merge = new SharedRAbundVector();
249 for (int j = 0; j < lookup[0]->size(); j++) {
250 merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), j, "");
254 subset.push_back(merge); subset.push_back(lookup[1]);
255 sharedBwithAC = vCalcs[i]->getValues(subset);
258 //merge AB and estimate with shared with C
259 merge = new SharedRAbundVector();
260 for (int j = 0; j < lookup[0]->size(); j++) {
261 merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), j, "");
265 subset.push_back(lookup[2]); subset.push_back(merge);
266 sharedCwithAB = vCalcs[i]->getValues(subset);
269 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
270 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
271 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
273 //if any of the possible m's are - throw them out
274 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
275 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
276 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
278 //sharedABC is the minimum of the 3 possibilities
279 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
280 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
281 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }
283 vector<double> data = vCalcs[i]->getValues(lookup);
285 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
286 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
287 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
291 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 800 800\" >\n";
295 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"800\" height=\"800\"/>";
296 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
297 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>";
298 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>";
299 outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>";
301 //place labels within overlaps
302 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"170\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n";
303 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "</text>\n";
304 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedAB[0] - sharedABC).length() / 2)) + "\" y=\"170\">" + toString(sharedAB[0] - sharedABC) + "</text>\n";
305 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)toString(numB[0]-sharedBwithAC[0]).length() / 2)) + "\" y=\"170\">" + toString(numB[0]-sharedBwithAC[0]) + "</text>\n";
306 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"150\">" + lookup[1]->getGroup() + "</text>\n";
307 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(268 - ((int)toString(sharedAC[0] - sharedABC).length() / 2)) + "\" y=\"305\">" + toString(sharedAC[0] - sharedABC) + "</text>\n";
308 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(numC[0]-sharedCwithAB[0]).length() / 2)) + "\" y=\"430\">" + toString(numC[0]-sharedCwithAB[0]) + "</text>\n";
309 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"410\">" + lookup[2]->getGroup() + "</text>\n";
310 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"305\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";
311 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedABC).length() / 2)) + "\" y=\"280\">" + toString(sharedABC) + "</text>\n";
313 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "</text>\n";
314 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "</text>\n";
315 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "</text>\n";
316 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"720\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
317 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"740\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
318 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"760\">The number of sepecies shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
319 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"580\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
320 if (numA.size() == 3) {
321 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
322 }else { outsvg << "</text>\n"; }
324 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"600\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
325 if (numB.size() == 3) {
326 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
327 }else { outsvg << "</text>\n"; }
329 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"620\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
330 if (numC.size() == 3) {
331 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "</text>\n";
332 }else { outsvg << "</text>\n"; }
334 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"640\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "</text>\n";
335 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"780\">The total shared richness is " + toString(sharedABC) + "</text>\n";
338 outsvg << "</g>\n</svg>\n";
344 /******************* 4 Groups **************************/
346 }else if (lookup.size() == 4) {
347 //calc the shared otu
348 float sharedABCD = 0;
349 float numA = 0; float numB = 0; float numC = 0; float numD = 0;
350 float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
351 float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
353 //get sabund vector pointers so you can use the single calculators
355 SAbundVector sA, sB, sC, sD;
356 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
357 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
358 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
359 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
360 sD = lookup[3]->getSAbundVector(); sabundD = &sD;
362 //A = red, B = green, C = blue, D = yellow
364 //make a file for each calculator
365 for(int i=0;i<vCalcs.size();i++){
367 if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); mothurOutEndLine(); }
369 string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
370 openOutputFile(filenamesvg, outsvg);
373 //in essence you want to run it like a single
374 if (vCalcs[i]->getName() == "sharedsobs") {
375 singleCalc = new Sobs();
376 }else if (vCalcs[i]->getName() == "sharedchao") {
377 singleCalc = new Chao1();
380 //get estimates for numA
381 data = singleCalc->getValues(sabundA);
384 //get estimates for numB
385 data = singleCalc->getValues(sabundB);
388 //get estimates for numC
389 data = singleCalc->getValues(sabundC);
392 //get estimates for numD
393 data = singleCalc->getValues(sabundD);
397 //get estimates for pairs
399 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
400 data = vCalcs[i]->getValues(subset);
404 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
405 data = vCalcs[i]->getValues(subset);
409 subset.push_back(lookup[0]); subset.push_back(lookup[3]);
410 data = vCalcs[i]->getValues(subset);
414 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
415 data = vCalcs[i]->getValues(subset);
419 subset.push_back(lookup[1]); subset.push_back(lookup[3]);
420 data = vCalcs[i]->getValues(subset);
424 subset.push_back(lookup[2]); subset.push_back(lookup[3]);
425 data = vCalcs[i]->getValues(subset);
429 //get estimates for combos of 3
431 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
432 data = vCalcs[i]->getValues(subset);
436 subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
437 data = vCalcs[i]->getValues(subset);
441 subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
442 data = vCalcs[i]->getValues(subset);
446 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
447 data = vCalcs[i]->getValues(subset);
450 //get estimate for all four
451 data = vCalcs[i]->getValues(lookup);
452 sharedABCD = data[0];
456 outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
460 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
461 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
462 outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
463 outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
464 outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 440 315) \" cx=\"440\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
465 outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 270 315) \" cx=\"270\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
467 //A = red, B = green, C = blue, D = yellow
469 //place labels within overlaps
470 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)toString(numA).length() / 2)) + "\" y=\"110\">" + toString(numA) + "</text>\n";
471 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[0]->getGroup() + "</text>\n";
472 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedAB).length() / 2)) + "\" y=\"160\">" + toString(sharedAB) + "</text>\n";
473 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)toString(numB).length() / 2)) + "\" y=\"110\">" + toString(numB) + "</text>\n";
474 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[1]->getGroup() + "</text>\n";
475 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(sharedAC).length() / 2)) + "\" y=\"190\">" + toString(sharedAC) + "</text>\n";
476 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(550 - ((int)toString(numC).length() / 2)) + "\" y=\"230\">" + toString(numC) + "</text>\n";
477 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(550 - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"210\">" + lookup[2]->getGroup() + "</text>\n";
478 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(215 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"190\">" + toString(sharedBC) + "</text>\n";
479 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(150 - ((int)toString(numD).length() / 2)) + "\" y=\"230\">" + toString(numD) + "</text>\n";
480 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(150 - ((int)lookup[3]->getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "</text>\n";
481 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n";
482 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedBD) + "</text>\n";
483 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedCD).length() / 2)) + "\" y=\"430\">" + toString(sharedCD) + "</text>\n";
484 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(275 - ((int)toString(sharedABD).length() / 2)) + "\" y=\"240\">" + toString(sharedABD) + "</text>\n";
485 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(400 - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"360\">" + toString(sharedBCD) + "</text>\n";
486 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(305 - ((int)toString(sharedACD).length() / 2)) + "\" y=\"360\">" + toString(sharedACD) + "</text>\n";
487 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(440 - ((int)toString(sharedABC).length() / 2)) + "\" y=\"240\">" + toString(sharedABC) + "</text>\n";
488 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedABCD).length() / 2)) + "\" y=\"320\">" + toString(sharedABCD) + "</text>\n";
489 outsvg << "<text fill=\"black\" class=\"seri\" x=\"250\" y=\"490\">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)) + "</text>\n";
491 outsvg << "</g>\n</svg>\n";
499 catch(exception& e) {
500 errorOut(e, "Venn", "getPic");