BED file: how to split/join into fragments of fixed length that take only portions INSIDE the intervals ?
1
0
Entering edit mode
8.9 years ago
biocyberman ▴ 860

I have been looking at bedtools and bedops to do the following thing but haven't figured out:

Input bed:

chr1    1000    2000    geneA    0    +
chr1    2100    2500    geneB    0    +
chr1    2800    3200    geneC    0    +
chr1    3700    4600    geneD    0    +

Output by 500 bases fragments inside those BED intervals:

chr1    1000    1500    geneA          0    + # split action
chr1    1500    2000    geneA          0    + # split action
chr1    2100    2900    geneB,geneC    0    + # join action: 400 from 2100 - 2500, and 100 from 2800 - 2900
chr1    2900    3900    geneC,geneD    0    + # join action: 300 from 2900 - 3200, and 200 from 3700 - 3900
chr1    3900    4400    geneD          0    + # split action
chr1    4400    4600    geneD          0    + # split action, take the rest

For simplicity, input bed do not have overlapping intervals.

BED bedops bedtools • 2.5k views
ADD COMMENT
1
Entering edit mode

I know that this is not the answer you're looking for but maybe you should try to write a little perl/python/awk script to do it.

ADD REPLY
0
Entering edit mode

If there is no quick way, I will have to spend time and do it.

Reading more carefully about --stagger and--chop operation of bedops, they may actually can do what I want.

ADD REPLY
0
Entering edit mode

No, bedops doesn't do what I want:

bedops --chop 500 test.bedops.bed                                                                                                                         
chr1    1000    1500
chr1    1500    2000
chr1    2100    2500 # only take 400 and stops
chr1    2800    3200 # start anew
chr1    3700    4200 # start anew
chr1    4200    4600 # only take 400 and stops
ADD REPLY
0
Entering edit mode
8.9 years ago

As mentioned, you need to write a script to do this, because you are not applying the same operation to all input intervals equally. For instance, some elements get one split operation, other elements get a different split operation. You will likely need to write custom logic to decide how to apply your desired operations.

ADD COMMENT

Login before adding your answer.

Traffic: 2525 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6