Mercurial > repos > guru-ananda > karyotype_plot
comparison karyotype/karyotype_plot.xml @ 0:b1e0bf394aa9 draft
Imported from capsule None
author | devteam |
---|---|
date | Thu, 22 Jan 2015 10:40:48 -0500 |
parents | |
children | 88ecf2b559a0 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b1e0bf394aa9 |
---|---|
1 <tool id="karyotype_Plot_1" name="Karyotype Plotting tool" version="1.0.0"> | |
2 <description>for multiple series </description> | |
3 <command interpreter="bash">\$R_SCRIPT_PATH/r_wrapper.sh $script_file</command> | |
4 | |
5 <inputs> | |
6 <param name="main" type="text" value="" size="30" label="Plot Title"/> | |
7 <param name="xlab" type="text" value="" size="30" label="Label for x axis"/> | |
8 <param name="ylab" type="text" value="" size="30" label="Label for y axis"/> | |
9 <param name="lty" type="select" label="Backbone Line Type"> | |
10 <option value="1">Solid</option> | |
11 <option value="2">Dashed</option> | |
12 <option value="3">Dotted</option> | |
13 </param> | |
14 <param name="col" type="select" label="Backbone Line Color"> | |
15 <option value="1">Black</option> | |
16 <option value="2">Red</option> | |
17 <option value="3">Green</option> | |
18 <option value="4">Blue</option> | |
19 <option value="5">Cyan</option> | |
20 <option value="6">Magenta</option> | |
21 <option value="7">Yellow</option> | |
22 <option value="8">Gray</option> | |
23 </param> | |
24 <param name="lwd" type="float" label="Backbone Line Width" value="1.0"/> | |
25 | |
26 <conditional name="legend"> | |
27 <param name="status" type="select" label="Include legend?"> | |
28 <option value="yes" selected="true">Yes</option> | |
29 <option value="no">No</option> | |
30 </param> | |
31 <when value="yes"> | |
32 <param name="leg_title" type="text" value="" size="30" label="Legend title"/> | |
33 <param name="leg_pos" type="select" label="Legend position"> | |
34 <option value="top" selected="true">top</option> | |
35 <option value="topright">topright</option> | |
36 <option value="topleft">topleft</option> | |
37 <option value="bottom">bottom</option> | |
38 <option value="bottomright">bottomright</option> | |
39 <option value="bottomleft">bottomleft</option> | |
40 <option value="left">left</option> | |
41 <option value="right">right</option> | |
42 <option value="center">center</option> | |
43 </param> | |
44 </when> | |
45 <when value="no"> | |
46 </when> | |
47 </conditional> | |
48 | |
49 <repeat name="series" title="Series"> | |
50 <param name="input" type="data" format="tabular" label="Dataset"/> | |
51 <param name="chrcolumn" type="data_column" data_ref="input" label="Chromosome Column"/> | |
52 <param name="startcolumn" type="data_column" data_ref="input" numerical="True" label="Start Column"/> | |
53 <param name="endcolumn" type="data_column" data_ref="input" numerical="True" label="End Column"/> | |
54 <param name="fpch" type="select" label="Point Type"> | |
55 <option value="1">Circle (hollow)</option> | |
56 <option value="2">Triangle (hollow)</option> | |
57 <option value="3">Cross</option> | |
58 <option value="4">Diamond (hollow)</option> | |
59 <option value="15">Square (filled)</option> | |
60 <option value="16">Circle (filled)</option> | |
61 <option value="17">Triangle (filled)</option> | |
62 </param> | |
63 <param name="fcol" type="select" label="Point Color"> | |
64 <option value="1">Black</option> | |
65 <option value="2">Red</option> | |
66 <option value="3">Green</option> | |
67 <option value="4">Blue</option> | |
68 <option value="5">Cyan</option> | |
69 <option value="6">Magenta</option> | |
70 <option value="7">Yellow</option> | |
71 <option value="8">Gray</option> | |
72 </param> | |
73 <param name="fcex" type="float" label="Point Scale" value="1.0"/> | |
74 <param name="leg_text" type="text" value="" size="30" label="Legend text" help="Will be printed only if Include Legend option is set to Yes"/> | |
75 </repeat> | |
76 </inputs> | |
77 | |
78 <configfiles> | |
79 <configfile name="script_file"> | |
80 ## Setup R error handling to go to stderr | |
81 options( show.error.messages=F, | |
82 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) }, | |
83 warn = -1 ) | |
84 ## Determine range of all series in the plot | |
85 library('gtools') | |
86 chrlist = c() | |
87 coordrange = c( NULL, NULL ) | |
88 #for $i, $s in enumerate( $series ) | |
89 s${i} = read.table( "${s.input.file_name}" ) | |
90 chrlist = union( chrlist, as.character(unique(s${i}[,${s.chrcolumn}])) ) | |
91 coordrange = range( coordrange, range(s${i}[,${s.startcolumn}]), range(s${i}[,${s.endcolumn}]) ) | |
92 #end for | |
93 chrlist=mixedsort(chrlist) | |
94 coordrange_byChr=list() | |
95 length(coordrange_byChr) = length(chrlist)*2 | |
96 dim(coordrange_byChr) = c(length(chrlist),2) | |
97 ci=1 | |
98 for (chr in chrlist) { | |
99 #for $i, $s in enumerate( $series ) | |
100 s${i} = read.table( "${s.input.file_name}" ) | |
101 if (nrow(s${i}[s${i}[,${s.chrcolumn}]==chr,]) > 0) { | |
102 coordrange_byChr[ci,]=range(coordrange_byChr[ci,], s${i}[s${i}[,${s.chrcolumn}]==chr,c(${s.startcolumn},${s.endcolumn})]) | |
103 } | |
104 #end for | |
105 ci=ci+1 | |
106 } | |
107 ## Open output PDF file | |
108 pdf( "${out_file1}" ) | |
109 ## Dummy plot for axis / labels | |
110 plot( NULL, type="n", xlim=c(1,length(chrlist)), ylim=coordrange, axes=F, main="${main}", xlab="${xlab}", ylab="${ylab}" ) | |
111 box() | |
112 axis(1,at=1:length(chrlist),labels=chrlist,cex.axis=0.9, las=2) | |
113 axis(2,at=seq(coordrange[1],coordrange[2], length.out=10)) | |
114 ## Plot backbone lines for each chr | |
115 ci=1 | |
116 for (chr in chrlist) { | |
117 lines(c(ci,ci),coordrange_byChr[ci,],lty=${lty},col=${col},lwd=${lwd}) | |
118 ci=ci+1 | |
119 } | |
120 | |
121 legend_text=c() | |
122 pchlist=c() | |
123 colorlist=c() | |
124 ## Plot each series | |
125 #for $i, $s in enumerate( $series ) | |
126 chrs=as.character(s${i}[,${s.chrcolumn}]) | |
127 xvals=sapply(chrs,function(x) which(chrlist==x)) | |
128 points(xvals, s${i}[,${s.startcolumn}], pch=${s.fpch}, cex=${s.fcex}, col=${s.fcol} ) | |
129 legend_text[${i}+1] = "${s.leg_text}" | |
130 pchlist[${i}+1] = ${s.fpch} | |
131 colorlist[${i}+1] = ${s.fcol} | |
132 #end for | |
133 | |
134 #if $legend['status'] == "yes" | |
135 legend_title = "$legend.leg_title" | |
136 legend_pos = "$legend.leg_pos" | |
137 legend(legend_pos, title=legend_title, legend=legend_text, pch=pchlist, col=colorlist) | |
138 #end if | |
139 | |
140 ## Close the PDF file | |
141 devname = dev.off() | |
142 </configfile> | |
143 </configfiles> | |
144 | |
145 <outputs> | |
146 <data format="pdf" name="out_file1" /> | |
147 </outputs> | |
148 | |
149 <requirements> | |
150 <requirement type="set_environment">R_SCRIPT_PATH</requirement> | |
151 <requirement type="package" version="2.15.0">R</requirement> | |
152 </requirements> | |
153 | |
154 <help> | |
155 .. class:: infomark | |
156 | |
157 **What it does** | |
158 | |
159 This tool allows you to paint genomic regions of interest on chromosomes arranged in a karyotype-like fashion. It also allows you to have multiple series in a plot, with each series corresponding to a different feature/dataset. | |
160 | |
161 ----- | |
162 | |
163 .. class:: warningmark | |
164 | |
165 Chromosome lengths (backbone line) are determined based on min and max co-ordinates (by chromosome) in start and end columns respectively. For the series, only the co-ordiantes in start column are used for plotting. | |
166 | |
167 ----- | |
168 | |
169 **Example** | |
170 | |
171 Below is an example of a two series karyotype plot: | |
172 | |
173 .. image:: ./static/operation_icons/karyotype_output.png | |
174 :height: 540 | |
175 :width: 540 | |
176 | |
177 </help> | |
178 </tool> |