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