Question: How to convert bedgraph to wig
0
6 months ago by
ferbecneu0 wrote:

Hi, i would like to convert a bedgraph document to wig format for downstream data analyisis for which I require a wig file.

I have it in the format:

 track name=CD6_1_RPMs description="read per million" type=bedGraph chr1 3005880 3006265 0.788085378200589 chr1 3006269 3014101 0.788085378200589 Its from a 4c-seq RPM normalized counts and the coordinates represent fragments generated from RE digestion. Is it possible to do this with Bioconductor? Thank you very much!
rtracklayer genomicranges • 342 views
modified 6 months ago by Michael Lawrence11k • written 6 months ago by ferbecneu0
Answer: How to convert bedgraph to wig
1
6 months ago by
United States
Michael Lawrence11k wrote:

bedGraph used to be a variant of WIG, so it might work as-is. But if not, then the ranges all need to be the same width, so in general they will all need to be length one. The GPos object is an efficient way to represent that, so you could load the data, convert to a GPos, and export.

Something like:

library(rtracklayer)
bg <- import("foo.bedGraph")
gp <- GPos(bg) # unfortunately need to carry over metadata manually
score(gp) <- rep(score(bg), width(bg))
export(gp, "foo.wig")