This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting gtf format to bed format

Hello,

I have a question regarding the bed file format.

To convert the gtf file format to the bed format, I am wondering about the start of the second exon of the minus strand. in the minus strand. Please look at the following example:

gtf format

chr1   exon1    1   10    +
          exon2   15   20   +
chr 1   exon1   8   11     -
           exon2   13  19    -

In the above gtf example, the fields describe the chromosome number, exon number, start of the exon, end of the exon and the strand sign.

Now to convert it to bed format:

chr1   11,6   0,14   + 
          3,8     0, ?     -

The question is that how to calculate the start of the second exon of the minus strand.

bed

3 answers

There is an easy way to do that.

Have you installed bedops?

If not, please do that. bedops would help you lot in many cases.

It has a tool

gtf2bed --do-not-sort < foo.gtf > unsorted-foo.gtf.bed

if you want to sort your output bed file, just do

gtf2bed < foo.gtf > unsorted-foo.gtf.bed

There is full on material here

HTH

Hi! How about if I need UCSC BED12 format which seems different from the output of gtf2bed?

Use this script (Works well for all Gencode GTF files > V11 upto V20)

Usage:

./convertGTF.sh InputGTF(Gencode) LEVEL(gene|transcript) OutPutDirectory

Example Gene level output:

Output 1: Table

Table format

Output 2: BED

BED format

Could you please share the script again? The link you provided is not working anymore. Thank you

Hi, I found a script which works perfect on this question!

http://allaboutbioinfo.blogspot.se/2011/08/converting-cufflinks-gtf-predictions-to.html

Log in to answer this question.