This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Create bed file where each column is the number of intersections with another bed file

For example I have 3 bed files:

window.bed:

chr1    0   1000
chr1    1000    2000

lp1.bed:

chr1    20  50
chr1    1500    1900

lp2.bed:

chr1    68  786
chr1    899 987

How can I create this output in bed format:

chr1    0   1000    1   2
chr1    1000    2000    1   0

In this output columns 1, 2, 3 are the standard bed format cols, of the chromosome, start, and end of the features taken from window.bed above. Column 4 is the number of intersections between window.bed and lp1.bed per feature in window.bed. For example, the first element in column 4 is '1' because there is one intersection between window.bed and lp1.bed. Column 5 is the same but for the number of intersections between window.bed and lp2.bed for each feature in window.bed.

I suspect that it is doable with bedtools intersect, but I cannot work out the syntax.

bedtools

0 answers

No answers yet.

Log in to answer this question.