very messy
It turns out that bedmap already does what I want! Modified pipeline according. Hurray!