|
0
|
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 hg18bed="${scriptsdir}/hg18Genes"
|
|
|
40 hg19bed="${scriptsdir}/hg19Genes"
|
|
|
41
|
|
|
42
|
|
|
43 # which tracks to show (depending on which files are provided)
|
|
|
44 if [ $junctions == "None" ]
|
|
|
45 then
|
|
|
46 echo "show = no" > show_junctions.txt
|
|
|
47 else
|
|
|
48 echo "show = yes" > show_junctions.txt
|
|
|
49 fi
|
|
|
50
|
|
|
51 if [ $variations == "None" ]
|
|
|
52 then
|
|
|
53 echo "show = no" > show_variations.txt
|
|
|
54 else
|
|
|
55 echo "show = yes" > show_variations.txt
|
|
|
56 fi
|
|
|
57
|
|
|
58 if [ $snps == "None" ]
|
|
|
59 then
|
|
|
60 echo "show = no" > show_snps.txt
|
|
|
61 else
|
|
|
62 echo "show = yes" > show_snps.txt
|
|
|
63 fi
|
|
|
64
|
|
|
65 if [ $probes == "None" ]
|
|
|
66 then
|
|
|
67 echo "show = no" > show_probes.txt
|
|
|
68 else
|
|
|
69 echo "show = yes" > show_probes.txt
|
|
|
70 fi
|
|
|
71
|
|
|
72
|
|
|
73
|
|
|
74 echo "karyotype = data/karyotype/karyotype.human.hg19.txt" > karyotype.txt
|
|
|
75 if [ $build == "hg18" ]
|
|
|
76 then
|
|
|
77 echo "karyotype = data/karyotype/karyotype.human.hg18.txt" > karyotype.txt
|
|
|
78 fi
|
|
|
79
|
|
|
80 bn=`basename ${junctions}`
|
|
|
81 junctions_circos="${bn}_J_circos"
|
|
|
82 probes_circos="${bn}_probes_circos"
|
|
|
83 snps_circos="${bn}_snps_circos"
|
|
|
84 variations_circos="${bn}_variations_circos"
|
|
|
85 variations_circos_chr="${bn}_variations_circos_chr"
|
|
|
86 bed_junctions="bedfile_junctions_${bn}"
|
|
|
87 bed_snps="bedfile_snps_${bn}"
|
|
|
88 impacted_genes="ImpactedGenes.tsv"
|
|
|
89 circos_out_wg="${bn}_out_wg"
|
|
|
90 circos_out_montage="${bn}_out_montage"
|
|
|
91
|
|
|
92 touch $bed_junctions
|
|
|
93 touch $bed_snps
|
|
|
94 touch $impacted_genes
|
|
|
95
|
|
|
96
|
|
|
97
|
|
|
98 echo ""
|
|
|
99 echo "galaxy:runCircos.sh: "
|
|
|
100 echo "junctions $junctions, probes: $probes, snps: $snps, variations: $variations, wg_out: $wgout, montage_out: $montage_out, per_chr_file: $per_chr_file"
|
|
|
101 echo ""
|
|
|
102
|
|
|
103 ## conf file
|
|
|
104 conffile=${confdir}/circos_JSV.conf
|
|
|
105
|
|
|
106
|
|
|
107
|
|
|
108 #####################################
|
|
|
109 #
|
|
|
110 # input file conversions
|
|
|
111 #
|
|
|
112 #####################################
|
|
|
113
|
|
|
114
|
|
|
115 echo "show = ${show_gene_track}" > showgenes.txt
|
|
|
116
|
|
|
117 if [ $junctions != "None" ]
|
|
|
118 then
|
|
|
119 echo "junctions file specified"
|
|
|
120 if [[ ! -f $junctions_circos ]]
|
|
|
121 then
|
|
|
122 ${scriptsdir}/junctions2circos.sh $junctions $junctions_circos $bed_junctions
|
|
|
123 fi
|
|
|
124
|
|
|
125 if [ ${show_gene_track} == "yes" ]
|
|
|
126 then
|
|
|
127
|
|
|
128 #cat $bed_junctions $bed_snps > ImpactedGenes.tmp
|
|
|
129 mv $bed_junctions ImpactedGenes.tmp
|
|
|
130
|
|
|
131 if [ $build == "hg18" ]
|
|
|
132 then
|
|
|
133 intersectBed -a ImpactedGenes.tmp -b $hg18bed -wb > ImpactedGenes.tmp2
|
|
|
134 else
|
|
|
135 intersectBed -a ImpactedGenes.tmp -b $hg19bed -wb > ImpactedGenes.tmp2
|
|
|
136 fi
|
|
|
137
|
|
|
138 #generate text-track input file
|
|
|
139 awk 'BEGIN{
|
|
|
140 FS="\t"
|
|
|
141 OFS=" "
|
|
|
142 }{
|
|
|
143 print $1,$11,$12,$19
|
|
|
144 }END{
|
|
|
145
|
|
|
146 }' ImpactedGenes.tmp2 > ImpactedGenes.tmp3
|
|
|
147
|
|
|
148 sed -i 's/chr/hs/g' ImpactedGenes.tmp3
|
|
|
149 sort -k4 ImpactedGenes.tmp3 > ImpactedGenes.tmp4
|
|
|
150 uniq -u -f 3 ImpactedGenes.tmp4 ImpactedGenes.tsv
|
|
|
151 cat ImpactedGenes.tsv
|
|
|
152 fi
|
|
|
153
|
|
|
154 fi
|
|
|
155
|
|
|
156 if [[ $probes != "None" && $snps != "None" ]]
|
|
|
157 then
|
|
|
158 echo "probes and snps files specified"
|
|
|
159
|
|
|
160 ${scriptsdir}/SNParray2circos.sh $probes $snps $probes_circos $snps_circos
|
|
|
161
|
|
|
162 #if too many points, reduce (max 25000)
|
|
|
163 numpoints=`wc -l $probes_circos |cut -d" " -f1 `
|
|
|
164 echo "numpoints probes.txt: $numpoints"
|
|
|
165 while [ $numpoints -gt 25000 ]
|
|
|
166 do
|
|
|
167 echo "reducing number of datapoints in probes file"
|
|
|
168 awk 'BEGIN{
|
|
|
169 FS="\t"
|
|
|
170 OFS="\t"
|
|
|
171 }{
|
|
|
172 if(FNR%2==1)
|
|
|
173 print $0 #print alternating lines
|
|
|
174
|
|
|
175 }END{}' $probes_circos > probes_circos_reduced
|
|
|
176
|
|
|
177 rm $probes_circos
|
|
|
178 mv probes_circos_reduced $probes_circos
|
|
|
179 numpoints=`wc -l $probes_circos |cut -d" " -f1 `
|
|
|
180 done
|
|
|
181
|
|
|
182 #if too many points, reduce (max 25000)
|
|
|
183 numpoints=`wc -l $snps_circos | cut -d" " -f1 `
|
|
|
184 echo "numpoints snps.txt: $numpoints"
|
|
|
185 while [ $numpoints -gt 25000 ]
|
|
|
186 do
|
|
|
187 echo "reducing number of datapoints in snps file"
|
|
|
188 awk 'BEGIN{
|
|
|
189 FS="\t"
|
|
|
190 OFS="\t"
|
|
|
191 }{
|
|
|
192 if(FNR%2==1)
|
|
|
193 print $0
|
|
|
194
|
|
|
195 }END{}' $snps_circos > snps_circos_reduced
|
|
|
196
|
|
|
197 rm $snps_circos
|
|
|
198 mv snps_circos_reduced $snps_circos
|
|
|
199 numpoints=`wc -l $snps_circos |cut -d" " -f1 `
|
|
|
200 done
|
|
|
201
|
|
|
202
|
|
|
203 fi
|
|
|
204
|
|
|
205
|
|
|
206 if [ $variations != "None" ]
|
|
|
207 then
|
|
|
208 echo "variations file specified"
|
|
|
209 if [[ ! -f $variations_circos ]]
|
|
|
210 then
|
|
|
211 ${scriptsdir}/variations2circos.sh $variations $variations_circos $variations_circos_chr $bed_snps
|
|
|
212 echo "variations_circos"
|
|
|
213 cat $variations_circos
|
|
|
214 fi
|
|
|
215 fi
|
|
|
216
|
|
|
217
|
|
|
218
|
|
|
219
|
|
|
220
|
|
|
221 #####################################
|
|
|
222 #
|
|
|
223 # run circos
|
|
|
224 #
|
|
|
225 #####################################
|
|
|
226
|
|
|
227
|
|
|
228 echo "running circos"
|
|
|
229 ${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
|
|
|
230
|
|
|
231
|
|
|
232
|
|
|
233
|
|
|
234
|
|
|
235
|
|
|
236
|
|
|
237
|
|
|
238
|
|
|
239
|
|
|
240
|