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) : outputDir(o), nseqs(n) {
22 globaldata = GlobalData::getInstance();
23 m = MothurOut::getInstance();
27 m->errorOut(e, "Venn", "Venn");
31 //**********************************************************************************************************************
32 vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
35 vector<string> outputNames;
37 for(int i=0;i<vCalcs.size();i++){
38 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
39 outputNames.push_back(filenamesvg);
40 m->openOutputFile(filenamesvg, outsvg);
42 if (m->control_pressed) { outsvg.close(); return outputNames; }
44 vector<double> data = vCalcs[i]->getValues(sabund);
50 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";
53 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
54 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";
55 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)) + "\"/>";
56 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";
58 if (data.size() == 3) {
59 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";
60 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";
64 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.70 * height)) + "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
67 outsvg << "</g>\n</svg>\n";
74 m->errorOut(e, "Venn", "getPic");
78 //**********************************************************************************************************************
79 vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
82 vector<SharedRAbundVector*> subset;
83 vector<string> outputNames;
88 /******************* 1 Group **************************/
89 if (lookup.size() == 1) {
92 s = lookup[0]->getSAbundVector(); SAbundVector* sabund = &s;
94 //make a file for each calculator
95 for(int i=0;i<vCalcs.size();i++){
96 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
97 outputNames.push_back(filenamesvg);
98 m->openOutputFile(filenamesvg, outsvg);
100 if (m->control_pressed) { outsvg.close(); return outputNames; }
102 //in essence you want to run it like a single
103 if (vCalcs[i]->getName() == "sharedsobs") {
104 singleCalc = new Sobs();
105 }else if (vCalcs[i]->getName() == "sharedchao") {
106 singleCalc = new Chao1();
107 }else if (vCalcs[i]->getName() == "sharedace") {
108 singleCalc = new Ace(10);
111 vector<double> data = singleCalc->getValues(sabund);
114 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";
117 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
118 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";
119 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)) + "\"/>";
120 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";
121 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";
123 if (data.size() == 3) {
124 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";
125 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";
129 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.70 * height)) + "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
132 outsvg << "</g>\n</svg>\n";
137 /******************* 2 Groups **************************/
139 }else if (lookup.size() == 2) {
140 //get sabund vector pointers so you can use the single calculators
143 SAbundVector* sabundA; SAbundVector* sabundB;
144 sabundA = new SAbundVector(lookup[0]->getSAbundVector());// sabundA = &sA;
145 sabundB = new SAbundVector(lookup[1]->getSAbundVector());// sabundB = &sB;
148 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
150 //make a file for each calculator
151 for(int i=0;i<vCalcs.size();i++){
152 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
154 outputNames.push_back(filenamesvg);
155 m->openOutputFile(filenamesvg, outsvg);
157 if (m->control_pressed) { outsvg.close(); return outputNames; }
159 //get estimates for sharedAB
160 vector<double> shared = vCalcs[i]->getValues(subset);
162 //in essence you want to run it like a single
163 if (vCalcs[i]->getName() == "sharedsobs") {
164 singleCalc = new Sobs();
165 }else if (vCalcs[i]->getName() == "sharedchao") {
166 singleCalc = new Chao1();
167 }//else if (vCalcs[i]->getName() == "sharedace") {
168 //singleCalc = new Ace(10);
171 int sharedVal, numSeqsA, numSeqsB;
173 NSeqs* nseqsCalc = new NSeqs();
174 vector<double> data = nseqsCalc->getValues(lookup);
176 sharedVal = data[0] + data[1];
177 numSeqsA = sabundA->getNumSeqs();
178 numSeqsB = sabundB->getNumSeqs();
184 //get estimates for numA
185 vector<double> numA = singleCalc->getValues(sabundA);
187 //get estimates for numB
188 vector<double> numB = singleCalc->getValues(sabundB);
191 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";
195 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
196 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";
197 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)) + "\"/>";
198 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)) + "\"/>";
199 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";
200 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";
201 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";
202 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";
203 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";
204 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]);
205 if (numA.size() == 3) {
206 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
208 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
209 outsvg << "</text>\n";
211 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]);
212 if (numB.size() == 3) {
213 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
215 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
216 outsvg << "</text>\n";
218 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]);
219 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
220 outsvg << "</text>\n";
222 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";
223 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";;
227 outsvg << "</g>\n</svg>\n";
231 /******************* 3 Groups **************************/
233 }else if (lookup.size() == 3) {
236 int windowSize = height;
239 //get sabund vector pointers so you can use the single calculators
241 SAbundVector sA, sB, sC;
242 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
243 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
244 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
245 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
247 //make a file for each calculator
248 for(int i=0;i<vCalcs.size();i++){
250 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
252 outputNames.push_back(filenamesvg);
253 m->openOutputFile(filenamesvg, outsvg);
255 if (m->control_pressed) { outsvg.close(); return outputNames; }
257 int sharedVal, sharedABVal, sharedACVal, sharedBCVal, numSeqsA, numSeqsB, numSeqsC;
260 NSeqs* nseqsCalc = new NSeqs();
261 vector<double> sharedData = nseqsCalc->getValues(lookup);
263 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
264 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
266 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
267 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
269 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
270 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
272 sharedVal = sharedData[0] + sharedData[1] + sharedData[2];
273 sharedABVal = sharedAB[0] + sharedAB[1];
274 sharedACVal = sharedAC[0] + sharedAC[1];
275 sharedBCVal = sharedBC[0] + sharedBC[1];
276 numSeqsA = sabundA->getNumSeqs();
277 numSeqsB = sabundB->getNumSeqs();
278 numSeqsC = sabundC->getNumSeqs();
284 if (vCalcs[i]->getName() == "sharedace") {
286 singleCalc = new Ace(10);
288 //get estimates for numA
289 vector<double> numA = singleCalc->getValues(sabundA);
291 //get estimates for numB
292 vector<double> numB = singleCalc->getValues(sabundB);
294 //get estimates for numC
295 vector<double> numC = singleCalc->getValues(sabundC);
298 //get estimates for sharedAB, sharedAC and sharedBC
300 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
301 vector<double> sharedAB = vCalcs[i]->getValues(subset);
304 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
305 vector<double> sharedAC = vCalcs[i]->getValues(subset);
308 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
309 vector<double> sharedBC = vCalcs[i]->getValues(subset);
311 vector<double> sharedAwithBC;
312 vector<double> sharedBwithAC;
313 vector<double> sharedCwithAB;
315 //find possible sharedABC values
316 float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
318 if (vCalcs[i]->getMultiple() == false) {
319 //merge BC and estimate with shared with A
320 SharedRAbundVector* merge = new SharedRAbundVector();
321 for (int j = 0; j < lookup[1]->size(); j++) {
322 merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
326 subset.push_back(lookup[0]); subset.push_back(merge);
327 sharedAwithBC = vCalcs[i]->getValues(subset);
330 //merge AC and estimate with shared with B
331 merge = new SharedRAbundVector();
332 for (int j = 0; j < lookup[0]->size(); j++) {
333 merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
337 subset.push_back(merge); subset.push_back(lookup[1]);
338 sharedBwithAC = vCalcs[i]->getValues(subset);
341 //merge AB and estimate with shared with C
342 merge = new SharedRAbundVector();
343 for (int j = 0; j < lookup[0]->size(); j++) {
344 merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
348 subset.push_back(lookup[2]); subset.push_back(merge);
349 sharedCwithAB = vCalcs[i]->getValues(subset);
352 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
353 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
354 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
356 //if any of the possible m's are - throw them out
357 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
358 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
359 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
361 //sharedABC is the minimum of the 3 possibilities
362 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
363 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
364 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }
366 vector<double> data = vCalcs[i]->getValues(lookup);
368 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
369 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
370 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
374 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";
378 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
379 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";
380 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)) + "\"/>";
381 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)) + "\"/>";
382 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)) + "\"/>";
384 //place labels within overlaps
385 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";
386 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";
387 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";
388 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";
389 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";
390 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";
391 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";
392 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";
393 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";
394 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";
396 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]);
397 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
398 outsvg << "</text>\n";
399 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]);
400 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
401 outsvg << "</text>\n";
402 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]);
403 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
404 outsvg << "</text>\n";
405 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";
406 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";
407 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";
408 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]);
409 if (numA.size() == 3) {
410 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
412 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
413 outsvg << "</text>\n";
415 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]);
416 if (numB.size() == 3) {
417 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
419 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
420 outsvg << "</text>\n";
422 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]);
423 if (numC.size() == 3) {
424 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
426 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
427 outsvg << "</text>\n";
429 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";
430 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);
431 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
432 outsvg << "</text>\n";
436 }else { //sharedchao and sharedsobs are multigroup
438 vector<SharedRAbundVector*> subset;
440 //get estimates for numA
441 subset.push_back(lookup[0]);
442 vector<double> numA = vCalcs[i]->getValues(subset);
444 //get estimates for numB
446 subset.push_back(lookup[1]);
447 vector<double> numB = vCalcs[i]->getValues(subset);
449 //get estimates for numC
451 subset.push_back(lookup[2]);
452 vector<double> numC = vCalcs[i]->getValues(subset);
455 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
456 vector<double> sharedab = vCalcs[i]->getValues(subset);
459 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
460 vector<double> sharedac = vCalcs[i]->getValues(subset);
463 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
464 vector<double> sharedbc = vCalcs[i]->getValues(subset);
467 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
468 vector<double> sharedabc = vCalcs[i]->getValues(subset);
471 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";
475 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
476 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";
477 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)) + "\"/>";
478 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)) + "\"/>";
479 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)) + "\"/>";
481 //place labels within overlaps
482 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";
483 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";
484 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";
485 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";
486 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";
487 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";
488 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";
489 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";
490 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";
491 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";
493 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]);
494 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
495 outsvg << "</text>\n";
496 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]);
497 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
498 outsvg << "</text>\n";
499 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]);
500 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
501 outsvg << "</text>\n";
503 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]);
504 if (numA.size() == 3) {
505 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
507 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
508 outsvg << "</text>\n";
510 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]);
511 if (numB.size() == 3) {
512 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
514 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
515 outsvg << "</text>\n";
517 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]);
518 if (numC.size() == 3) {
519 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
521 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
522 outsvg << "</text>\n";
524 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";
525 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]);
526 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
527 outsvg << "</text>\n";
532 outsvg << "</g>\n</svg>\n";
538 /******************* 4 Groups **************************/
540 }else if (lookup.size() == 4) {
544 int windowSize = height;
546 //calc the shared otu
547 float sharedABCD = 0;
548 float numA = 0; float numB = 0; float numC = 0; float numD = 0;
549 float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
550 float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
552 //get sabund vector pointers so you can use the single calculators
554 SAbundVector sA, sB, sC, sD;
555 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
556 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
557 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
558 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
559 sD = lookup[3]->getSAbundVector(); sabundD = &sD;
561 //A = red, B = green, C = blue, D = yellow
563 //make a file for each calculator
564 for(int i=0;i<vCalcs.size();i++){
566 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(); }
568 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
569 outputNames.push_back(filenamesvg);
570 m->openOutputFile(filenamesvg, outsvg);
572 if (m->control_pressed) { outsvg.close(); return outputNames; }
574 //in essence you want to run it like a single
575 if (vCalcs[i]->getName() == "sharedsobs") {
576 singleCalc = new Sobs();
577 }else if (vCalcs[i]->getName() == "sharedchao") {
578 singleCalc = new Chao1();
581 //get estimates for numA
582 data = singleCalc->getValues(sabundA);
584 //cout << "num a = " << numA << endl;
586 //get estimates for numB
587 data = singleCalc->getValues(sabundB);
589 //cout << "num b = " << numB << endl;
590 //get estimates for numC
591 data = singleCalc->getValues(sabundC);
593 //cout << "num c = " << numC << endl;
594 //get estimates for numD
595 data = singleCalc->getValues(sabundD);
597 //cout << "num d = " << numD << endl;
599 //get estimates for pairs
601 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
602 data = vCalcs[i]->getValues(subset);
604 //cout << "num ab = " << sharedAB << endl;
606 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
607 data = vCalcs[i]->getValues(subset);
609 //cout << "num ac = " << sharedAC << endl;
611 subset.push_back(lookup[0]); subset.push_back(lookup[3]);
612 data = vCalcs[i]->getValues(subset);
614 //cout << "num ad = " << sharedAD << endl;
616 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
617 data = vCalcs[i]->getValues(subset);
619 //cout << "num bc = " << sharedBC << endl;
621 subset.push_back(lookup[1]); subset.push_back(lookup[3]);
622 data = vCalcs[i]->getValues(subset);
624 //cout << "num bd = " << sharedBD << endl;
626 subset.push_back(lookup[2]); subset.push_back(lookup[3]);
627 data = vCalcs[i]->getValues(subset);
630 //cout << "num cd = " << sharedCD << endl;
631 //get estimates for combos of 3
633 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
634 data = vCalcs[i]->getValues(subset);
636 //cout << "num abc = " << sharedABC << endl;
638 subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
639 data = vCalcs[i]->getValues(subset);
641 //cout << "num acd = " << sharedACD << endl;
643 subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
644 data = vCalcs[i]->getValues(subset);
646 //cout << "num bcd = " << sharedBCD << endl;
648 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
649 data = vCalcs[i]->getValues(subset);
651 //cout << "num abd = " << sharedABD << endl;
652 //get estimate for all four
653 data = vCalcs[i]->getValues(lookup);
654 sharedABCD = data[0];
655 //cout << "num abcd = " << sharedABCD << endl << endl;
656 int sharedVal, sharedABCVal, sharedABDVal, sharedACDVal, sharedBCDVal, sharedABVal, sharedACVal, sharedADVal, sharedBCVal, sharedBDVal, sharedCDVal, numSeqsA, numSeqsB, numSeqsC, numSeqsD;
659 NSeqs* nseqsCalc = new NSeqs();
660 vector<double> sharedData = nseqsCalc->getValues(lookup);
662 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
663 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
665 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
666 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
668 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[3]);
669 vector<double> sharedAD = nseqsCalc->getValues(mysubset);
671 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
672 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
674 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
675 vector<double> sharedBD = nseqsCalc->getValues(mysubset);
677 mysubset.clear(); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
678 vector<double> sharedCD = nseqsCalc->getValues(mysubset);
680 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
681 vector<double> sharedABC = nseqsCalc->getValues(mysubset);
683 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
684 vector<double> sharedABD = nseqsCalc->getValues(mysubset);
686 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
687 vector<double> sharedACD = nseqsCalc->getValues(mysubset);
689 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
690 vector<double> sharedBCD = nseqsCalc->getValues(mysubset);
692 sharedVal = sharedData[0] + sharedData[1] + sharedData[2] + sharedData[3];
693 sharedABCVal = sharedABC[0] + sharedABC[1] + sharedABC[2];
694 sharedABDVal = sharedABD[0] + sharedABD[1] + sharedABD[2];
695 sharedACDVal = sharedACD[0] + sharedACD[1] + sharedACD[2];
696 sharedBCDVal = sharedBCD[0] + sharedBCD[1] + sharedBCD[2];
697 sharedABVal = sharedAB[0] + sharedAB[1];
698 sharedACVal = sharedAC[0] + sharedAC[1];
699 sharedADVal = sharedAD[0] + sharedAD[1];
700 sharedBCVal = sharedBC[0] + sharedBC[1];
701 sharedBDVal = sharedBD[0] + sharedBD[1];
702 sharedCDVal = sharedCD[0] + sharedCD[1];
703 numSeqsA = sabundA->getNumSeqs();
704 numSeqsB = sabundB->getNumSeqs();
705 numSeqsC = sabundC->getNumSeqs();
706 numSeqsD = sabundD->getNumSeqs();
713 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";
715 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(windowSize) + "\"/>";
716 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";
718 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);
719 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
720 outsvg << "</text>\n";
721 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);
722 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
723 outsvg << "</text>\n";
724 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);
725 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
726 outsvg << "</text>\n";
727 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);
728 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsD); }
729 outsvg << "</text>\n";
731 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);
732 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
733 outsvg << "</text>\n";
734 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);
735 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
736 outsvg << "</text>\n";
737 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);
738 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedADVal); }
739 outsvg << "</text>\n";
740 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);
741 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
742 outsvg << "</text>\n";
743 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);
744 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBDVal); }
745 outsvg << "</text>\n";
746 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);
747 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedCDVal); }
748 outsvg << "</text>\n";
750 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);
751 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABCVal); }
752 outsvg << "</text>\n";
753 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);
754 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABDVal); }
755 outsvg << "</text>\n";
756 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);
757 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACDVal); }
758 outsvg << "</text>\n";
759 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);
760 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCDVal); }
761 outsvg << "</text>\n";
764 sharedABC = sharedABC - sharedABCD;
765 //cout << "num abc = " << sharedABC << endl;
766 sharedABD = sharedABD - sharedABCD;
767 //cout << "num abd = " << sharedABD << endl;
768 sharedACD = sharedACD - sharedABCD;
769 //cout << "num acd = " << sharedACD << endl;
770 sharedBCD = sharedBCD - sharedABCD;
771 //cout << "num bcd = " << sharedBCD << endl;
773 sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD; //cout << "num ab = " << sharedAB << endl;
774 sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD; //cout << "num ac = " << sharedAC << endl;
775 sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD; //cout << "num ad = " << sharedAD << endl;
776 sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD; //cout << "num bc = " << sharedBC << endl;
777 sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl;
778 sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD; //cout << "num cd = " << sharedCD << endl;
780 numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
781 //cout << "num a = " << numA << endl;
782 numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
783 //cout << "num b = " << numB << endl;
784 numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
785 //cout << "num c = " << numC << endl;
786 numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
787 //cout << "num d = " << numD << endl;
790 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 ";
791 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 ";
792 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 ";
793 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 ";
795 //A = red, B = green, C = blue, D = yellow
797 //place labels within overlaps
798 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";
799 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";
800 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";
801 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";
802 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";
803 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";
804 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";
805 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";
806 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";
807 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";
808 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";
809 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";
810 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";
811 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";
812 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";
813 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";
814 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";
815 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";
816 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";
818 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));
819 if (nseqs) { outsvg << ", and the number of squences in the otus shared by all groups is " + toString(sharedVal); }
820 outsvg << "</text>\n";
822 outsvg << "</g>\n</svg>\n";
832 catch(exception& e) {
833 m->errorOut(e, "Venn", "getPic");