comparison galaxy_runCircos.sh @ 0:46f7f689b929 draft default tip

Uploaded
author saskia-hiltemann
date Tue, 17 Sep 2013 11:29:11 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:46f7f689b929
1 #!/bin/bash
2
3
4 #######################################
5 # Location specific settings
6
7 #scriptsdir="/data/galaxy-dist/tools/trait/circos" # location of tool directory
8 #confdir=${scriptsdir} # loacation of circos conf files (circos_JSV.conf, circos_JS.conf etc)
9 #hg18bed="${scriptsdir}/hg18Genes"
10 #hg19bed="${scriptsdir}/hg19Genes"
11 #######################################
12
13
14 # arguments <junctions file> <SNParray probes> <SNParray snps> <varfile> <WG file> <montage file> <per_chr_file> <hg18|hg19> <customplotfile> <custom_region> <genetrack> <imageformat>
15 echo "arguments: $@"
16
17
18 if [ $# -ne 14 ]
19 then
20 echo "error, unexpected number of arguments in $0"
21 exit
22 fi
23
24 junctions=$1
25 probes=$2
26 snps=$3
27 variations=$4
28 wg_out=$5
29 montage_out=$6
30 per_chr_file=$7
31 build=$8
32 customplot_file=$9
33 custom_region=${10//chr/hs}
34 show_gene_track=${11}
35 imageformat=${12}
36 scriptsdir=${13}
37 confdir=${14}
38
39
40 # if no input data, exit
41 if [[ $junctions == "None" && $probes == "None" && $snps == "None" && $variations == "None" ]]
42 then
43 echo "error, not enough data to make a plot"
44 exit
45 fi
46
47
48 hg18bed="${scriptsdir}/hg18Genes"
49 hg19bed="${scriptsdir}/hg19Genes"
50
51
52 # which tracks to show (depending on which files are provided)
53 if [ $junctions == "None" ]
54 then
55 echo "show = no" > show_junctions.txt
56 else
57 echo "show = yes" > show_junctions.txt
58 fi
59
60 if [ $variations == "None" ]
61 then
62 echo "show = no" > show_variations.txt
63 else
64 echo "show = yes" > show_variations.txt
65 fi
66
67 if [ $snps == "None" ]
68 then
69 echo "show = no" > show_snps.txt
70 else
71 echo "show = yes" > show_snps.txt
72 fi
73
74 if [ $probes == "None" ]
75 then
76 echo "show = no" > show_probes.txt
77 else
78 echo "show = yes" > show_probes.txt
79 fi
80
81
82
83 echo "karyotype = data/karyotype/karyotype.human.hg19.txt" > karyotype.txt
84 if [ $build == "hg18" ]
85 then
86 echo "karyotype = data/karyotype/karyotype.human.hg18.txt" > karyotype.txt
87 fi
88
89 bn=`basename ${junctions}`
90 junctions_circos="${bn}_J_circos"
91 probes_circos="${bn}_probes_circos"
92 snps_circos="${bn}_snps_circos"
93 variations_circos="${bn}_variations_circos"
94 variations_circos_chr="${bn}_variations_circos_chr"
95 bed_junctions="bedfile_junctions_${bn}"
96 bed_snps="bedfile_snps_${bn}"
97 impacted_genes="ImpactedGenes.tsv"
98 circos_out_wg="${bn}_out_wg"
99 circos_out_montage="${bn}_out_montage"
100
101 touch $bed_junctions
102 touch $bed_snps
103 touch $impacted_genes
104
105
106
107 echo ""
108 echo "galaxy:runCircos.sh: "
109 echo "junctions $junctions, probes: $probes, snps: $snps, variations: $variations, wg_out: $wgout, montage_out: $montage_out, per_chr_file: $per_chr_file"
110 echo ""
111
112 ## conf file
113 conffile=${confdir}/circos_JSV.conf
114
115
116
117 #####################################
118 #
119 # input file conversions
120 #
121 #####################################
122
123
124 echo "show = ${show_gene_track}" > showgenes.txt
125
126 if [ $junctions != "None" ]
127 then
128 echo "junctions file specified"
129 if [[ ! -f $junctions_circos ]]
130 then
131 ${scriptsdir}/junctions2circos.sh $junctions $junctions_circos $bed_junctions
132 fi
133
134 if [ ${show_gene_track} == "yes" ]
135 then
136
137 #cat $bed_junctions $bed_snps > ImpactedGenes.tmp
138 mv $bed_junctions ImpactedGenes.tmp
139
140 if [ $build == "hg18" ]
141 then
142 intersectBed -a ImpactedGenes.tmp -b $hg18bed -wb > ImpactedGenes.tmp2
143 else
144 intersectBed -a ImpactedGenes.tmp -b $hg19bed -wb > ImpactedGenes.tmp2
145 fi
146
147 #generate text-track input file
148 awk 'BEGIN{
149 FS="\t"
150 OFS=" "
151 }{
152 print $1,$11,$12,$19
153 }END{
154
155 }' ImpactedGenes.tmp2 > ImpactedGenes.tmp3
156
157 sed -i 's/chr/hs/g' ImpactedGenes.tmp3
158 sort -k4 ImpactedGenes.tmp3 > ImpactedGenes.tmp4
159 uniq -u -f 3 ImpactedGenes.tmp4 ImpactedGenes.tsv
160 cat ImpactedGenes.tsv
161 fi
162
163 fi
164
165 if [[ $probes != "None" && $snps != "None" ]]
166 then
167 echo "probes and snps files specified"
168
169 ${scriptsdir}/SNParray2circos.sh $probes $snps $probes_circos $snps_circos
170
171 #if too many points, reduce (max 25000)
172 numpoints=`wc -l $probes_circos |cut -d" " -f1 `
173 echo "numpoints probes.txt: $numpoints"
174 while [ $numpoints -gt 25000 ]
175 do
176 echo "reducing number of datapoints in probes file"
177 awk 'BEGIN{
178 FS="\t"
179 OFS="\t"
180 }{
181 if(FNR%2==1)
182 print $0 #print alternating lines
183
184 }END{}' $probes_circos > probes_circos_reduced
185
186 rm $probes_circos
187 mv probes_circos_reduced $probes_circos
188 numpoints=`wc -l $probes_circos |cut -d" " -f1 `
189 done
190
191 #if too many points, reduce (max 25000)
192 numpoints=`wc -l $snps_circos | cut -d" " -f1 `
193 echo "numpoints snps.txt: $numpoints"
194 while [ $numpoints -gt 25000 ]
195 do
196 echo "reducing number of datapoints in snps file"
197 awk 'BEGIN{
198 FS="\t"
199 OFS="\t"
200 }{
201 if(FNR%2==1)
202 print $0
203
204 }END{}' $snps_circos > snps_circos_reduced
205
206 rm $snps_circos
207 mv snps_circos_reduced $snps_circos
208 numpoints=`wc -l $snps_circos |cut -d" " -f1 `
209 done
210
211
212 fi
213
214
215 if [ $variations != "None" ]
216 then
217 echo "variations file specified"
218 if [[ ! -f $variations_circos ]]
219 then
220 ${scriptsdir}/variations2circos.sh $variations $variations_circos $variations_circos_chr $bed_snps
221 echo "variations_circos"
222 cat $variations_circos
223 fi
224 fi
225
226
227
228
229
230 #####################################
231 #
232 # run circos
233 #
234 #####################################
235
236
237 echo "running circos"
238 ${scriptsdir}/runcircos_JSV.sh ${conffile_JSV} ${junctions_circos} ${probes_circos} ${snps_circos} $wg_out $montage_out $per_chr_file $build ${variations_circos} ${variations_circos_chr} $customplot_file $custom_region $imageformat
239
240
241
242
243
244
245
246
247
248
249