2

Do you know any way to convert easily (either by R, or with other program) a BED file to WIG?

Can you give me some guidelines?

Timur Shtatland
  • 12,024
  • 2
  • 30
  • 47
Anna
  • 147
  • 2
  • 4
  • 12

2 Answers2

3

Take a look at the rtracklayer package and specifically at the following man pages:

 ?import
 ?export
Paolo
  • 2,795
  • 1
  • 20
  • 23
  • thank you...do you know if there is way to convert a bedgraph to bed??? how this can be done? – Anna Apr 23 '12 at 15:06
  • 1
    For bioinformatics-related questions I suggest you to post on http://www.biostars.org/ . For example this question http://www.biostars.org/post/show/10141/bedgraph-to-bed/ . – Paolo Apr 23 '12 at 15:36
2

Here is a specific example of how I would convert .bed to .wig. As @Paolo implied, it's a straight-forward procedure:

library(rtracklayer) #bioconductor

bed_loaded <- import(con="~/Downloads/my_bed.bed.gz", format="bed") #no need to unzip .gz
# bed_loaded <- import.bed(con="~/Downloads/my_bed.bed") #if you unzip 

export.wig(object=bed_loaded, con="~/Downloads/bed2wig.wig")

Note that you import and export both have methods (wig, bed, bigwig or bw, etc.). You may directly use them without specifying the method but specifying format argument.

This GitHub tutorial will be helpful.

zx8754
  • 52,746
  • 12
  • 114
  • 209
David C.
  • 1,974
  • 2
  • 19
  • 29