Question: Extract exact match from bed files
0
gravatar for brown.annaleigh
3 months ago by
brown.annaleigh10 wrote:

I would like to extract only regions which exactly match another bed

So I have a regions of interest bed which defines regions, I want to extract only exact matches to these regions

cat regions_of_interest.bed
chr8    79611214    79636802    annotated   0   -
chr8    79611214    79616823    abnormal    0   -

Trying with bedops extracts the regions which also have overlap with these regions

bedops -e 1 target.sorted.bed regions_of_interest.bed

Returns

chr8    79611214    79613670    target.sorted.bed   3   +
chr8    79611214    79613823    target.sorted.bed   178 +
chr8    79611214    79615702    target.sorted.bed   3   +
chr8    79611214    79616054    target.sorted.bed   6   +

Bedtools intersect also returns any overlap

bedtools intersect -a target.sorted.bed -b regions_of_interest.bed

chr8    79611214    79613670    target.sorted.bed   3   +
chr8    79611214    79613670    target.sorted.bed   3   +
chr8    79611214    79613823    target.sorted.bed   178 +
chr8    79611214    79613823    target.sorted.bed   178 +
chr8    79611214    79615702    target.sorted.bed   3   +
chr8    79611214    79615702    target.sorted.bed   3   +
chr8    79611214    79616054    target.sorted.bed   6   +
chr8    79611214    79616054    target.sorted.bed   6   +

Ideally the function would work like this

differenttool intersect -a target.sorted.bed -b regions_of_interest.bed

chr8    79611214    79613823    target.sorted.bed   178 +
chr8    79611214    79636802    target.sorted.bed   2996    +
bedops bed bedtools • 199 views
ADD COMMENTlink modified 3 months ago by Alex Reynolds31k • written 3 months ago by brown.annaleigh10
1
gravatar for brown.annaleigh
3 months ago by
brown.annaleigh10 wrote:
bedtools intersect -f 1 -wa -r -a target.aggregated.bed -b regions_of_interest.bed
ADD COMMENTlink modified 3 months ago by GenoMax92k • written 3 months ago by brown.annaleigh10
1
gravatar for Alex Reynolds
3 months ago by
Alex Reynolds31k
Seattle, WA USA
Alex Reynolds31k wrote:

The following uses BEDOPS bedmap:

bedmap --echo --exact --skip-unmapped target.sorted.bed regions_of_interest.bed > answer.bed

The file answer.bed contains elements from target.sorted.bed, whose intervals match exactly with intervals from regions_of_interest.bed.

ADD COMMENTlink modified 3 months ago • written 3 months ago by Alex Reynolds31k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1667 users visited in the last hour