5 * Created by Sarah Westcott on 3/30/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
15 #include "sharedchao1.h"
16 #include "sharedsobscollectsummary.h"
19 //**********************************************************************************************************************
20 Venn::Venn(string o, bool n, string f, int fs, bool so) : outputDir(o), nseqs(n), inputfile(f), fontSize(fs), sharedOtus(so) {
22 m = MothurOut::getInstance();
25 m->errorOut(e, "Venn", "Venn");
29 //**********************************************************************************************************************
30 vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
33 vector<string> outputNames;
35 for(int i=0;i<vCalcs.size();i++){
36 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
37 outputNames.push_back(filenamesvg);
38 m->openOutputFile(filenamesvg, outsvg);
40 if (m->control_pressed) { outsvg.close(); return outputNames; }
42 vector<double> data = vCalcs[i]->getValues(sabund);
48 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(height) + " \" >\n";
51 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
52 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
53 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" + toString(int(0.50 * width)) + "\" cy=\"" + toString(int(0.29 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
54 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString((width / 2) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(data[0]) + "</text>\n";
56 if (data.size() == 3) {
57 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.60 * height)) + "\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
58 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.645 * height)) + "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
62 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.70 * height)) + "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
65 outsvg << "</g>\n</svg>\n";
72 m->errorOut(e, "Venn", "getPic");
76 //**********************************************************************************************************************
77 vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
80 vector<SharedRAbundVector*> subset;
81 vector<string> outputNames;
86 /******************* 1 Group **************************/
87 if (lookup.size() == 1) {
90 s = lookup[0]->getSAbundVector(); SAbundVector* sabund = &s;
92 //make a file for each calculator
93 for(int i=0;i<vCalcs.size();i++){
94 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
95 outputNames.push_back(filenamesvg);
96 m->openOutputFile(filenamesvg, outsvg);
98 if (m->control_pressed) { outsvg.close(); return outputNames; }
100 //in essence you want to run it like a single
101 if (vCalcs[i]->getName() == "sharedsobs") {
102 singleCalc = new Sobs();
103 }else if (vCalcs[i]->getName() == "sharedchao") {
104 singleCalc = new Chao1();
105 }else if (vCalcs[i]->getName() == "sharedace") {
106 singleCalc = new Ace(10);
109 vector<double> data = singleCalc->getValues(sabund);
112 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(height) + " \">\n";
115 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
116 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
117 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" + toString(int(0.50 * width)) + "\" cy=\"" + toString(int(0.29 * height)) + "\" r=\"" + toString(int(0.22 * width)) + "\"/>";
118 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.50 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
119 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.50 * width) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(data[0]) + "</text>\n";
121 if (data.size() == 3) {
122 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.60 * height)) + "\" >The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
123 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.645 * height)) + "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
127 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.35 * width)) + "\" y=\"" + toString(int(0.70 * height)) + "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
130 outsvg << "</g>\n</svg>\n";
135 /******************* 2 Groups **************************/
137 }else if (lookup.size() == 2) {
138 //get sabund vector pointers so you can use the single calculators
141 SAbundVector* sabundA; SAbundVector* sabundB;
142 sabundA = new SAbundVector(lookup[0]->getSAbundVector());// sabundA = &sA;
143 sabundB = new SAbundVector(lookup[1]->getSAbundVector());// sabundB = &sB;
146 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
148 //make a file for each calculator
149 for(int i=0;i<vCalcs.size();i++){
150 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
152 outputNames.push_back(filenamesvg);
153 m->openOutputFile(filenamesvg, outsvg);
155 if (m->control_pressed) { outsvg.close(); return outputNames; }
157 //get estimates for sharedAB
158 vector<string> labels;
159 vector<double> shared = vCalcs[i]->getValues(subset, labels);
161 //in essence you want to run it like a single
162 if (vCalcs[i]->getName() == "sharedsobs") {
163 singleCalc = new Sobs();
164 if (sharedOtus && (labels.size() != 0)) {
165 string groupsTag = "";
166 for (int h = 0; h < lookup.size()-1; h++) { groupsTag += lookup[h]->getGroup() + "-"; } groupsTag += lookup[lookup.size()-1]->getGroup();
167 string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + groupsTag + ".sharedotus";
169 outputNames.push_back(filenameShared);
171 m->openOutputFile(filenameShared, outShared);
172 outShared << "Groups\tNumShared\tOTULabels\n";
173 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t' << labels.size() << '\t';
174 for (int k = 0; k < labels.size()-1; k++) {
175 outShared << labels[k] << ",";
177 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
181 }else if (vCalcs[i]->getName() == "sharedchao") {
182 singleCalc = new Chao1();
185 int sharedVal, numSeqsA, numSeqsB, uniqSeqsToA, uniqSeqsToB;
187 NSeqs* nseqsCalc = new NSeqs();
188 vector<double> data = nseqsCalc->getValues(lookup);
189 cout << data[0] << '\t' << data[1] << endl;
190 sharedVal = data[0] + data[1];
191 numSeqsA = sabundA->getNumSeqs();
192 numSeqsB = sabundB->getNumSeqs();
193 uniqSeqsToA = numSeqsA-data[0];
194 uniqSeqsToB = numSeqsB-data[1];
200 //get estimates for numA
201 vector<double> numA = singleCalc->getValues(sabundA);
203 //get estimates for numB
204 vector<double> numB = singleCalc->getValues(sabundB);
207 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";
211 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
212 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
213 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)) + "\"/>";
214 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)) + "\"/>";
215 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(numA[0] - shared[0]) + "</text>\n";
216 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(numB[0] - shared[0]) + "</text>\n";
217 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
218 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
219 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(shared[0]).length() / 2)) + "\" y=\"" + toString(int(0.28 * height)) + "\">" + toString(shared[0]) + "</text>\n";
220 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.66 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
221 if (numA.size() == 3) {
222 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
224 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA) + "; " + toString(uniqSeqsToA) + " sequences are not shared"; }
225 outsvg << "</text>\n";
227 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.69 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
228 if (numB.size() == 3) {
229 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
231 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB) + "; " + toString(uniqSeqsToB) + " sequences are not shared"; }
232 outsvg << "</text>\n";
234 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.72 * height)) + "\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]);
235 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal) + "; " + toString((sharedVal / (float)(numSeqsA + numSeqsB))*100) + "% of these sequences are shared"; }
236 outsvg << "</text>\n";
238 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))*100) + "</text>\n";
240 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.78 * height)) + "\">The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0]))+ "</text>\n";;
244 outsvg << "</g>\n</svg>\n";
248 /******************* 3 Groups **************************/
250 }else if (lookup.size() == 3) {
253 int windowSize = height;
256 //get sabund vector pointers so you can use the single calculators
258 SAbundVector sA, sB, sC;
259 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
260 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
261 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
262 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
264 //make a file for each calculator
265 for(int i=0;i<vCalcs.size();i++){
267 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
269 outputNames.push_back(filenamesvg);
270 m->openOutputFile(filenamesvg, outsvg);
272 if (m->control_pressed) { outsvg.close(); return outputNames; }
274 int sharedVal, sharedABVal, sharedACVal, sharedBCVal, numSeqsA, numSeqsB, numSeqsC, uniqSeqsToA, uniqSeqsToB, uniqSeqsToC;
277 NSeqs* nseqsCalc = new NSeqs();
278 vector<double> sharedData = nseqsCalc->getValues(lookup);
280 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
281 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
283 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
284 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
286 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
287 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
289 sharedVal = sharedData[0] + sharedData[1] + sharedData[2];
290 sharedABVal = sharedAB[0] + sharedAB[1];
291 sharedACVal = sharedAC[0] + sharedAC[1];
292 sharedBCVal = sharedBC[0] + sharedBC[1];
293 numSeqsA = sabundA->getNumSeqs();
294 numSeqsB = sabundB->getNumSeqs();
295 numSeqsC = sabundC->getNumSeqs();
296 uniqSeqsToA = numSeqsA-sharedData[0];
297 uniqSeqsToB = numSeqsC-sharedData[1];
298 uniqSeqsToC = numSeqsB-sharedData[1];
304 if (vCalcs[i]->getName() == "sharedace") {
306 singleCalc = new Ace(10);
308 //get estimates for numA
309 vector<double> numA = singleCalc->getValues(sabundA);
311 //get estimates for numB
312 vector<double> numB = singleCalc->getValues(sabundB);
314 //get estimates for numC
315 vector<double> numC = singleCalc->getValues(sabundC);
318 //get estimates for sharedAB, sharedAC and sharedBC
320 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
321 vector<double> sharedAB = vCalcs[i]->getValues(subset);
324 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
325 vector<double> sharedAC = vCalcs[i]->getValues(subset);
328 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
329 vector<double> sharedBC = vCalcs[i]->getValues(subset);
331 vector<double> sharedAwithBC;
332 vector<double> sharedBwithAC;
333 vector<double> sharedCwithAB;
335 //find possible sharedABC values
336 float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
338 if (vCalcs[i]->getMultiple() == false) {
339 //merge BC and estimate with shared with A
340 SharedRAbundVector* merge = new SharedRAbundVector();
341 for (int j = 0; j < lookup[1]->size(); j++) {
342 merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
346 subset.push_back(lookup[0]); subset.push_back(merge);
347 sharedAwithBC = vCalcs[i]->getValues(subset);
350 //merge AC and estimate with shared with B
351 merge = new SharedRAbundVector();
352 for (int j = 0; j < lookup[0]->size(); j++) {
353 merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
357 subset.push_back(merge); subset.push_back(lookup[1]);
358 sharedBwithAC = vCalcs[i]->getValues(subset);
361 //merge AB and estimate with shared with C
362 merge = new SharedRAbundVector();
363 for (int j = 0; j < lookup[0]->size(); j++) {
364 merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
368 subset.push_back(lookup[2]); subset.push_back(merge);
369 sharedCwithAB = vCalcs[i]->getValues(subset);
372 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
373 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
374 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
376 //if any of the possible m's are - throw them out
377 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
378 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
379 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
381 //sharedABC is the minimum of the 3 possibilities
382 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
383 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
384 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }
386 vector<double> data = vCalcs[i]->getValues(lookup);
388 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
389 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
390 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
394 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";
398 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
399 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.44 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
400 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)) + "\"/>";
401 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)) + "\"/>";
402 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)) + "\"/>";
404 //place labels within overlaps
405 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.33 * width) - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n";
406 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.33 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
407 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB[0] - sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(sharedAB[0] - sharedABC) + "</text>\n";
408 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]-sharedBwithAC[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numB[0]-sharedBwithAC[0]) + "</text>\n";
409 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
410 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedAC[0] - sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedAC[0] - sharedABC) + "</text>\n";
411 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedCwithAB[0]).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(numC[0]-sharedCwithAB[0]) + "</text>\n";
412 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.52 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
413 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.58 * width) - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";
414 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.34 * height)) + "\">" + toString(sharedABC) + "</text>\n";
416 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.825 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]);
417 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
418 outsvg << "</text>\n";
419 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.85 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]);
420 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
421 outsvg << "</text>\n";
422 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.875 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]);
423 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
424 outsvg << "</text>\n";
425 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
426 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.925 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
427 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.95 * height)) + "\">The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
428 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.725 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
429 if (numA.size() == 3) {
430 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
432 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA) + "; " + toString(uniqSeqsToA) + " sequences are not shared"; }
433 outsvg << "</text>\n";
435 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
436 if (numB.size() == 3) {
437 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
439 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB) + "; " + toString(uniqSeqsToB) + " sequences are not shared"; }
440 outsvg << "</text>\n";
442 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.775 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
443 if (numC.size() == 3) {
444 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
446 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC) + "; " + toString(uniqSeqsToC) + " sequences are not shared"; }
447 outsvg << "</text>\n";
449 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.80 * height)) + "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "</text>\n";
450 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.975 * height)) + "\">The total shared richness is " + toString(sharedABC);
451 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
452 outsvg << "</text>\n";
456 }else { //sharedchao and sharedsobs are multigroup
459 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
460 string groupsTag = "";
461 for (int h = 0; h < lookup.size()-1; h++) { groupsTag += lookup[h]->getGroup() + "-"; } groupsTag += lookup[lookup.size()-1]->getGroup();
462 string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + groupsTag + ".sharedotus";
464 outputNames.push_back(filenameShared);
466 m->openOutputFile(filenameShared, outShared);
467 outShared << "Groups\tNumShared\tOTULabels\n";
469 vector<SharedRAbundVector*> subset;
471 //get estimates for numA
472 subset.push_back(lookup[0]);
473 vector<double> numA = vCalcs[i]->getValues(subset);
475 //get estimates for numB
477 subset.push_back(lookup[1]);
478 vector<double> numB = vCalcs[i]->getValues(subset);
480 //get estimates for numC
482 subset.push_back(lookup[2]);
483 vector<double> numC = vCalcs[i]->getValues(subset);
486 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
487 vector<string> labels;
488 vector<double> sharedab = vCalcs[i]->getValues(subset, labels);
489 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
490 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t' << labels.size() << '\t';
491 for (int k = 0; k < labels.size()-1; k++) {
492 outShared << labels[k] << ",";
494 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
499 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
500 vector<double> sharedac = vCalcs[i]->getValues(subset, labels);
501 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
502 outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
503 for (int k = 0; k < labels.size()-1; k++) {
504 outShared << labels[k] << ",";
506 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
511 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
512 vector<double> sharedbc = vCalcs[i]->getValues(subset, labels);
513 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
514 outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
515 for (int k = 0; k < labels.size()-1; k++) {
516 outShared << labels[k] << ",";
518 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
524 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
525 vector<double> sharedabc = vCalcs[i]->getValues(subset, labels);
526 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
527 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
528 for (int k = 0; k < labels.size()-1; k++) {
529 outShared << labels[k] << ",";
531 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
537 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";
541 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(height) + "\"/>";
542 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
543 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)) + "\"/>";
544 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)) + "\"/>";
545 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)) + "\"/>";
547 //place labels within overlaps
548 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "</text>\n";
549 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
550 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedab[0] - sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(sharedab[0] - sharedabc[0]) + "</text>\n";
551 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.68 * width) - ((int)toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.22 * height)) + "\">" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
552 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.68 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
553 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedac[0] - sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedac[0] - sharedabc[0]) + "</text>\n";
554 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
555 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.51 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
556 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.59 * width) - ((int)toString(sharedbc[0] - sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.38 * height)) + "\">" + toString(sharedbc[0] - sharedabc[0]) + "</text>\n";
557 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedabc[0]).length() / 2)) + "\" y=\"" + toString(int(0.35 * height)) + "\">" + toString(sharedabc[0]) + "</text>\n";
559 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.825 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]);
560 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
561 outsvg << "</text>\n";
562 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.85 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]);
563 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
564 outsvg << "</text>\n";
565 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.875 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]);
566 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
567 outsvg << "</text>\n";
569 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.725 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
570 if (numA.size() == 3) {
571 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
573 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
574 outsvg << "</text>\n";
576 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
577 if (numB.size() == 3) {
578 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
580 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
581 outsvg << "</text>\n";
583 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.775 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
584 if (numC.size() == 3) {
585 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
587 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
588 outsvg << "</text>\n";
590 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.8 * height)) + "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedab[0] - sharedac[0] - sharedbc[0] + sharedabc[0]) + "</text>\n";
591 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The total shared richness is " + toString(sharedabc[0]);
592 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedVal); }
593 outsvg << "</text>\n";
598 outsvg << "</g>\n</svg>\n";
604 /******************* 4 Groups **************************/
606 }else if (lookup.size() == 4) {
610 int windowSize = height;
612 //calc the shared otu
613 float sharedABCD = 0;
614 float numA = 0; float numB = 0; float numC = 0; float numD = 0;
615 float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
616 float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
618 //get sabund vector pointers so you can use the single calculators
620 SAbundVector sA, sB, sC, sD;
621 SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
622 sA = lookup[0]->getSAbundVector(); sabundA = &sA;
623 sB = lookup[1]->getSAbundVector(); sabundB = &sB;
624 sC = lookup[2]->getSAbundVector(); sabundC = &sC;
625 sD = lookup[3]->getSAbundVector(); sabundD = &sD;
627 //A = red, B = green, C = blue, D = yellow
629 //make a file for each calculator
630 for(int i=0;i<vCalcs.size();i++){
632 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(); }
634 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
635 outputNames.push_back(filenamesvg);
636 m->openOutputFile(filenamesvg, outsvg);
638 if (m->control_pressed) { outsvg.close(); return outputNames; }
640 //in essence you want to run it like a single
641 if (vCalcs[i]->getName() == "sharedsobs") {
642 singleCalc = new Sobs();
643 }else if (vCalcs[i]->getName() == "sharedchao") {
644 singleCalc = new Chao1();
647 //get estimates for numA
648 data = singleCalc->getValues(sabundA);
650 //cout << "num a = " << numA << endl;
652 //get estimates for numB
653 data = singleCalc->getValues(sabundB);
655 //cout << "num b = " << numB << endl;
656 //get estimates for numC
657 data = singleCalc->getValues(sabundC);
659 //cout << "num c = " << numC << endl;
660 //get estimates for numD
661 data = singleCalc->getValues(sabundD);
663 //cout << "num d = " << numD << endl;
666 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
667 string groupsTag = "";
668 for (int h = 0; h < lookup.size()-1; h++) { groupsTag += lookup[h]->getGroup() + "-"; } groupsTag += lookup[lookup.size()-1]->getGroup();
669 string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + groupsTag + ".sharedotus";
671 outputNames.push_back(filenameShared);
673 m->openOutputFile(filenameShared, outShared);
674 outShared << "Groups\tNumShared\tOTULabels\n";
677 //get estimates for pairs
679 vector<string> labels;
680 subset.push_back(lookup[0]); subset.push_back(lookup[1]);
681 data = vCalcs[i]->getValues(subset, labels);
683 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
684 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t'<< labels.size() << '\t';
685 for (int k = 0; k < labels.size()-1; k++) {
686 outShared << labels[k] << ",";
688 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
691 //cout << "num ab = " << sharedAB << endl;
693 subset.push_back(lookup[0]); subset.push_back(lookup[2]);
694 data = vCalcs[i]->getValues(subset, labels);
696 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
697 outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
698 for (int k = 0; k < labels.size()-1; k++) {
699 outShared << labels[k] << ",";
701 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
704 //cout << "num ac = " << sharedAC << endl;
706 subset.push_back(lookup[0]); subset.push_back(lookup[3]);
707 data = vCalcs[i]->getValues(subset, labels);
709 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
710 outShared << lookup[0]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
711 for (int k = 0; k < labels.size()-1; k++) {
712 outShared << labels[k] << ",";
714 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
717 //cout << "num ad = " << sharedAD << endl;
719 subset.push_back(lookup[1]); subset.push_back(lookup[2]);
720 data = vCalcs[i]->getValues(subset, labels);
722 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
723 outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
724 for (int k = 0; k < labels.size()-1; k++) {
725 outShared << labels[k] << ",";
727 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
730 //cout << "num bc = " << sharedBC << endl;
732 subset.push_back(lookup[1]); subset.push_back(lookup[3]);
733 data = vCalcs[i]->getValues(subset, labels);
735 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
736 outShared << lookup[1]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
737 for (int k = 0; k < labels.size()-1; k++) {
738 outShared << labels[k] << ",";
740 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
743 //cout << "num bd = " << sharedBD << endl;
745 subset.push_back(lookup[2]); subset.push_back(lookup[3]);
746 data = vCalcs[i]->getValues(subset, labels);
748 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
749 outShared << lookup[2]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
750 for (int k = 0; k < labels.size()-1; k++) {
751 outShared << labels[k] << ",";
753 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
757 //cout << "num cd = " << sharedCD << endl;
758 //get estimates for combos of 3
760 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
761 data = vCalcs[i]->getValues(subset, labels);
763 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
764 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup()+ "-" + lookup[2]->getGroup()<< '\t'<< labels.size() << '\t';
765 for (int k = 0; k < labels.size()-1; k++) {
766 outShared << labels[k] << ",";
768 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
771 //cout << "num abc = " << sharedABC << endl;
773 subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
774 data = vCalcs[i]->getValues(subset, labels);
776 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
777 outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
778 for (int k = 0; k < labels.size()-1; k++) {
779 outShared << labels[k] << ",";
781 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
784 //cout << "num acd = " << sharedACD << endl;
786 subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
787 data = vCalcs[i]->getValues(subset,labels);
789 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
790 outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
791 for (int k = 0; k < labels.size()-1; k++) {
792 outShared << labels[k] << ",";
794 outShared << labels[labels.size()-1];
797 //cout << "num bcd = " << sharedBCD << endl;
799 subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
800 data = vCalcs[i]->getValues(subset, labels);
802 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
803 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
804 for (int k = 0; k < labels.size()-1; k++) {
805 outShared << labels[k] << ",";
807 outShared << labels[labels.size()-1];
810 //cout << "num abd = " << sharedABD << endl;
811 //get estimate for all four
812 data = vCalcs[i]->getValues(lookup, labels);
813 sharedABCD = data[0];
814 if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs") && (labels.size() != 0)) {
815 outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
816 for (int k = 0; k < labels.size()-1; k++) {
817 outShared << labels[k] << ",";
819 if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
823 //cout << "num abcd = " << sharedABCD << endl << endl;
824 int sharedVal, sharedABCVal, sharedABDVal, sharedACDVal, sharedBCDVal, sharedABVal, sharedACVal, sharedADVal, sharedBCVal, sharedBDVal, sharedCDVal, numSeqsA, numSeqsB, numSeqsC, numSeqsD;
827 NSeqs* nseqsCalc = new NSeqs();
828 vector<double> sharedData = nseqsCalc->getValues(lookup);
830 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
831 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
833 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
834 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
836 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[3]);
837 vector<double> sharedAD = nseqsCalc->getValues(mysubset);
839 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
840 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
842 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
843 vector<double> sharedBD = nseqsCalc->getValues(mysubset);
845 mysubset.clear(); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
846 vector<double> sharedCD = nseqsCalc->getValues(mysubset);
848 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
849 vector<double> sharedABC = nseqsCalc->getValues(mysubset);
851 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
852 vector<double> sharedABD = nseqsCalc->getValues(mysubset);
854 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
855 vector<double> sharedACD = nseqsCalc->getValues(mysubset);
857 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
858 vector<double> sharedBCD = nseqsCalc->getValues(mysubset);
860 sharedVal = sharedData[0] + sharedData[1] + sharedData[2] + sharedData[3];
861 sharedABCVal = sharedABC[0] + sharedABC[1] + sharedABC[2];
862 sharedABDVal = sharedABD[0] + sharedABD[1] + sharedABD[2];
863 sharedACDVal = sharedACD[0] + sharedACD[1] + sharedACD[2];
864 sharedBCDVal = sharedBCD[0] + sharedBCD[1] + sharedBCD[2];
865 sharedABVal = sharedAB[0] + sharedAB[1];
866 sharedACVal = sharedAC[0] + sharedAC[1];
867 sharedADVal = sharedAD[0] + sharedAD[1];
868 sharedBCVal = sharedBC[0] + sharedBC[1];
869 sharedBDVal = sharedBD[0] + sharedBD[1];
870 sharedCDVal = sharedCD[0] + sharedCD[1];
871 numSeqsA = sabundA->getNumSeqs();
872 numSeqsB = sabundB->getNumSeqs();
873 numSeqsC = sabundC->getNumSeqs();
874 numSeqsD = sabundD->getNumSeqs();
881 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";
883 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(width) + "\" height=\"" + toString(windowSize) + "\"/>";
884 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.40 * width)) + "\" y=\"" + toString(int(0.05 * height)) + "\" >Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
886 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.625 * height)) + "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA);
887 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsA); }
888 outsvg << "</text>\n";
889 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.65 * height)) + "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB);
890 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsB); }
891 outsvg << "</text>\n";
892 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.675 * height)) + "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC);
893 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsC); }
894 outsvg << "</text>\n";
895 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.7 * height)) + "\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD);
896 if (nseqs) { outsvg << ", and the number of squences is " + toString(numSeqsD); }
897 outsvg << "</text>\n";
899 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.725 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB);
900 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABVal); }
901 outsvg << "</text>\n";
902 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.75 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC);
903 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACVal); }
904 outsvg << "</text>\n";
905 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.775 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD);
906 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedADVal); }
907 outsvg << "</text>\n";
908 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.8 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC);
909 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCVal); }
910 outsvg << "</text>\n";
911 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.825 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD);
912 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBDVal); }
913 outsvg << "</text>\n";
914 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.85 * height)) + "\">The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD);
915 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedCDVal); }
916 outsvg << "</text>\n";
918 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.875 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC);
919 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABCVal); }
920 outsvg << "</text>\n";
921 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.9 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD);
922 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedABDVal); }
923 outsvg << "</text>\n";
924 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.925 * height)) + "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD);
925 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedACDVal); }
926 outsvg << "</text>\n";
927 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.95 * height)) + "\">The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD);
928 if (nseqs) { outsvg << ", and the number of squences is " + toString(sharedBCDVal); }
929 outsvg << "</text>\n";
932 sharedABC = sharedABC - sharedABCD;
933 //cout << "num abc = " << sharedABC << endl;
934 sharedABD = sharedABD - sharedABCD;
935 //cout << "num abd = " << sharedABD << endl;
936 sharedACD = sharedACD - sharedABCD;
937 //cout << "num acd = " << sharedACD << endl;
938 sharedBCD = sharedBCD - sharedABCD;
939 //cout << "num bcd = " << sharedBCD << endl;
941 sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD; //cout << "num ab = " << sharedAB << endl;
942 sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD; //cout << "num ac = " << sharedAC << endl;
943 sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD; //cout << "num ad = " << sharedAD << endl;
944 sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD; //cout << "num bc = " << sharedBC << endl;
945 sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl;
946 sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD; //cout << "num cd = " << sharedCD << endl;
948 numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
949 //cout << "num a = " << numA << endl;
950 numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
951 //cout << "num b = " << numB << endl;
952 numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
953 //cout << "num c = " << numC << endl;
954 numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
955 //cout << "num d = " << numD << endl;
958 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 ";
959 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 ";
960 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 ";
961 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 ";
963 //A = red, B = green, C = blue, D = yellow
965 //place labels within overlaps
966 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.66 * width) - ((int)toString(numA).length() / 2)) + "\" y=\"" + toString(int(0.14 * height)) + "\">" + toString(numA) + "</text>\n";
967 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.66 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[0]->getGroup() + "</text>\n";
968 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB).length() / 2)) + "\" y=\"" + toString(int(0.2 * height)) + "\">" + toString(sharedAB) + "</text>\n";
969 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.36 * width) - ((int)toString(numB).length() / 2)) + "\" y=\"" + toString(int(0.14 * height)) + "\">" + toString(numB) + "</text>\n";
970 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.36 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[1]->getGroup() + "</text>\n";
971 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(sharedAC).length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + toString(sharedAC) + "</text>\n";
972 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.785 * width) - ((int)toString(numC).length() / 2)) + "\" y=\"" + toString(int(0.29 * height)) + "\">" + toString(numC) + "</text>\n";
973 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.785 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[2]->getGroup() + "</text>\n";
974 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.31 * width) - ((int)toString(sharedBD).length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + toString(sharedBD) + "</text>\n";
975 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.22 * width) - ((int)toString(numD).length() / 2)) + "\" y=\"" + toString(int(0.29 * height)) + "\">" + toString(numD) + "</text>\n";
976 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.22 * width) - ((int)lookup[3]->getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[3]->getGroup() + "</text>\n";
977 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.34 * width) - ((int)toString(sharedAD).length() / 2)) + "\" y=\"" + toString(int(0.41 * height)) + "\">" + toString(sharedAD) + "</text>\n";
978 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.675 * width) - ((int)toString(sharedBC).length() / 2)) + "\" y=\"" + toString(int(0.41 * height)) + "\">" + toString(sharedBC) + "</text>\n";
979 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedCD).length() / 2)) + "\" y=\"" + toString(int(0.54 * height)) + "\">" + toString(sharedCD) + "</text>\n";
980 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.39 * width) - ((int)toString(sharedABD).length() / 2)) + "\" y=\"" + toString(int(0.3 * height)) + "\">" + toString(sharedABD) + "</text>\n";
981 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.57 * width) - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"" + toString(int(0.45 * height)) + "\">" + toString(sharedBCD) + "</text>\n";
982 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.435 * width) - ((int)toString(sharedACD).length() / 2)) + "\" y=\"" + toString(int(0.45 * height)) + "\">" + toString(sharedACD) + "</text>\n";
983 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.63 * width) - ((int)toString(sharedABC).length() / 2)) + "\" y=\"" + toString(int(0.3 * height)) + "\">" + toString(sharedABC) + "</text>\n";
984 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABCD).length() / 2)) + "\" y=\"" + toString(int(0.4 * height)) + "\">" + toString(sharedABCD) + "</text>\n";
986 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.25 * width)) + "\" y=\"" + toString(int(0.975 * height)) + "\">The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD));
987 if (nseqs) { outsvg << ", and the number of squences in the otus shared by all groups is " + toString(sharedVal); }
988 outsvg << "</text>\n";
990 outsvg << "</g>\n</svg>\n";
1000 catch(exception& e) {
1001 m->errorOut(e, "Venn", "getPic");