annotate align2multiple.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="align2multiple" name="align-to-multiple">
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
2 <description>features</description>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
3 <command>cat $script_file | R --vanilla --slave > $logfile </command>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
4 <inputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
5 <param name="query" type="data" format="interval" label="Query intervals" help= "keep it small (less than 1,000,000 lines)"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
6 <param name="label" type="text" value="" size="30" label="Data Label"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
7 <param name="windowsize" size="10" type="integer" value="5000" label="radius of the window" help="will create new intervals of w bp flanking the original center. set to 0 will not change input interval size)"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
8 <param name="nbins" size="10" type="integer" value="20" label="Number of bins dividing the window"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
9 <param name="sort" label="Sort intervals" help="Sort by the center of the first input, then the second input, then third..." type="boolean" truevalue="sort" falsevalue="none" checked="True"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
10 <repeat name="series" title="input file">
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
11 <param name="label" type="text" value="" size="30" label="Data Label"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
12 <param name="input" type="data" format="interval" label="Dataset"/>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
13 </repeat>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
14 </inputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
15
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
16 <configfiles>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
17 <configfile name="script_file">
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
18 ## Setup R error handling to go to stderr
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
19 cat('\n[',date(),'] Start running job\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
20 options(warn=-1)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
21 windowsize = as.integer("$windowsize")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
22 labels = '$label'
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
23 ## align query to itself
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
24 cmd = 'python /Users/xuebing/galaxy-dist/tools/mytools/alignr.py -a $query -b $query -o $label-$label --profile-only -q -w $windowsize -n $nbins'
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
25 cat('\n[',date(),'] ',cmd,'\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
26 system(cmd)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
27 ## align other sets to query
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
28 #for $i,$s in enumerate( $series )
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
29 labels = c(labels,'$s.label.value')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
30 cmd = 'python /Users/xuebing/galaxy-dist/tools/mytools/alignr.py -a $s.input.file_name -b $query -o $label-$s.label.value --profile-only -q -w $windowsize -n $nbins'
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
31 cat('\n[',date(),'] ',cmd,'\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
32 system(cmd)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
33 #end for
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
34 cat('\n[',date(),'] Read output\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
35 ## read output of query2query
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
36 print(paste(labels[1],labels[1],sep='-'))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
37 x = read.table(paste(labels[1],labels[1],sep='-'))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
38 ids = as.character(x[,1])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
39 nfeat = nrow(x)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
40 x = as.matrix(x[,3:ncol(x)])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
41 nbin = ncol(x)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
42
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
43 ## a table mapping id to position
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
44 ind = list()
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
45 for (i in 1:nfeat){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
46 ind[[ids[i]]] = i
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
47 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
48 ## read other output files
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
49 for (i in 2:length(labels)){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
50 print(paste(labels[1],labels[i],sep='-'))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
51 x0 = read.table(paste(labels[1],labels[i],sep='-'))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
52 ids0 = as.character(x0[,1])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
53 x0 = as.matrix(x0[,3:ncol(x0)])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
54 x1 = matrix(0,nfeat,nbin)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
55 for (j in 1:nrow(x0)){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
56 #cat(j,'\t',ids0[j],'\t',ind[[ids0[j]]],'\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
57 x1[ind[[ids0[j]]],] = x0[j,]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
58 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
59 x = cbind(x,x1)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
60 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
61 ## reorder
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
62 if ("${sort}" == "sort"){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
63 cat('\n[',date(),'] Sort intervals\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
64 for (i in rev(2:length(labels))){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
65 x = x[order(x[,i*nbin-nbin/2]>0),]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
66 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
67 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
68 png("${out_file1}")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
69 ##par(mfrow=c(2,length(labels)),mar=c(1,1,4,1))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
70 layout(matrix(seq(2*length(labels)),nrow=2,byrow=T),heights=c(1,5))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
71 cat('\n[',date(),'] Plot summary\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
72 par(mar=c(0,0,4,0)+0.1)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
73 for (i in 1:length(labels)){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
74 plot(colSums(x[,((i-1)*nbin+1):(i*nbin)]),type='l',axes=F,main=labels[i])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
75 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
76 cat('\n[',date(),'] Plot heatmap\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
77 par(mar=c(0,0,0,0)+0.1)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
78 for (i in 1:length(labels)){
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
79 image(-t(log2(1+x[,((i-1)*nbin+1):(i*nbin)])),axes=F)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
80 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
81 dev.off()
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
82 cat('\n[',date(),'] Finished\n')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
83
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
84 </configfile>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
85 </configfiles>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
86
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
87 <outputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
88 <data format="txt" name="logfile" label="${tool.name} on ${on_string}: (log)" />
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
89 <data format="png" name="out_file1" label="${tool.name} on ${on_string}: (plot)" />
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
90 </outputs>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
91
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
92 <help>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
93 .. class:: infomark
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
94
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
95 This tool allows you to check the co-localization pattern of multiple interval sets. All interval sets are aligned to the center of the intervals in the query interval set.
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
96
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
97 Each row represents a window of certain size around the center of one interval in the query set, such as ChIP peaks. Each heatmap shows the position of other features in the SAME window (the same rows in each heatmap represent the same interval/genomic position).
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
98
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
99
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
100 The example below shows that of all Fox2 peaks, half of them are within 1kb of TSS. Of the half outside TSS, about one half has H3K4me1, two thirds of which are further depleted of H3K4me3.
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
101
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
102 -----
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
103
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
104 **Example**
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
105
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
106 .. image:: ./static/images/align2multiple.png
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
107
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
108 </help>
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
109 </tool>