Question: Manipulating Wiggle Files
2
gravatar for KCC
8.0 years ago by
KCC4.0k
Cambridge, MA
KCC4.0k wrote:

I have a wiggle file and I also have a bed file with some features. I want to average the profile defined in the wiggle file over all of the features in the bed file in order to get an average profile.

Is there software out there that can do this? I would be especially interested in Bioconductor packages. Although, I am not commited to Bioconductor and I would be willing to use just about anything.

bed wiggle • 7.2k views
ADD COMMENTlink modified 6.7 years ago by sjneph600 • written 8.0 years ago by KCC4.0k
5
gravatar for sjneph
6.7 years ago by
sjneph600
sjneph600 wrote:

Sure, just download BEDOPS. Then:


  wig2bed mywig.wig | sort-bed - > mywig.sort.bed
  sort-bed mybed.bed > mybed.sort.bed
  bedmap --echo --mean --delim "\t" mybed.sort.bed mywig.sort.bed 

Each file must be properly sorted as shown above. Once that is completed, all operations with those files are extremely efficient in both time and memory. The bedmap command shown produces results in properly sorted order too, so subsequent analyses with its answer can be done without ever sorting it. bedmap comes loaded with a lot of calculations, including the --mean you're currently after.

ADD COMMENTlink modified 6.7 years ago • written 6.7 years ago by sjneph600

wig comes in a variety of formats and it isn't a simple process to convert to bed when one considers all possibilities (for example, a wig file may embed several sub-wig files within itself, and these could be in any mixture of fixedStep, variableStep, or regular wig formats). I won't claim that this is common, but a good tool will deal with all of these possibilities. wig2bed will deal with any/all of those situations. And, you'll find it's really fast and memory efficient in practice.

As far as finer control than what I've shown above, check out --echo-map-score with bedmap. In addition to all of the built-in solutions, it can retrieve the group of overlapping scores for each row of your bed file, so you can process things further on your own. BEDOPS has pre-built binaries. You should consider downloading and giving it a shot.

ADD REPLYlink modified 6.7 years ago • written 6.7 years ago by sjneph600
2
gravatar for Pierre Lindenbaum
8.0 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum123k wrote:

The ucsc provides some utilities to handle the bigwig/bigbed files: for example bigWigAverageOverBed see http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/

ADD COMMENTlink written 8.0 years ago by Pierre Lindenbaum123k

Thanks. Is there something that would give me more fine control of the process?

ADD REPLYlink written 8.0 years ago by KCC4.0k

From the kent source utilities, you can convert the wiggle files to bigWig by using wigToBigWig, the convert the bigWig to bedGraph format using bigWigToBedGraph, then you can use either bedops or bedtools to calculate the overlap statistics

ADD REPLYlink written 6.7 years ago by dli220

more control ? the sources for the bigWIG format are available in the UCSC git repository. A big* library is also available for java: http://biostar.stackexchange.com/questions/6146

ADD REPLYlink written 8.0 years ago by Pierre Lindenbaum123k
1
gravatar for Istvan Albert
8.0 years ago by
Istvan Albert ♦♦ 81k
University Park, USA
Istvan Albert ♦♦ 81k wrote:

A possible choice would be to convert the wiggle file to bed and use the bedtools package to intersect then perhaps the filo/groupBy to average. This would probably gove you all the control that you need. (I can't seem to find a wiggle to bed converter but that is a simple process)

ADD COMMENTlink written 8.0 years ago by Istvan Albert ♦♦ 81k
1
gravatar for Steve Lianoglou
8.0 years ago by
Steve Lianoglou5.0k
US
Steve Lianoglou5.0k wrote:

The rtracklayer package has support for importing bigWig files (or sub ranges of them).

You can define your BED coordinates as some type of *Ranges object (GRanges, for instance), combine that with the rtracklayer::import.bw function (to import the bigWig), and you will be good to go.

This is the example code snippet you'll find at the bottom of the ?import.bw help page to give you an idea of how it works:

  bw <- import(system.file("tests", "test.bw", package = "rtracklayer"),
               ranges = GenomicRanges::GRanges("chr19", IRanges(1, 6e7)))
ADD COMMENTlink written 8.0 years ago by Steve Lianoglou5.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 709 users visited in the last hour