annotate mytools/genomeView.xml @ 0:39217fa39ff2

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