Generating a bedgraph from a scored bed file
3
2
Entering edit mode
9.1 years ago
Matt Corley ▴ 40

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

< image not found >

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:

< image not found >

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).

bedgraph ChIP-Seq coverage bedtools genome • 3.5k views
ADD COMMENT
1
Entering edit mode
9.1 years ago

I think what you want to do can be accomplished using bedtools map.

ADD COMMENT
1
Entering edit mode
9.1 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1470 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6