Converstion of BED with scores into bigWig
1
2
Entering edit mode
9.4 years ago
Leszek 4.2k

I have some profiles with scores in BED format and I would like to convert them into bigWig format to visualise these data in jBrowse.

9    35084375    35084376    ENSDART00000000004    160.9480969    -
9    35060460    35060461    ENSDART00000000005    752.3776435    +
4    14148184    14148185    ENSDART00000000019    5226.62898     -
2    50770137    50770138    ENSDART00000000042    3513.471655    -

Typically (genomeCoverageBed + bedGraphToBigWig), the intervals from BED file are summed up into bigWig, but this is not what I want. I would like the scores from BED to be visible directly in bigWig track.

Can you recommend me some way of converting such BED in bigWig?

bed bigWig • 34k views
ADD COMMENT
14
Entering edit mode
9.4 years ago
michael.ante ★ 3.9k

You can use awk to get a bedgraph:

awk '{printf "%s\t%d\t%d\t%2.3f\n" , $1,$2,$3,$5}' myBed.bed > myFile.bedgraph

In case the BED file was not sorted properly:

sort -k1,1 -k2,2n myFile.bedgraph > myFile_sorted.bedgraph

Finally, use the UCSC bedGraphToBigWig tool:

bedGraphToBigWig myFile_sorted.bedgraph myChrom.sizes myBigWig.bw

Beware of the naming conventions (sometimes you need to add a chr to your chromosomes' name).

Cheers,
Michael

[edit] updated awk-command after comment

ADD COMMENT
1
Entering edit mode

Nice reply, but how to get the "myChrom.sizes"? Thanks.

ADD REPLY
1
Entering edit mode
ADD REPLY
1
Entering edit mode
samtools faidx genome.fasta 
cut -f1,2 genome.fasta.fai > genome.size
ADD REPLY
1
Entering edit mode

Thank you michael.ante ! But watch out, there's an extra apostrophe at the end of the awk syntax ' (on the answer)

ADD REPLY
0
Entering edit mode

thanks Michael, that was good hint!

I have overlapping intervals, therefore I sort it and merge the overlapping intervals first and then convert it to bedGraph and BigWig.

ADD REPLY
0
Entering edit mode

Has someone encountered a problem with this? I did exactly this and the bigwigs look a bit weird. The bedGraph (MACS2 output .bdg file) shows nicely the peak-like bumps of signal whereas the bigwig shows narrow, rectangular towers as if it's just marking summits or the presence/absence of a peak instead of the different heights along the peak interval. I followed exactly the steps that are in this answer.. (sorted, created the chrom file and converted to bigwig - human chipseq data, hg38) could it be that there is some other parameter that I should add that I am ignoring?

ADD REPLY
1
Entering edit mode

Hi msimmer92,

Currently, I'm not 100% into this topic. I think it would be best to post this as a new question referring to this thread. I can remember that there are two ways of structuring a wig file, but which way is the more appropriate one I cannot remember.

Best,

Michael

ADD REPLY
0
Entering edit mode

I tried again with other of my samples and it seems the one I was handling had a problem or something, because the same exact procedure with others worked well. So your answer is still working! Forget my previous comment. For the record, there's also a tool called bedSort from UCSC that can be used for the sorting step.

ADD REPLY
0
Entering edit mode

Sorry , another comment. If you want to include this on a Bash script (that has arguments) the line with the awk crashes (since the $1, $2.. are substituted with the parameter values you feed into the script). An alternative might be cut -f1-3,5 instead of awk. That could be a nice edit to the answer. Thank you!

ADD REPLY

Login before adding your answer.

Traffic: 2303 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6