Biostar Beta. Not for public use.
Question: Converstion of BED with scores into bigWig
0
Entering edit mode

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?

ADD COMMENTlink 4.6 years ago Leszek 4.0k • updated 9 months ago msimmer92 • 180
9
Entering edit mode

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 COMMENTlink 9 months ago michael.ante ♦ 3.3k
Entering edit mode
1

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

ADD REPLYlink 3.1 years ago
moxu
• 440
Entering edit mode
Entering edit mode
0

samtools faidx genome.fasta

cut -f1,2 genome.fasta.fai > genome.size

ADD REPLYlink 2.4 years ago
kashiff007
• 50
Entering edit mode
1

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

ADD REPLYlink 9 months ago
msimmer92
• 180
Entering edit mode
0

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 REPLYlink 4.6 years ago
Leszek
4.0k
Entering edit mode
0

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 REPLYlink 9 months ago
msimmer92
• 180
Entering edit mode
1

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 REPLYlink 9 months ago
michael.ante
♦ 3.3k
Entering edit mode
0

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 REPLYlink 9 months ago
msimmer92
• 180
Entering edit mode
0

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 REPLYlink 9 months ago
msimmer92
• 180

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0