I am looking for a tool that can take multiple BED inputs and output as per my example below. Not sure how to describe this, I suppose it makes a consensus of all regions in the BEDs, then outputs values in column 4 based on overlap. Is there a quick BEDtools or something? It seems relatively trivial and I am starting to write a Perl script but would appreciate anyones thoughts.
My example inputs:
BED_1
chr1 100 1000 0.5
BED_2
chr1 100 200 0.1
chr1 300 400 0.2
And the 'consensus' output:
chr1 100 200 0.1;0.5
chr1 200 300 NA;0.5
chr1 300 400 0.2;0.5
chr1 400 1000 NA;0.5
might be BEDOPS could help or galaxy has many thing around bed files
Use BEDOPS
bedops --partition
to generate your disjoint intervals,bedops --everything
to generate a unioned set, andbedmap --echo-map-id
to map ids of a unioned set to the disjointed intervals. The documentation is helpful in showing how this works, but you might do:Once you see how each step works, it is easy to integrate with a pipeline or script with any desired tweaks, like windows or padding, or mapping of score or other columns, etc.
Thanks,I checked out BEDOPS after Angels suggestion and did it as you described, very neat, many thanks.
Thank you Alex, this is helpful, however I have the problem where for some regions, there are no values. I am merging 30 or so files together. for example:
chr9 121507304 140976434 2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2
chr10 0 103741188
chr10 103741188 104966662
chr10 104966662 115535087
....
chr22 0 21727195
chr22 21727195 26344341
chr22 26344341 51005330
chrX 0 154915660 2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2
What should I do? I followed your instructions and it seems to work for small numbers of files.
Nevermind. I ended up using BEDOPS and got it working fine.