Collapse bed and only sum overlapping parts
Hi,
I have a bed that looks something like this:
chr1 150000 170000 feature 10 +
chr1 160000 180000 feature 10 +
I want a way to sum the scores in only the overlapping regions, like this:
chr1 150000 160000 feature 10 +
chr1 160000 170000 feature 20 +
chr1 170000 180000 feature 10 +
Does anyone have any ideas how to do this? I wrote a super chunky python script, but its super computationally intensive and there must be a better way.
Thanks!
• 902 views
•
link
1 answer
Figured out a bedops bedmap option:
bedops --partition my.bed | bedmap --echo --sum --delim '\t' - my.bed
Input bed needs to be sorted first.
• 0 views
•
link
Log in to answer this question.