Tutorial: bedGraphToBigWig Tutorial and Report
5
gravatar for Shicheng Guo
21 months ago by
Shicheng Guo4.5k
Shicheng Guo4.5k wrote:

It is too easy to make error report in the bedGraphToBigWig process. I want to save the time for the fresh people. The following procedure would be work well for majority situations. 

1, bedGraph should be without header before sorting

awk 'NR!=1' input.bedGraph > input.deheader.bedGraph

2, bedGraph should be sorted

  sort -k1,1 -k2,2n unsorted.bedGraph > sorted.bedGraph

3, chorsome length should be same with Bam files

 fetchChromSizes hg19 > hg19.chrom.sizes

​4, Be sure the bedGraph should only have 4 column 

awk '{print $1,$2,$3,$4}' NC-P-2.bedGraph_CpG.sort.bedGraph > NC-P-2.bedGraph_CpG.sort.4.bedGraph

5, Now, you can run the script (bedGraphToBigWig input.sort.bam chrome.size output.bw)

 

Summary, You can use the following two step to do bedGraphtobigwig transformation:

(head -n 1 NC-P-25.bedGraph_CpG.bedGraph && tail -n +2 NC-P-25.bedGraph_CpG.bedGraph | sort -k1,1 -k2,2n | awk '{print $1,$2,$3,$4}' OFS="\t" )  > NC-P-25.bedGraph_CpG.bedGraph.sort


bedGraphToBigWig NC-P-25.bedGraph_CpG.bedGraph.sort  hg19.chrom.sizes  NC-P-2.bw

For large number of bedGraph files:

# bedgraph to bigwig
for i in `ls *bedGraph`
do
(head -n 1 $i && tail -n +2 $i | sort -k1,1 -k2,2n | awk '{print $1,$2,$3,$4}' OFS="\t" )  > $i.sort
bedGraphToBigWig $i.sort ~/oasis/db/hg19/hg19.chrom.sizes $i.bw 
done

..

ADD COMMENTlink modified 17 months ago • written 21 months ago by Shicheng Guo4.5k
1

It is fine to have this done, I would like to ask you to also put from where one get fetchChromSizes with the link In any case there are numerous ways to do that. I can simply link to HOMER as it is a suite involving numbers *seq pipelines. Obviously for a newbie it will be important. However as you know there are some softwares which provides the chromsome sizes directly. There is also an error in the post fetchChromSizes hg19 > hg18.chrom.sizes. It should be hg19.chrom.sizes

Also the order is a bit tricky here for the file naming convention. If you can make it simpler for newbies. Appreciate your effort. It can be more enriched.

Another thing is the sort command (I appreciate the sorting you implemented) it is also available in bedops as well. People should also know its power and you can put it as well if you want (just an advice)

ADD REPLYlink modified 19 months ago • written 19 months ago by vchris_ngs4.1k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 682 users visited in the last hour