]> git.donarmstrong.com Git - mothur.git/commitdiff
venn command with up to 4 groups
authorwestcott <westcott>
Thu, 2 Apr 2009 15:21:36 +0000 (15:21 +0000)
committerwestcott <westcott>
Thu, 2 Apr 2009 15:21:36 +0000 (15:21 +0000)
validparameter.cpp
venn.cpp
venncommand.cpp

index 4ba29a703ddb6c24bcb8394d9dd2dc36a739fe91..084068df81f6f2e9c4263e9a58f9549443bf69aa 100644 (file)
@@ -286,7 +286,7 @@ void ValidParameters::initCommandParameters() {
                string heatmapArray[] =  {"group","line","label","sorted"};
                commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string));
 
-               string vennArray[] =  {"group","line","label"};
+               string vennArray[] =  {"groups","line","label"};
                commandParameters["venn"] = addParameters(vennArray, sizeof(vennArray)/sizeof(string));
                
                string quitArray[] = {};
index 282ca984782a8fd05f979179c589806897649862..98c63a1cbe4127714be2939e0605741497e415e6 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -37,11 +37,13 @@ void Venn::getPic(OrderVector* order) {
                
                        
                //svg image
-               outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 200 200\" >\n";
+               outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
                outsvg << "<g>\n";
                                
-               outsvg << "<circle fill=\"red\" stroke=\"black\" cx=\"150\" cy=\"150\" r=\"100\"/>"; 
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"140\" y=\"150\">" + toString(rabund.getNumBins()) + "</text>\n";  
+               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
+               outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + order->getLabel() + "</text>\n";
+               outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"100\"/>"; 
+               outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(rabund.getNumBins()).length() / 2)) + "\" y=\"195\">" + toString(rabund.getNumBins()) + "</text>\n";  
                outsvg << "</g>\n</svg>\n";
                
                outsvg.close();
@@ -70,9 +72,17 @@ void Venn::getPic(SharedOrderVector* sharedorder) {
                outsvg << "<g>\n";
                                
                if (lookup.size() == 1) {
-                       outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"150\" cy=\"150\" r=\"100\"/>"; 
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"140\" y=\"150\">" + toString(lookup[0]->getNumBins()) + "</text>\n";  
-                       outsvg << "</g>\n</svg>\n";
+                       int numA = 0;
+                       //for each bin
+                       for (int i = 0; i < lookup[0]->size(); i++) {
+                               //are they only in one
+                               if (lookup[0]->getAbundance(i) != 0)  { numA++; }
+                       }
+
+                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n";
+                       outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(numA).length() / 2)) + "\" y=\"195\">" + toString(numA) + "</text>\n";  
                        
                }else if (lookup.size() == 2) {
                        //calc the shared otu
@@ -80,42 +90,25 @@ void Venn::getPic(SharedOrderVector* sharedorder) {
                        int numA = 0;
                        int numB = 0;
                        
-                       float rScaler;
-                       
                        //for each bin
                        for (int i = 0; i < lookup[0]->size(); i++) {
-                               if (lookup[0]->getAbundance(i) != 0) { numA++; }
-                               if (lookup[1]->getAbundance(i) != 0) { numB++; }
+                               //are they only in one
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0)) { numA++; }
+                               if ((lookup[1]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0)) { numB++; }
                                //are they shared
                                if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0)) { shared++; }
                        }
                        
-                       if (numA > numB) { rScaler = 150 / float(numA); }
-                       else { rScaler = 150 / float(numB); }
-                       
-                       //to determine how far over to overlap b onto a.
-                       float percentOverlap = shared / (float) numA;   
-                       
-                       int bx = 200 + (numA * rScaler) - ((2 * (numA * rScaler)) * percentOverlap) + (numB * rScaler);
-                       int leftedgeB = bx - (numB * rScaler);  //center b - b's radius
-                       int leftedgeA = 200 - (numA * rScaler); //center a - a's radius
-                       int rightedgeB = bx + (numB * rScaler);  //center b + b's radius
-                       int rightedgeA = 200 + (numA * rScaler); //center a + a's radius
-
-                       int mida = leftedgeA + ((leftedgeB - leftedgeA) / 2);
-                       int midb = rightedgeA + ((rightedgeB - rightedgeA) / 2);
-                       int midab = leftedgeB + ((rightedgeA - leftedgeB) / 2);
-                       
                        //draw circles
                        outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(leftedgeA + ((rightedgeB - leftedgeA) / 2) - 70) + "\" y=\"50\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n"; 
-                       outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".5\" stroke=\"black\" cx=\"200\" cy=\"250\" r=\"" + toString(numA * rScaler) + "\"/>"; 
-                       outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".5\" stroke=\"black\" cx=\"" + toString(bx)  + "\" cy=\"250\" r=\"" + toString(numB * rScaler) + "\"/>";
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(mida) + "\" y=\"250\">" + toString(numA-shared) + "</text>\n";  
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(midab) + "\" y=\"250\">" + toString(shared) + "</text>\n";  
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(midb) + "\" y=\"250\">" + toString(numB-shared) + "</text>\n";  
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(mida) + "\" y=\"500\">Percentage of species that are shared is " + toString((shared / (float)(numA + numB - shared))) + "</text>\n"; 
-                       
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n";
+                       outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"250\" cy=\"200\" r=\"150\"/>"; 
+                       outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"435\" cy=\"200\" r=\"150\"/>"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA).length() / 2)) + "\" y=\"195\">" + toString(numA) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(numB).length() / 2)) + "\" y=\"195\">" + toString(numB) + "</text>\n"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(shared).length() / 2)) + "\" y=\"195\">" + toString(shared) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"580\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString((shared / (float)(numA + numB + shared))) + "</text>\n";
+               
                }else if (lookup.size() == 3) {
                        //calc the shared otu
                        int sharedABC = 0;
@@ -126,13 +119,14 @@ void Venn::getPic(SharedOrderVector* sharedorder) {
                        
                        //for each bin
                        for (int i = 0; i < lookup[0]->size(); i++) {
-                               if (lookup[0]->getAbundance(i) != 0) { numA++; }
-                               if (lookup[1]->getAbundance(i) != 0) { numB++; }
-                               if (lookup[2]->getAbundance(i) != 0) { numC++; }
+                               //are they only in one
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0)) { numA++; }
+                               if ((lookup[1]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0)) { numB++; }
+                               if ((lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[0]->getAbundance(i) == 0)) { numC++; }
                                //are they shared by 2
-                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0)) { sharedAB++; }
-                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0)) { sharedAC++; }
-                               if ((lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0)) { sharedBC++; }
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0)) { sharedAB++; }
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0)) { sharedAC++; }
+                               if ((lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0)) { sharedBC++; }
                                
                                //are they shared by all
                                if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0)) { sharedABC++; }
@@ -146,19 +140,93 @@ void Venn::getPic(SharedOrderVector* sharedorder) {
                        outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>"; 
                        
                        //place labels within overlaps
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA-sharedAB-sharedAC+sharedABC).length() / 2)) + "\" y=\"170\">" + toString(numA-sharedAB-sharedAC+sharedABC) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA).length() / 2)) + "\" y=\"170\">" + toString(numA) + "</text>\n";  
                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedAB).length() / 2)) + "\"  y=\"170\">" + toString(sharedAB) + "</text>\n";  
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)toString(numB-sharedAB-sharedBC+sharedABC).length() / 2)) + "\"  y=\"170\">" + toString(numB-sharedAB-sharedBC+sharedABC) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)toString(numB).length() / 2)) + "\"  y=\"170\">" + toString(numB) + "</text>\n";  
                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(268 - ((int)toString(sharedAC).length() / 2)) + "\"  y=\"305\">" + toString(sharedAC) + "</text>\n";  
-                       outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(343 - ((int)toString(numC-sharedAC-sharedBC+sharedABC).length() / 2)) + "\"   y=\"430\">" + toString(numC-sharedAC-sharedBC+sharedABC) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(343 - ((int)toString(numC).length() / 2)) + "\"   y=\"430\">" + toString(numC) + "</text>\n";  
                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"305\">" + toString(sharedBC) + "</text>\n";  
                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"280\">" + toString(sharedABC) + "</text>\n"; 
                        
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"580\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString((sharedAB / (float)(numA + numB - sharedAB))) + "</text>\n";
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"610\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString((sharedAC / (float)(numA + numC - sharedAC))) + "</text>\n";
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"640\">Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString((sharedBC / (float)(numB + numC - sharedBC))) + "</text>\n";
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"670\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString((sharedABC / (float)(numA + numB + numC - sharedAB - sharedAC - sharedBC - (2 * sharedABC)))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"580\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString(((sharedAB + sharedABC) / (float)(numA + numB + sharedAB + sharedABC))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"610\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString(((sharedAC + sharedABC) / (float)(numA + numC + sharedAC + sharedABC))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"640\">Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedBC + sharedABC) / (float)(numB + numC + sharedBC + sharedABC))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"670\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString((sharedABC / (float)(numA + numB + numC + sharedAB + sharedAC + sharedBC + sharedABC))) + "</text>\n";
+               
+               }else if (lookup.size() == 4) {
+                       //calc the shared otu
+                       int sharedABCD = 0;
+                       int numA = 0; int numB = 0; int numC = 0; int numD = 0;
+                       int sharedAB = 0; int sharedAC = 0; int sharedBC = 0; int sharedAD = 0; int sharedBD = 0; int sharedCD = 0;
+                       int sharedABC = 0; int sharedACD = 0; int sharedBCD = 0; int sharedABD = 0;
+                       
+                       //A = red, B = green, C = blue, D = yellow
+                       
+                       //float scalerB;
+                       
+                       //for each bin
+                       for (int i = 0; i < lookup[0]->size(); i++) {
+                               //are they only in one
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { numA++; }
+                               if ((lookup[1]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { numB++; }
+                               if ((lookup[2]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { numC++; }
+                               if ((lookup[3]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0)) { numD++; }
+                               //are they shared by 2
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { sharedAB++; }
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { sharedAC++; }
+                               if ((lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { sharedBC++; }
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[1]->getAbundance(i) == 0)) { sharedAD++; }
+                               if ((lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[0]->getAbundance(i) == 0)) { sharedBD++; }
+                               if ((lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[0]->getAbundance(i) == 0)) { sharedCD++; }
+                               //are they shared by 3
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) == 0)) { sharedABC++; }
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0)) { sharedACD++; }
+                               if ((lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0)) { sharedBCD++; }
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0)) { sharedABD++; }
+                               //are they shared by all
+                               if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0)) { sharedABCD++; }
+                       }
+                                               
+                       //draw circles
+                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n";
+                       outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n "; 
+                       outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
+                       outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 440 315) \" cx=\"440\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
+                       outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 270 315) \" cx=\"270\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
+                       
+                       //A = red, B = green, C = blue, D = yellow
+                       
+                       //place labels within overlaps
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)toString(numA).length() / 2)) + "\" y=\"110\">" + toString(numA) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedAB).length() / 2)) + "\"  y=\"160\">" + toString(sharedAB) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)toString(numB).length() / 2)) + "\"  y=\"110\">" + toString(numB) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(sharedAC).length() / 2)) + "\"  y=\"190\">" + toString(sharedAC) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(550 - ((int)toString(numC).length() / 2)) + "\"   y=\"230\">" + toString(numC) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(215 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"190\">" + toString(sharedBC) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(150 - ((int)toString(numC).length() / 2)) + "\"   y=\"230\">" + toString(numD) + "</text>\n";  
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedBD) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedCD).length() / 2)) + "\" y=\"430\">" + toString(sharedCD) + "</text>\n"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(275 - ((int)toString(sharedABD).length() / 2)) + "\" y=\"240\">" + toString(sharedABD) + "</text>\n"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(400 - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"360\">" + toString(sharedBCD) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(305 - ((int)toString(sharedACD).length() / 2)) + "\" y=\"360\">" + toString(sharedACD) + "</text>\n"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(440 - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"240\">" + toString(sharedABC) + "</text>\n"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedABCD).length() / 2)) + "\"  y=\"320\">" + toString(sharedABCD) + "</text>\n"; 
+                       
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"490\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString(((sharedAB + sharedABD + sharedABC + sharedABCD) / (float)(numA + numB + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"510\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString(((sharedAC + sharedACD + sharedABC + sharedABCD) / (float)(numA + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"530\">Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[3] + " is " + toString(((sharedAD + sharedACD + sharedABD + sharedABCD) / (float)(numA + numD + sharedAB + sharedAC + sharedAD + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"550\">Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedBC + sharedABC + sharedBCD + sharedABCD) / (float)(numB + numC + sharedAB + sharedAC + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"570\">Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[3] + " is " + toString(((sharedBD + sharedABD + sharedBCD + sharedABCD) / (float)(numB + numD + sharedAB + sharedAD + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"590\">Percentage of species that are shared in groups " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedCD + sharedBCD + sharedACD + sharedABCD) / (float)(numC + numD + sharedAC + sharedAD + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"610\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedABC + sharedABCD) / (float)(numA + numB + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"630\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[3] + " is " + toString(((sharedABD + sharedABCD) / (float)(numA + numB + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"650\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedACD + sharedABCD) / (float)(numA + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"670\">Percentage of species that are shared in groups " + globaldata->Groups[1] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedBCD + sharedABCD) / (float)(numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"690\">Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString((sharedABCD / (float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "</text>\n";
                }
+
                
                outsvg << "</g>\n</svg>\n";
                outsvg.close();
index c8a7dbf36548cf915d64fbe7717ff82484a1e84e..85dcd93c33d9b1df4baf8dcbef8bf16e2677154b 100644 (file)
@@ -141,10 +141,18 @@ void VennCommand::setGroups() {
                        
                                //if the user only entered invalid groups
                                if (globaldata->Groups.size() == 0) { 
-                                       cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first three groups in your groupfile." << endl; 
-                                       for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
-                                               globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+                                       if (globaldata->gGroupmap->namesOfGroups.size() > 4) {
+                                               cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first four groups in your groupfile." << endl; 
+                                               for (int i = 0; i < 4; i++) {
+                                                       globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+                                               }
+                                       }else {
+                                               cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; 
+                                               for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) {
+                                                       globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]);
+                                               }
                                        }
+
                                }
                        }else{//user has enter "all" and wants the default groups
                                globaldata->Groups.clear();
@@ -161,9 +169,9 @@ void VennCommand::setGroups() {
                
                
                //check to make sure their are only 3 groups
-               if (globaldata->Groups.size() > 3) {
-                       cout << "You may only use 3 groups at a time with this command.  I will choose the first three and disregard the rest." << endl;
-                       for (int i = 3; i < globaldata->Groups.size(); i++) {
+               if (globaldata->Groups.size() > 4) {
+                       cout << "You may only use up to 4 groups at a time with this command.  I will choose the first four and disregard the rest." << endl;
+                       for (int i = 4; i < globaldata->Groups.size(); i++) {
                                globaldata->Groups.erase(globaldata->Groups.begin()+i);
                        }
                }