Question: Bedtools window: getting feature from bedfile instead of GFF3 file
0
gravatar for rioualen
2.3 years ago by
rioualen390
France
rioualen390 wrote:

Hello,

I want to get features from a GFF3 file by using a bedfile and betools window. From what I understand from the documentation (![screencap][1] attached), I should get the desired result (features from B), however it seems that I get feature from the bedfile instead (file A).

I'm using this type of command:

bedtools window -a input.bed -b input.gff3 -l 50 -r 500 -sm > output

[1] : https://ibb.co/febExG

window bedtools • 825 views
ADD COMMENTlink modified 2.3 years ago by Alex Reynolds29k • written 2.3 years ago by rioualen390
1
gravatar for Alex Reynolds
2.3 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

BEDOPS bedops --range L:R with bedmap and gff2bed may be another option. The order of the two input files in bedmap specifies whether they are reference or map, respectively.

First, use awk to separate inputs by strand:

$ awk '($6=="+")' input.bed > input.for.bed 
$ awk '($6=="-")' input.bed > input.rev.bed 
$ gff2bed < input.gff3 > input.gff3.bed
$ awk '($6=="+")' input.gff3.bed > input.gff3.for.bed 
$ awk '($6=="-")' input.gff3.bed > input.gff3.rev.bed

Then map the GFF annotations to asymmetrically-padded regions, leaving out any GFF annotations that do not overlap padded reference elements:

$ bedops --range -50:500 --everything input.for.bed | bedmap --echo-map --skip-unmapped - input.gff3.for.bed | sort-bed - > answer.for.bed
$ bedops --range -500:50 --everything input.rev.bed | bedmap --echo-map --skip-unmapped - input.gff3.rev.bed | sort-bed - > answer.rev.bed

Then take the union the two stranded results:

$ bedops --everything answer.for.bed answer.rev.bed > answer.bed

Hope this helps!

ADD COMMENTlink written 2.3 years ago by Alex Reynolds29k

@Alex: Slightly unrelated comment. Do you keep a running tally of answers (like this one) that you provide somewhere (like @Pierre has been doing on his GitHub site)? These would be hard to find by googling but can save someone a bunch of time, when needed.

ADD REPLYlink modified 2.3 years ago • written 2.3 years ago by genomax80k

I sometimes use the Biostars or Google search engine with various keywords. I'll look into this, maybe, but the documentation and examples cover most of this, too.

ADD REPLYlink written 2.3 years ago by Alex Reynolds29k

the documentation and examples cover most of this, too.

It is certainly possible considering your detailed answers (I confess that I am not a current BEDOPS user but will likely use it in future). The linear nature of program documentation is not able to capture dedicated solutions like this (how to do X with BEDOPS). A section on Biostars with practical answers like this would be a very useful section.

ADD REPLYlink modified 2.3 years ago • written 2.3 years ago by genomax80k
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: 1281 users visited in the last hour