[Bioc-sig-seq] BED to WIG format conversion

Ivan Gregoretti ivangreg at gmail.com
Thu Sep 17 17:14:25 CEST 2009


Hello everybody

How do you convert BED formatted files to WIG files?


I tried to do that with rtracklayer but it didn't quite succeed.

This is the session's transcript:

First, you can download
http://dl.getdropbox.com/u/2051155/myRegions.bed, which looks like
this

chr1	3002444	3002479			+
chr1	3002989	3003024			-
chr1	3017603	3017638			+
chr1	3017879	3017914			-
chr1	3018173	3018208			+
chr1	3018183	3018218			-
chr1	3018183	3018218			-
chr1	3019065	3019100			+
chr1	3019761	3019796			-
chr1	3020044	3020079			-
...

Now to R

suppressMessages(library(rtracklayer))
myRegions <- import('myRegions.bed')

So far so good. Now I try:
export(myRegions, 'myRegions.wig', format = 'wig')

but I get:
Error in export.ucsc(object, con, subformat, ...) :
  Track not compatible with WIG format: Overlapping features must be
on separate strands and every feature width must be positive

I seems that the error message is a feature rather than a bug. My
interpretation is that export() does not like records like lines 6 and
7:
chr1	3018183	3018218			-
chr1	3018183	3018218			-

So, how do you convert BED to WIG in your everyday work?

Thank you,

Ivan

> sessionInfo()
R version 2.9.2 (2009-08-24)
x86_64-redhat-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rtracklayer_1.4.0 RCurl_0.94-1

loaded via a namespace (and not attached):
[1] Biobase_2.4.0     Biostrings_2.12.0 BSgenome_1.12.0   IRanges_1.2.0
[5] tools_2.9.2       XML_2.3-0

Ivan Gregoretti, PhD
National Institute of Diabetes and Digestive and Kidney Diseases
National Institutes of Health
5 Memorial Dr, Building 5, Room 205.
Bethesda, MD 20892. USA.
Phone: 1-301-496-1592
Fax: 1-301-496-9878



More information about the Bioc-sig-sequencing mailing list