annotate tools/mytools/genomeView.xml @ 1:cdcb0ce84a1b

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:15 -0500
parents 9071e359b9a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 <tool id="genomeview" name="whole genome">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 <description>plot and correlation</description>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 <command>cat $script_file | R --vanilla --slave 2> err.log </command>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 <inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 <param name="genome" type="select" label="Select genome">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 <option value="/Users/xuebing/galaxy-dist/tool-data/genome/chrsize/mouse.mm9.genome" selected="true">mm9</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 <option value="/Users/xuebing/galaxy-dist/tool-data/genome/chrsize/mouse.mm8.genome">mm8</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 <option value="/Users/xuebing/galaxy-dist/tool-data/genome/chrsize/human.hg18.genome">hg18</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 <option value="/Users/xuebing/galaxy-dist/tool-data/genome/chrsize/human.hg19.genome">hg19</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 <param name="resolution" type="integer" label="resolution" value="5000" help="resolution in bps. It must be between 200 and 10,000,000">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 <validator type="in_range" max="1000000000" min="200" message="Resolution is out of range, Resolution has to be between 200 to 100000000" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 <param name="log" label="plot the log" type="boolean" truevalue="log" falsevalue="none" checked="False"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 <param name="union" label="compute correlation in union regions" help="ignore regions covered by neither interval sets. Recommended for sparse data under high resolution when most regions are empty" type="boolean" truevalue="union" falsevalue="none" checked="False"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 <repeat name="series" title="input file">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 <param name="label" type="text" value="" size="30" label="Data Label"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 <param name="input" type="data" format="interval" label="Dataset"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 </repeat>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 </inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 <configfiles>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 <configfile name="script_file">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 ## Setup R error handling to go to stderr
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 options(warn=-1)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 source("/Users/xuebing/galaxy-dist/tools/mytools/genomeview.r")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 genome = read.table( "${genome}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 uselog = as.character("${log}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 union = as.character("${union}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 resolution = as.integer("${resolution}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 cat('resolution=',resolution,'\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 offset = caloffset(genome)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 mcov = matrix(ncol=1,nrow=as.integer(offset[length(offset)] / resolution))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 ## Open output PDF file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 pdf( "${out_file1}" ,height=4,width=20)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 labels = character(0)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 ## Determine range of all series in the plot
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 #for $i, $s in enumerate( $series )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 x = read.table( "${s.input.file_name}" )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 res = coverage(x,genome,offset,resolution)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 plotcov(res,genome,offset,"${s.label.value}",uselog)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42 labels = c(labels,"${s.label.value}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 attach(res)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 mcov = cbind(mcov,cov)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 detach(res)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 #end for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 dev.off()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 pdf("${out_file2}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 mcov = mcov[,-1]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 nSample = length(labels)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 if (nSample > 1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52 if (union == 'union') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53 cm = matrix(0,nrow=nSample,ncol=nSample)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 for (i in 1:(nSample-1)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55 cm[i,i] = 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
56 for (j in (i+1):nSample){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
57 cm[i,j] = union_correlation(mcov[,i],mcov[,j])
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
58 cm[j,i] = cm[i,j]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
59 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
60 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
61 cm[nSample,nSample] = 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
62 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
63 cm = cor(mcov)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
64 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
65 rm(mcov)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
66 ##heatmap(-cm,margins=c(8,8),sym=T,scale='none',labRow=labels,labCol=labels)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
67 ##heatmap2(cm,'none',TRUE,c(8,8),labels,labels)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
68 x = cm
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
69 h = heatmap(-x,scale='none',sym=T,margins=c(8,8),labRow=labels,labRol=labels)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
70 attach(h)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
71 x = x[rowInd,colInd]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
72 tx = numeric(0)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
73 ty = numeric(0)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
74 txt = character(0)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
75 for (i in 1:nrow(x)){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
76 for (j in 1:ncol(x)){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
77 tx = c(tx,i)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
78 ty = c(ty,ncol(x)-j+1)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
79 txt = c(txt,round(x[i,j]*100)/100)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
80 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
81 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
82 heatmap(-x,scale='none',sym=T,margins=c(8,8),labRow=labels[rowInd],labCol=labels[colInd],add.expr=text(tx,ty,txt,col='black'))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
83 library(gplots)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
84 heatmap.2(cm,margins=c(8,8),scale='none',key=TRUE,trace='none', symkey=T,symbreaks=T,col=bluered,labRow=labels,labCol=labels,symm=T)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
85 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
86 dev.off()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
87 </configfile>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
88 </configfiles>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
89
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
90 <outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
91 <data format="pdf" name="out_file1" label="${tool.name} on ${on_string}: (plot)" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
92 <data format="pdf" name="out_file2" label="${tool.name} on ${on_string}: (correlation)" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
93 </outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
94
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
95 <help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
96 .. class:: infomark
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
97
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
98 This tool allows you to plot multiple intervals across all chromosomes at different resolution, and it also plots the correlation matrix if multiple intervals are provided.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
99
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
100 -----
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
101
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
102 **Example**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
103
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
104 .. image:: ./static/images/correlationmatrix.png
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
105 .. image:: ./static/images/wholegenome.png
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
106
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
107 </help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
108 </tool>