1
|
1 # use of output: move to public_html and visualize in ucsc genome browser with the following:
|
|
2 # track name="xxx" color=0,0,255 type=bigWig bigDataUrl=http://rous.mit.edu/~wuxbl/xxx.bw
|
|
3
|
|
4 if [ $# -lt 6 ]
|
|
5 then
|
|
6 echo "./bigwig.sh infile outtag bam/bed sorted/none genome strand/none [-split]"
|
|
7 exit
|
|
8 fi
|
|
9
|
|
10 f=$1
|
|
11 outf=$2
|
|
12 extension=$3
|
|
13 sorted=$4
|
|
14 genome=$5
|
|
15 strand=$6
|
|
16 split=$7
|
|
17 i=i
|
|
18 if [ $extension = bam ]
|
|
19 then
|
|
20 i=ibam
|
|
21 if [ $sorted != sorted ]
|
|
22 then
|
|
23 echo 'sorting bam file...=>' $f.sorted.bam
|
|
24 samtools sort $f $f.sorted
|
|
25 f=$f.sorted.bam
|
|
26 fi
|
|
27 else
|
|
28 if [ $sorted != sorted ]
|
|
29 then
|
|
30 echo 'sorting bed file...=>' $f.sorted.bed
|
|
31 sort -k1,1 $f > $f.sorted.bed
|
|
32 f=$f.sorted.bed
|
|
33 fi
|
|
34 fi
|
|
35
|
|
36 echo 'making bedgraph file...=>' $f.bedgraph
|
|
37 if [ $strand != strand ]
|
|
38 then
|
|
39 genomeCoverageBed -bg -$i $f -g $genome $split > $f.bedgraph
|
|
40 echo 'making bigwig file...=>' $outf.bw
|
|
41 bedGraphToBigWig $f.bedgraph $genome $outf
|
|
42 else
|
|
43 genomeCoverageBed -bg -$i $f -g $genome $split -strand + > $f+.bedgraph
|
|
44 genomeCoverageBed -bg -$i $f -g $genome $split -strand - > $f-.bedgraph
|
|
45 echo 'making bigwig file for + strand...=>' $outf+.bw
|
|
46 bedGraphToBigWig $f+.bedgraph $genome $outf+.bw
|
|
47 echo 'making bigwig file for - strand...=>' $outf-.bw
|
|
48 bedGraphToBigWig $f-.bedgraph $genome $outf-.bw
|
|
49 fi
|
|
50
|
|
51 # remove intermediate files
|
|
52 if [ $sorted != sorted ]
|
|
53 then
|
|
54 rm $f
|
|
55 fi
|
|
56 rm $f*.bedgraph
|
|
57
|