annotate venn.xml @ 13:292186c14b08

Uploaded
author xuebing
date Sat, 10 Mar 2012 08:17:36 -0500
parents b7f1d9f8f3bc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
1 <tool id="venn" name="Venn Diagram">
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
2 <description>from summary counts</description>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
3 <command interpreter="python">$script_file $labels $counts $output $script</command>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
4 <inputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
5 <param name="labels" type="text" value="A,B" size="50" label="Set Labels"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
6 <param name="counts" type="text" value="30,10,20" size="80" label="Counts in each region" help="region order: two sets: A, B, AB; three sets: A,B,C,AB,BC,AC,ABC"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
7 </inputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
8 <configfiles>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
9 <configfile name="script_file">
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
10 import os
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
11 labels = '${labels}'.replace(' ','_').split(',')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
12 counts = '${counts}'.replace(' ','').split(',')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
13 counts = map(int,counts)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
14 rscript = open('${script}','w')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
15 rscript.write("options(warn=-1)\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
16 rscript.write("pdf('"+"${output}"+"')\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
17 rscript.write("library(grid)\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
18 rscript.write("library(VennDiagram)\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
19 if len(labels)==2:
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
20 for i in range(2):
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
21 counts[i+1] = counts[i+1]+counts[i]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
22 rscript.write("venn =venn.diagram(\n\tx=list(\n\t\t"+labels[0]+"=c(1:"+str(counts[0])+","+str(counts[1]+1)+":"+str(counts[2])+"),\n\t\t"+labels[1]+"="+str(counts[0]+1)+":"+str(counts[2])+"),\n\tfilename=NULL,\n\tfill=c('red','blue'),\n\tcol='transparent',\n\talpha=0.5,\n\tlabel.col='black',\n\tcex=2,\n\tlwd=0,\n\tfontfamily='serif',\n\tfontface='bold',\n\tcat.col = c('red', 'blue'),\n\tcat.cex=2,\n\tcat.fontfamily='serif',\n\tcat.fontface='bold')\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
23 else:
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
24 for i in range(6):
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
25 counts[i+1] = counts[i+1]+counts[i]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
26 rscript.write("venn =venn.diagram(\n\tx=list(\n\t\t"+labels[0]+"=c(1:"+str(counts[0])+","+str(counts[2]+1)+":"+str(counts[3])+","+str(counts[4]+1)+":"+str(counts[6])+"),\n\t\t"+labels[1]+"=c("+str(counts[0]+1)+":"+str(counts[1])+","+str(counts[2]+1)+":"+str(counts[4])+","+str(counts[5]+1)+":"+str(counts[6])+"),\n\t\t"+labels[2]+"=c("+str(counts[1]+1)+":"+str(counts[2])+","+str(counts[3]+1)+":"+str(counts[6])+")),\n\tfilename=NULL,\n\tfill=c('red','blue','green'),\n\tcol='transparent',\n\talpha=0.5,\n\tlabel.col='black',\n\tcex=2,\n\tlwd=0,\n\tfontfamily='serif',\n\tfontface='bold',\n\tcat.col = c('red', 'blue','green'),\n\tcat.cex=2,\n\tcat.fontfamily='serif',\n\tcat.fontface='bold')\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
27 rscript.write("grid.draw(venn)\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
28 rscript.write("dev.off()\n")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
29 rscript.close()
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
30 os.system("cat "+"${script}"+" | R --vanilla --slave")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
31 </configfile>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
32 </configfiles>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
33
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
34 <outputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
35 <data format="txt" name="script" label="${tool.name} on ${on_string}: (script)" />
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
36 <data format="pdf" name="output" label="${tool.name} on ${on_string}: (plot)" />
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
37
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
38 </outputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
39
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
40 <help>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
41 .. class:: infomark
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
42
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
43 This is a wrapper for R package VennDiagram. It allows you to plot two-set or three-set venn diagrams based on counts. The R script used to generate the plot is also in the output.
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
44
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
45 Input: labels for sets and counts for each region in the diagram.
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
46
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
47 A: A-only
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
48
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
49 B: B-only
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
50
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
51 C: C-only
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
52
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
53 AB: in A and B but not C
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
54
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
55 BC: in B and C but not A
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
56
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
57 AC: in A and C but not B
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
58
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
59 ABC: in A, B, and C
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
60
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
61 -----
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
62
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
63 **Example**
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
64
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
65 Labels: X,Y
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
66
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
67 Counts: 30,10,20
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
68
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
69
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
70 .. image:: ./static/images/venn2.png
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
71
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
72
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
73 Labels: A,B,C
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
74
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
75 Counts: 10,20,30,40,50,60,70
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
76
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
77
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
78 .. image:: ./static/images/venn3.png
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
79
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
80
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
81 </help>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
82 </tool>