Question: Converstion of BED with scores into bigWig
0
gravatar for Leszek
4.2 years ago by
Leszek4.0k
IIMCB, Poland
Leszek4.0k wrote:

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? 

 

scores conversion bigwig bed • 11k views
ADD COMMENTlink modified 4 months ago by msimmer92200 • written 4.2 years ago by Leszek4.0k
9
gravatar for michael.ante
4.2 years ago by
michael.ante3.4k
Austria/Vienna
michael.ante3.4k wrote:

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 modified 4 months ago • written 4.2 years ago by michael.ante3.4k
1

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

ADD REPLYlink written 2.6 years ago by moxu440
1

Please see: A: Easiest Way To Obtain Chromosome Length?

ADD REPLYlink written 2.6 years ago by michael.ante3.4k

samtools faidx genome.fasta

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

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by kashiff00780
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 modified 4 months ago • written 4 months ago by msimmer92200

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 written 4.2 years ago by Leszek4.0k

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 modified 4 months ago • written 4 months ago by msimmer92200
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 written 4 months ago by michael.ante3.4k

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 written 4 months ago by msimmer92200

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 modified 4 months ago • written 4 months ago by msimmer92200
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: 909 users visited in the last hour