Entering edit mode
4 months ago
rxs1018
•
0
If I have two bed files:
A.bed
chr1 100 200 SVID1
chr2 1300 2100 SVID2
chr5 3000 4500 SVID3
B.bed
chr1 40 210
chr2 1330 2901
chr5 3059 4430
I would like to find the features in B that have both the start and end position within 100bp of the start and end positions of A.bed, and label with the SVID.
Therefore in this case, the output would be:
C.bed
chr1 40 210 SVID1
chr5 3059 4430 SVID3
Is there an easy and/or efficient way to do this? Preferably in bedtools, but I do not mind the tool used
bedtools intersect
: https://bedtools.readthedocs.io/en/latest/content/tools/intersect.htmlCurious as to how/why you did not find this tool yourself. You even included
intersect
as atag
for post.I'm familiar with using bedtools for finding intersections, but my understanding is that it is only capable of computing intersection/fraction of intersection rather than check whether start and end are within n base pairs?
Thank you for clarifying that.
While there is
bedtools window
: https://bedtools.readthedocs.io/en/latest/content/tools/window.html it looks like you may be best served by using a custom program. Ask your favorite LLM for assistance if you don't program or I can post a solution suggested by GPT.Here is how you would run the program. (files as shown in the example in original question) :
One way is to use BEDOPS
bedmap
:Via: https://github.com/bedops/bedops
Documentation for
bedmap
is available at: https://bedops.readthedocs.io/en/latest/content/reference/statistics/bedmap.html