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 //**********************************************************************************************************************
19 Venn::Venn(string o) : outputDir(o) {
21 globaldata = GlobalData::getInstance();
22 m = MothurOut::getInstance();
26 m->errorOut(e, "Venn", "Venn");
30 //**********************************************************************************************************************
31 vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
34 vector<string> outputNames;
36 for(int i=0;i<vCalcs.size();i++){
37 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg";
38 outputNames.push_back(filenamesvg);
39 openOutputFile(filenamesvg, outsvg);
41 if (m->control_pressed) { outsvg.close(); return outputNames; }
43 vector<double> data = vCalcs[i]->getValues(sabund);
49 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";
52 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
53 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
54 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)) + "\"/>";
55 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString((width / 2) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(data[0]) + "</text>\n";
57 if (data.size() == 3) {
58 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
59 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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 << "</g>\n</svg>\n";
69 m->errorOut(e, "Venn", "getPic");
73 //**********************************************************************************************************************
74 vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
77 vector<SharedRAbundVector*> subset;
78 vector<string> outputNames;
83 /******************* 1 Group **************************/
84 if (lookup.size() == 1) {
87 s = lookup[0]->getSAbundVector(); SAbundVector* sabund = &s;
89 //make a file for each calculator
90 for(int i=0;i<vCalcs.size();i++){
91 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
92 outputNames.push_back(filenamesvg);
93 openOutputFile(filenamesvg, outsvg);
95 if (m->control_pressed) { outsvg.close(); return outputNames; }
97 //in essence you want to run it like a single
98 if (vCalcs[i]->getName() == "sharedsobs") {
99 singleCalc = new Sobs();
100 }else if (vCalcs[i]->getName() == "sharedchao") {
101 singleCalc = new Chao1();
102 }else if (vCalcs[i]->getName() == "sharedace") {
103 singleCalc = new Ace(10);
106 vector<double> data = singleCalc->getValues(sabund);
109 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";
112 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
113 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
114 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)) + "\"/>";
115 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.50 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
116 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.50 * width) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(data[0]) + "</text>\n";
118 if (data.size() == 3) {
119 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
120 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
123 outsvg << "</g>\n</svg>\n";
128 /******************* 2 Groups **************************/
130 }else if (lookup.size() == 2) {
131 //get sabund vector pointers so you can use the single calculators
134 SAbundVector* sabundA; SAbundVector* sabundB;
135 sabundA = new SAbundVector(lookup[0]->getSAbundVector());// sabundA = &sA;
136 sabundB = new SAbundVector(lookup[1]->getSAbundVector());// sabundB = &sB;
139 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
141 //make a file for each calculator
142 for(int i=0;i<vCalcs.size();i++){
143 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
144 outputNames.push_back(filenamesvg);
145 openOutputFile(filenamesvg, outsvg);
147 if (m->control_pressed) { outsvg.close(); return outputNames; }
149 //get estimates for sharedAB
150 vector<double> shared = vCalcs[i]->getValues(subset);
152 //in essence you want to run it like a single
153 if (vCalcs[i]->getName() == "sharedsobs") {
154 singleCalc = new Sobs();
155 }else if (vCalcs[i]->getName() == "sharedchao") {
156 singleCalc = new Chao1();
157 }//else if (vCalcs[i]->getName() == "sharedace") {
158 //singleCalc = new Ace(10);
161 //get estimates for numA
162 vector<double> numA = singleCalc->getValues(sabundA);
164 //get estimates for numB
165 vector<double> numB = singleCalc->getValues(sabundB);
168 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";
172 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
173 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
174 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)) + "\"/>";
175 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)) + "\"/>";
176 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
177 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
178 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
179 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
180 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(shared[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(shared[0]) + "</text>\n";
181 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
182 if (numA.size() == 3) {
183 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
184 }else { outsvg << "</text>\n"; }
186 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
187 if (numB.size() == 3) {
188 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
189 }else { outsvg << "</text>\n"; }
191 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
192 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
193 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
196 outsvg << "</g>\n</svg>\n";
200 /******************* 3 Groups **************************/
202 }else if (lookup.size() == 3) {
206 //get sabund vector pointers so you can use the single calculators
208 SAbundVector sA, sB, sC;
209 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
210 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
211 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
212 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
214 //make a file for each calculator
215 for(int i=0;i<vCalcs.size();i++){
217 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
218 outputNames.push_back(filenamesvg);
219 openOutputFile(filenamesvg, outsvg);
221 if (m->control_pressed) { outsvg.close(); return outputNames; }
223 if (vCalcs[i]->getName() == "sharedace") {
225 singleCalc = new Ace(10);
227 //get estimates for numA
228 vector<double> numA = singleCalc->getValues(sabundA);
230 //get estimates for numB
231 vector<double> numB = singleCalc->getValues(sabundB);
233 //get estimates for numC
234 vector<double> numC = singleCalc->getValues(sabundC);
237 //get estimates for sharedAB, sharedAC and sharedBC
239 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
240 vector<double> sharedAB = vCalcs[i]->getValues(subset);
243 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
244 vector<double> sharedAC = vCalcs[i]->getValues(subset);
247 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
248 vector<double> sharedBC = vCalcs[i]->getValues(subset);
250 vector<double> sharedAwithBC;
251 vector<double> sharedBwithAC;
252 vector<double> sharedCwithAB;
254 //find possible sharedABC values
255 float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
257 if (vCalcs[i]->getMultiple() == false) {
258 //merge BC and estimate with shared with A
259 SharedRAbundVector* merge = new SharedRAbundVector();
260 for (int j = 0; j < lookup[1]->size(); j++) {
261 merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
265 subset.push_back(lookup[0]); subset.push_back(merge);
266 sharedAwithBC = vCalcs[i]->getValues(subset);
269 //merge AC and estimate with shared with B
270 merge = new SharedRAbundVector();
271 for (int j = 0; j < lookup[0]->size(); j++) {
272 merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
276 subset.push_back(merge); subset.push_back(lookup[1]);
277 sharedBwithAC = vCalcs[i]->getValues(subset);
280 //merge AB and estimate with shared with C
281 merge = new SharedRAbundVector();
282 for (int j = 0; j < lookup[0]->size(); j++) {
283 merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
287 subset.push_back(lookup[2]); subset.push_back(merge);
288 sharedCwithAB = vCalcs[i]->getValues(subset);
291 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
292 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
293 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
295 //if any of the possible m's are - throw them out
296 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
297 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
298 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
300 //sharedABC is the minimum of the 3 possibilities
301 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
302 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
303 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }
305 vector<double> data = vCalcs[i]->getValues(lookup);
307 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
308 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
309 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
313 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";
317 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
318 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.44 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
319 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)) + "\"/>";
320 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)) + "\"/>";
321 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)) + "\"/>";
323 //place labels within overlaps
324 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
325 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.33 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
326 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
327 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
328 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
329 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
330 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
331 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.52 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
332 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
333 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.34 * height)) + "\">" + toString(sharedABC) + "</text>\n";
335 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
336 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
337 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
338 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
339 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
340 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
341 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
342 if (numA.size() == 3) {
343 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
344 }else { outsvg << "</text>\n"; }
346 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
347 if (numB.size() == 3) {
348 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
349 }else { outsvg << "</text>\n"; }
351 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
352 if (numC.size() == 3) {
353 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "</text>\n";
354 }else { outsvg << "</text>\n"; }
356 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
357 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.975 * height)) + "\">The total shared richness is " + toString(sharedABC) + "</text>\n";
361 }else { //sharedchao and sharedsobs are multigroup
363 vector<SharedRAbundVector*> subset;
365 //get estimates for numA
366 subset.push_back(lookup[0]);
367 vector<double> numA = vCalcs[i]->getValues(subset);
369 //get estimates for numB
371 subset.push_back(lookup[1]);
372 vector<double> numB = vCalcs[i]->getValues(subset);
374 //get estimates for numC
376 subset.push_back(lookup[2]);
377 vector<double> numC = vCalcs[i]->getValues(subset);
380 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
381 vector<double> sharedab = vCalcs[i]->getValues(subset);
384 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
385 vector<double> sharedac = vCalcs[i]->getValues(subset);
388 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
389 vector<double> sharedbc = vCalcs[i]->getValues(subset);
392 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
393 vector<double> sharedabc = vCalcs[i]->getValues(subset);
396 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";
400 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
401 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
402 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)) + "\"/>";
403 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)) + "\"/>";
404 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)) + "\"/>";
406 //place labels within overlaps
407 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
408 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
409 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
410 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
411 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.68 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
412 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
413 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
414 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.51 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
415 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
416 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.35 * height)) + "\">" + toString(sharedabc[0]) + "</text>\n";
418 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
419 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
420 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]) + "</text>\n";
421 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
422 if (numA.size() == 3) {
423 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
424 }else { outsvg << "</text>\n"; }
426 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
427 if (numB.size() == 3) {
428 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
429 }else { outsvg << "</text>\n"; }
431 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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]);
432 if (numC.size() == 3) {
433 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "</text>\n";
434 }else { outsvg << "</text>\n"; }
436 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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";
437 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The total shared richness is " + toString(sharedabc[0]) + "</text>\n";
444 outsvg << "</g>\n</svg>\n";
450 /******************* 4 Groups **************************/
452 }else if (lookup.size() == 4) {
456 //calc the shared otu
457 float sharedABCD = 0;
458 float numA = 0; float numB = 0; float numC = 0; float numD = 0;
459 float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
460 float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
462 //get sabund vector pointers so you can use the single calculators
464 SAbundVector sA, sB, sC, sD;
465 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
466 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
467 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
468 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
469 sD = lookup[3]->getSAbundVector(); sabundD = &sD;
471 //A = red, B = green, C = blue, D = yellow
473 //make a file for each calculator
474 for(int i=0;i<vCalcs.size();i++){
476 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(); }
478 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
479 outputNames.push_back(filenamesvg);
480 openOutputFile(filenamesvg, outsvg);
482 if (m->control_pressed) { outsvg.close(); return outputNames; }
484 //in essence you want to run it like a single
485 if (vCalcs[i]->getName() == "sharedsobs") {
486 singleCalc = new Sobs();
487 }else if (vCalcs[i]->getName() == "sharedchao") {
488 singleCalc = new Chao1();
491 //get estimates for numA
492 data = singleCalc->getValues(sabundA);
494 //cout << "num a = " << numA << endl;
496 //get estimates for numB
497 data = singleCalc->getValues(sabundB);
499 //cout << "num b = " << numB << endl;
500 //get estimates for numC
501 data = singleCalc->getValues(sabundC);
503 //cout << "num c = " << numC << endl;
504 //get estimates for numD
505 data = singleCalc->getValues(sabundD);
507 //cout << "num d = " << numD << endl;
509 //get estimates for pairs
511 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
512 data = vCalcs[i]->getValues(subset);
514 //cout << "num ab = " << sharedAB << endl;
516 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
517 data = vCalcs[i]->getValues(subset);
519 //cout << "num ac = " << sharedAC << endl;
521 subset.push_back(lookup[0]); subset.push_back(lookup[3]);
522 data = vCalcs[i]->getValues(subset);
524 //cout << "num ad = " << sharedAD << endl;
526 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
527 data = vCalcs[i]->getValues(subset);
529 //cout << "num bc = " << sharedBC << endl;
531 subset.push_back(lookup[1]); subset.push_back(lookup[3]);
532 data = vCalcs[i]->getValues(subset);
534 //cout << "num bd = " << sharedBD << endl;
536 subset.push_back(lookup[2]); subset.push_back(lookup[3]);
537 data = vCalcs[i]->getValues(subset);
540 //cout << "num cd = " << sharedCD << endl;
541 //get estimates for combos of 3
543 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
544 data = vCalcs[i]->getValues(subset);
546 //cout << "num abc = " << sharedABC << endl;
548 subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
549 data = vCalcs[i]->getValues(subset);
551 //cout << "num acd = " << sharedACD << endl;
553 subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
554 data = vCalcs[i]->getValues(subset);
556 //cout << "num bcd = " << sharedBCD << endl;
558 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
559 data = vCalcs[i]->getValues(subset);
561 //cout << "num abd = " << sharedABD << endl;
562 //get estimate for all four
563 data = vCalcs[i]->getValues(lookup);
564 sharedABCD = data[0];
565 //cout << "num abcd = " << sharedABCD << endl << endl;
570 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";
572 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
573 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\" >Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
575 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.625 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA) + "</text>\n";
576 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.65 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB) + "</text>\n";
577 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.675 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC) + "</text>\n";
578 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.7 * height)) + "\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD) + "</text>\n";
580 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
581 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
582 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
583 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
584 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
585 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
587 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
588 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
589 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
590 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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) + "</text>\n";
593 sharedABC = sharedABC - sharedABCD;
594 //cout << "num abc = " << sharedABC << endl;
595 sharedABD = sharedABD - sharedABCD;
596 //cout << "num abd = " << sharedABD << endl;
597 sharedACD = sharedACD - sharedABCD;
598 //cout << "num acd = " << sharedACD << endl;
599 sharedBCD = sharedBCD - sharedABCD;
600 //cout << "num bcd = " << sharedBCD << endl;
602 sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD; //cout << "num ab = " << sharedAB << endl;
603 sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD; //cout << "num ac = " << sharedAC << endl;
604 sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD; //cout << "num ad = " << sharedAD << endl;
605 sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD; //cout << "num bc = " << sharedBC << endl;
606 sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl;
607 sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD; //cout << "num cd = " << sharedCD << endl;
609 numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
610 //cout << "num a = " << numA << endl;
611 numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
612 //cout << "num b = " << numB << endl;
613 numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
614 //cout << "num c = " << numC << endl;
615 numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
616 //cout << "num d = " << numD << endl;
619 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 ";
620 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 ";
621 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 ";
622 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 ";
624 //A = red, B = green, C = blue, D = yellow
626 //place labels within overlaps
627 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.66 * width) - ((int)toString(numA).length() / 2)) + "\" y=\"" + toString(int(0.14 * height)) + "\">" + toString(numA) + "</text>\n";
628 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.66 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
629 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB).length() / 2)) + "\" y=\"" + toString(int(0.2 * height)) + "\">" + toString(sharedAB) + "</text>\n";
630 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.36 * width) - ((int)toString(numB).length() / 2)) + "\" y=\"" + toString(int(0.14 * height)) + "\">" + toString(numB) + "</text>\n";
631 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.36 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
632 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)toString(sharedAC).length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + toString(sharedAC) + "</text>\n";
633 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.785 * width) - ((int)toString(numC).length() / 2)) + "\" y=\"" + toString(int(0.29 * height)) + "\">" + toString(numC) + "</text>\n";
634 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.785 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
635 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.31 * width) - ((int)toString(sharedBD).length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + toString(sharedBD) + "</text>\n";
636 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.22 * width) - ((int)toString(numD).length() / 2)) + "\" y=\"" + toString(int(0.29 * height)) + "\">" + toString(numD) + "</text>\n";
637 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.22 * width) - ((int)lookup[3]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[3]->getGroup() + "</text>\n";
638 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.34 * width) - ((int)toString(sharedAD).length() / 2)) + "\" y=\"" + toString(int(0.41 * height)) + "\">" + toString(sharedAD) + "</text>\n";
639 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.675 * width) - ((int)toString(sharedBC).length() / 2)) + "\" y=\"" + toString(int(0.41 * height)) + "\">" + toString(sharedBC) + "</text>\n";
640 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedCD).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(sharedCD) + "</text>\n";
641 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.39 * width) - ((int)toString(sharedABD).length() / 2)) + "\" y=\"" + toString(int(0.3 * height)) + "\">" + toString(sharedABD) + "</text>\n";
642 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.57 * width) - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"" + toString(int(0.45 * height)) + "\">" + toString(sharedBCD) + "</text>\n";
643 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.435 * width) - ((int)toString(sharedACD).length() / 2)) + "\" y=\"" + toString(int(0.45 * height)) + "\">" + toString(sharedACD) + "</text>\n";
644 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.63 * width) - ((int)toString(sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.3 * height)) + "\">" + toString(sharedABC) + "</text>\n";
645 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABCD).length() / 2)) + "\" y=\"" + toString(int(0.4 * height)) + "\">" + toString(sharedABCD) + "</text>\n";
649 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" 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)) + "</text>\n";
652 outsvg << "</g>\n</svg>\n";
662 catch(exception& e) {
663 m->errorOut(e, "Venn", "getPic");