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
$ bedGraphToWig.sh < mybedGraphfile > output.wig
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
--