bigwig to wig conversion, getting bedgraph
2
1
Entering edit mode
9.8 years ago

Hello,

I am using ucsc bigWigToWig conversion tool to get a wiggle format file.

However the output format I get is:

#bedGraph section chr1:10458-717292
chr1    10458    10459    7.7
chr1    10459    10460    7.8
chr1    10460    10461    7.9
chr1    10461    10462    8
chr1    10462    10464    8.1
chr1    10464    10465    8.2
chr1    10465    10467    8.3

I tried redownloading the tool from ucsc, checking if this is not a file name issue with ./<executable>

I tried using another bigwig file from ENCODE, same issue.

Because using ucsc bigwig to bedgraph conversion tool, I get a proper bedgraph, I decided to go backwards.

I converted bedgraph to bigwig to wig, again same thing.

The only difference that this file has compared to a usual bedgraph file is the section part added that describes schema of the following sequences(line 1 of table scheme above). While for a wiggle file format, I expect a one chromosomal position per unit output without chromosome name: http://genome.ucsc.edu/goldenpath/help/wiggle.html

I even tried using an older version of the tool from ucsc, same issue.

Any help would be much appreciated.

Mehran

ucsc wiggle bigwig • 6.3k views
ADD COMMENT
0
Entering edit mode

Encountered the same issue in 2022 with bioconda's ucsc-bigwigtowig build 377. :D

ADD REPLY
2
Entering edit mode
9.8 years ago

I have no clue why that's outputting bedGraph rather than wiggle format, but you can convert that to wiggle with awk:

awk '{if(NR>1) {if($1!=lastChrom){printf("variableStep chrom=%s\n",$1);lastChrom=$1;}print $2,$4}}' foo.bedGraph > foo.wig

This assumes that the first line of the bedGraph file should be ignored. This also assumes that wiggle is a 0-based format. I don't actually know if that's true or not. If it's 1-based, then just use $2+1 or $3 rather than $2. Finally, this assumes that each entry in the bedGraph file describes a single position. While one could change the code to deal with that not being the case, it'd be better to do just write a perl or python script at that point.

ADD COMMENT
1
Entering edit mode
9.8 years ago

Thanks a lot Devon. The problem with this is that when we have regions not covered by bedgraph for various reasons, it will simply jump without an extra section line. This would make a problem in downstream tools using wig format.

I made this in python if someone has the similar problem and wants to solve it manually: https://github.com/mehrankr/slow_bedGraph_to_wig/

ADD COMMENT
0
Entering edit mode

Hi. I have got similar problems. Did you figure out the problem? Can you show me how to run your python script? Thanks for any help.

ADD REPLY

Login before adding your answer.

Traffic: 1712 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