This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting bedgraph file to wig file

I have a bedgraph file which I have loaded up into R and I am wanting to convert it to a wig file for further analysis. In R, my bedgraph file looks like this:

1   0
2   0
3   0
4   0

I am wanting to add the header variableStep chrom=1 as the first line. I then want to convert this bedgraph file to wig. Does anyone know how to do this? I want my output file to look like this:

variableStep chrom=1
1   0
2   0
3   0
4   0
bedgraph wig r igv

1 answer

You can use the tool called bedGraphToBigWig that is part of kentUtils:

with conda you could use:

mamba install ucsc-bedgraphtobigwig

Edit: if you absolutely need wiggle then use bigwigtowig of the same toolset

Log in to answer this question.