annotate tools/mytools/align2multiple.xml @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 <tool id="align2multiple" name="align-to-multiple">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 <description>features</description>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 <command>cat $script_file | R --vanilla --slave > $logfile </command>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 <inputs>
9071e359b9a3 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)"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 <param name="label" type="text" value="" size="30" label="Data Label"/>
9071e359b9a3 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)"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 <param name="nbins" size="10" type="integer" value="20" label="Number of bins dividing the window"/>
9071e359b9a3 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"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 <repeat name="series" title="input file">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 <param name="label" type="text" value="" size="30" label="Data Label"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 <param name="input" type="data" format="interval" label="Dataset"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 </repeat>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 </inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 <configfiles>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 <configfile name="script_file">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 ## Setup R error handling to go to stderr
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 cat('\n[',date(),'] Start running job\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 options(warn=-1)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 windowsize = as.integer("$windowsize")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 labels = '$label'
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 ## align query to itself
9071e359b9a3 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'
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 cat('\n[',date(),'] ',cmd,'\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 system(cmd)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 ## align other sets to query
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 #for $i,$s in enumerate( $series )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 labels = c(labels,'$s.label.value')
9071e359b9a3 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'
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 cat('\n[',date(),'] ',cmd,'\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 system(cmd)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 #end for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 cat('\n[',date(),'] Read output\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 ## read output of query2query
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 print(paste(labels[1],labels[1],sep='-'))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 x = read.table(paste(labels[1],labels[1],sep='-'))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 ids = as.character(x[,1])
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 nfeat = nrow(x)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 x = as.matrix(x[,3:ncol(x)])
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 nbin = ncol(x)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 ## a table mapping id to position
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 ind = list()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 for (i in 1:nfeat){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 ind[[ids[i]]] = i
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 ## read other output files
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 for (i in 2:length(labels)){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 print(paste(labels[1],labels[i],sep='-'))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 x0 = read.table(paste(labels[1],labels[i],sep='-'))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52 ids0 = as.character(x0[,1])
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53 x0 = as.matrix(x0[,3:ncol(x0)])
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 x1 = matrix(0,nfeat,nbin)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55 for (j in 1:nrow(x0)){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
56 #cat(j,'\t',ids0[j],'\t',ind[[ids0[j]]],'\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
57 x1[ind[[ids0[j]]],] = x0[j,]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
58 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
59 x = cbind(x,x1)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
60 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
61 ## reorder
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
62 if ("${sort}" == "sort"){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
63 cat('\n[',date(),'] Sort intervals\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
64 for (i in rev(2:length(labels))){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
65 x = x[order(x[,i*nbin-nbin/2]>0),]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
66 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
67 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
68 png("${out_file1}")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
69 ##par(mfrow=c(2,length(labels)),mar=c(1,1,4,1))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
70 layout(matrix(seq(2*length(labels)),nrow=2,byrow=T),heights=c(1,5))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
71 cat('\n[',date(),'] Plot summary\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
72 par(mar=c(0,0,4,0)+0.1)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
73 for (i in 1:length(labels)){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
74 plot(colSums(x[,((i-1)*nbin+1):(i*nbin)]),type='l',axes=F,main=labels[i])
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
75 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
76 cat('\n[',date(),'] Plot heatmap\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
77 par(mar=c(0,0,0,0)+0.1)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
78 for (i in 1:length(labels)){
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
79 image(-t(log2(1+x[,((i-1)*nbin+1):(i*nbin)])),axes=F)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
80 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
81 dev.off()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
82 cat('\n[',date(),'] Finished\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
83
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
84 </configfile>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
85 </configfiles>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
86
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
87 <outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
88 <data format="txt" name="logfile" label="${tool.name} on ${on_string}: (log)" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
89 <data format="png" name="out_file1" label="${tool.name} on ${on_string}: (plot)" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
90 </outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
91
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
92 <help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
93 .. class:: infomark
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
94
9071e359b9a3 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.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
96
9071e359b9a3 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).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
98
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
99
9071e359b9a3 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.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
101
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
102 -----
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
103
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
104 **Example**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
105
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
106 .. image:: ./static/images/align2multiple.png
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
107
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
108 </help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
109 </tool>