comparison interval/genomeView.xml @ 18:9bbb37e8683f

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