Question: How To Convert Bed Format To Gtf?
3
gravatar for ftp
6.5 years ago by
ftp120
United States
ftp120 wrote:

Hello,

I've seen a lot of posts that convert gtf to bed files. However, i have a bed file that I'm trying to convert to gtf.

Is there any tool that can convert bed->gtf??

Thanks,

gtf bed convert • 13k views
ADD COMMENTlink modified 20 months ago by simon.vanheeringen170 • written 6.5 years ago by ftp120
3
gravatar for Alex Reynolds
6.5 years ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k wrote:

Depends on the BED data you want to convert to GTF. If your raw data was originally a GTF file converted with BEDOPS gtf2bed, then the lossless conversion result (BED-formatted) contains all the columns you need to rebuild the original data, by simply printing out columns in a different order and setting the correct coordinate index:

$ gtf2bed < foo.gtf | sort-bed - > foo.bed
$ awk '{print $1"\t"$7"\t"$8"\t"($2+1)"\t"$3"\t"$5"\t"$6"\t"$9"\t"(substr($0, index($0,$10)))}' foo.bed > foo_from_gtf2bed.gtf
ADD COMMENTlink modified 6.5 years ago • written 6.5 years ago by Alex Reynolds28k
2
gravatar for Istvan Albert
6.5 years ago by
Istvan Albert ♦♦ 81k
University Park, USA
Istvan Albert ♦♦ 81k wrote:

Changing the coordinate is really simple, just add one to the start coordinate. But the GTF format also needs attributes such as gene_id and transcript_id fields that are not present in the BED format. Therefore you will need a third source of information.

ADD COMMENTlink written 6.5 years ago by Istvan Albert ♦♦ 81k
0
gravatar for holgerbrandl
20 months ago by
holgerbrandl30
holgerbrandl30 wrote:

Alliteratively you could convert bed to gtf using this kscriptlet:

kscript https://git.io/vbJ4B my.bed > my.gtf
ADD COMMENTlink modified 20 months ago • written 20 months ago by holgerbrandl30
0
gravatar for simon.vanheeringen
20 months ago by
simon.vanheeringen170 wrote:

And another alternative is to combine the UCSC tools bedToGenePred and genePredToGtf.

bedToGenePred in.bed /dev/stdout | genePredToGtf file /dev/stdin out.gtf

You can install these tools with bioconda, or download them here.

ADD COMMENTlink written 20 months ago by simon.vanheeringen170
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: 1116 users visited in the last hour