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