Filter a BED file based on genome coordinates for gene names
1
0
Entering edit mode
12 months ago
joker • 0

Hi, I have BED file with certain regions of interests that looks like this:

chr1 0 91923
chr1 323234 4596845
..

with the start and end coordinates for each gene for the respective chromosome.

But I want to include maybe the gene name, since I need them for my downstream analyses. I have the GTF file for the whole genome with the annotations (gene names, start/end coordinates).

How can I use this GTF file to add the gene names to the bed file? I thought of using bedtools intersect, but not sure how to do this. Maybe: bedtools intersect -a input.bed -b input.gtf > output.bed?

But how is bedtools intersect aware of the column specific format of the GTF file? Or might there be also a way to filter the GTF file based on the coordinates in the BED file?

BED GTF GFF • 1.1k views
ADD COMMENT
0
Entering edit mode

convert GTF to bed before calling bedtools intersect : How To Convert Gencode Gtf Into Bed Format ? ; How to convert gtf to bed format ; Converting gtf format to bed format ; etc... ...

ADD REPLY
0
Entering edit mode

Hi, thanks! Is there also a way to filter the GTF file to include the records based on the BED file coordinates?

ADD REPLY
0
Entering edit mode

You may want to check out AGAT toolkit. Here is one promising option (not BED) but may work: https://agat.readthedocs.io/en/latest/tools/agat_sp_filter_feature_from_keep_list.html

ADD REPLY
0
Entering edit mode

I am already aware of the AGAT toolkit. But the script you mentioned only takes a gff/gtf file and a list of genes as inputs and extracts the overlaps based on the provided list.

But in my case I don't have the gene names, only the coordinates in bed format as mentioned before.

ADD REPLY
1
Entering edit mode

but you can use bedtools intersect with a gtf and a bed

ADD REPLY
1
Entering edit mode
12 months ago

Via BEDOPS bedmap:

bedmap --echo --echo-map-id-uniq regions.bed <(gtf2bed --attribute-key=gene_name < annotations.gtf | awk ($8=="gene")) > answer.bed
ADD COMMENT

Login before adding your answer.

Traffic: 5713 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