bigWigToWig producing a bedgraph?

844 views
Skip to first unread message

Nick Schurch

unread,
Jun 24, 2015, 11:53:59 AM6/24/15
to gen...@soe.ucsc.edu
Dear UCSC,

I used some of your tools to create depth coverage tracks from bam files. Basically, I used bedtools to mape coverage bedgraphs from the bam files and then used bedGraphToBigWig to convert these to BigWig format for fast loading in a browser. All fine.

Now though, I want the data as a plain wig file. So I used bigWigToWig to convert the BigWig to a wig - except I didn't end up with a wig, I got a bedgraph?!? Is this intended behaviour? It doesn't seem likely given the name of the tool and its usage help. Surely this is a bug....

--
Cheers,

Nick Schurch

Jonathan Casper

unread,
Jul 2, 2015, 6:15:40 PM7/2/15
to Nick Schurch, gen...@soe.ucsc.edu

Hello Nick,

Thank you for your question about why you are obtaining bedGraph output from the bigWigToWig utility instead of wiggle data. The bigWigToWig tool may have an unfortunate name, but this is actually not a bug. bigWigToWig is designed to return data in the same human-readable format that was used to create the bigWig file. If a bedGraph was used to create the bigWig, then the output of running bigWigToWig on the file will return bedGraph data. Note that the wigToBigWig utility is also somewhat format-agnostic. Despite being named for compressing wiggle files, wigToBigWig will also happily convert bedGraph data into a bigWig. Effectively, bedGraph is just another kind of wiggle.

If you don't mind my asking, why do you need to convert your bedGraph data into one of the other wiggle formats? We do not provide a tool for converting between them because they are intended to be complementary: they serve similar purposes, but are tailored to different types of data. There is even a wiki page devoted to deciding which format is most appropriate for your data at http://genomewiki.ucsc.edu/index.php/Selecting_a_graphing_track_data_format. One of our engineers also comments that bam to bedGraph to bigWig conversion is appropriate, but the bedGraph file is already the 'wiggle' format for this data. It won't fit into fixedStep or varStep format. It isn't fixed or variable in nature, it is uniquely bedGraph.

The following bash script will create a wiggle-like file from your bedGraph data; perhaps that will be enough for your purposes. Alternatively, you can review the format specifications at http://genome.ucsc.edu/goldenPath/help/wiggle.html andhttp://genome.ucsc.edu/goldenPath/help/bedgraph.html and then write your own conversion tool. Please note that the bedGraph data must be sorted for this to work; you can use the kent utility bedSort (available at http://hgdownload.soe.ucsc.edu/admin/exe/) to sort your bedGraph data before doing the conversion.

   #!/bin/bash
   while read A B C D
   do
   echo fixedStep chrom=$A start=$(($B+1)) step=$(($C-$B)) span=$(($C-$B))
   echo $D
   done

Place this script into a file (e.g., "bedGraphToWig.sh"), and then run it as follows:
   $ bedGraphToWig.sh < mybedGraphfile > output.wig

where "mybedGraphfile" is the name of the file containing your bedGraph data and "output.wig" is the name of the output file.

I hope this is helpful. If you have any further questions, please reply to gen...@soe.ucsc.edu or genome...@soe.ucsc.edu. Questions sent to those addresses will be archived in publicly-accessible forums for the benefit of other users. If your question contains sensitive data, you may send it instead to genom...@soe.ucsc.edu.

--
Jonathan Casper
UCSC Genome Bioinformatics Group


--


Reply all
Reply to author
Forward
0 new messages