Biostar Beta. Not for public use.
Question: Generating a bedgraph from a scored bed file
2
Entering edit mode

Bedtools has a function, genomecov , that will output a bedgraph from a BAM file:

I have a slightly different use case, where I'd like to generate a bedgraph file from a scored bed file. That is, instead of each interval representing a count of '1', each interval can represent an arbitrary count. In the case of overlapping intervals, I'd like to report the mean in the bedgraph output. Graphically:

Does anybody know a way to accomplish this using bedtools? I'll also accept non-bedtools solutions, provided they can be implemented in Python (e.g., other tools with a Python API or fully implemented in Python).

ADD COMMENTlink 4.9 years ago Matt Corley • 40 • updated 11 months ago Biostar 20
1
Entering edit mode

I think what you want to do can be accomplished using bedtools map: http://bedtools.readthedocs.org/en/latest/content/tools/map.html

ADD COMMENTlink 4.9 years ago Matt Shirley 9.0k
1
Entering edit mode

You could either use bedops --partition followed by bedtools map, or simply use bedtools unionbedg and post-process its output. If you're using pybedtools, the latter option is probably easiest. There may also be a way to do all of this with bedops.

ADD COMMENTlink 4.9 years ago Devon Ryan 90k

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0