I have a list of Active Enhancer peaks (bed file) and initially I wanted it assign them to closest target gene. I used Bedops's closest-features to do it. Active Enhancers:
chr1 34737 34937 7_Weak_Enhancer 0 . 34737 34937 255,252,4
chr1 35737 35937 7_Weak_Enhancer 0 . 35737 35937 255,252,4
chr1 36137 36337 7_Weak_Enhancer 0 . 36137 36337 255,252,4
Active Enhancer Annotated to Nearest Gene:
chr1 34737 34937 7_Weak_Enhancer 0 . 34737 34937 255,252,4|chr1 24610 44610 NR_026820 FAM138F -
chr1 35737 35937 7_Weak_Enhancer 0 . 35737 35937 255,252,4|chr1 24610 44610 NR_026820 FAM138F -
chr1 36137 36337 7_Weak_Enhancer 0 . 36137 36337 255,252,4|chr1 24610 44610 NR_026820 FAM138F -
Bedops command used was:
closest-features --closest sortFinalEnhancer.txt sorted10kGTF.bed > ActiveEnhancerCatalog.bed
Now I want to assign each Enhancer to all the genes within 20 kb range (not the nearest gene within 20 kb range but all of them which are in 20 kb range). For example, the output I want will look like this (for first enhancer peak):
chr1 34737 34937 7_Weak_Enhancer 0 . 34737 34937 255,252,4|chr1 24610 44610 NR_026820 FAM138F -
chr1 34737 34937 7_Weak_Enhancer 0 . 34737 34937 255,252,4|chr1 24610 44610 NR_026820 FAM138F -
chr1 34737 34937 7_Weak_Enhancer 0 . 34737 34937 255,252,4|chr1 24610 44610 NR_026820 FAM138F -
So the 3 different genes which were mapped 1-1 before (because of nearest gene criteria within 10 kb region) are now mapped against 1 enhancer peak because they all fall with 20 kb range.
Can anyone guide me if there is any Bedops option or any other possible option to do it? Thank you.