Take a look at the rtracklayer Bioconducor package:
?import.gff3 test_path <- system.file("tests", package = "rtracklayer") test_gff3 <- file.path(test_path, "genes.gff3") test <- import(test_gff3) export(test,"test.gtf","gtf")
It would help to know what your downstream analysis/usage is? If GTF is an intermediate step towards another conversion, I suggest you try to obtain directly the final format. From seqanswers:
The whole point of the GTF format was to standardise certain aspects that are left open in GFF. Hence, there are many different valid ways to encode the same information in a valid GFF format, and any parser or converter needs to be written specifically for the choices the author of the GFF file made. For example, a GTF file requires the gene ID attribute to be called "gene_id", while in GFF files, it may be "ID", "Gene", something different, or completely missing. Hence, a general GFF-to-GTF converter (as opposed to one converting only GFF files from a very specific source) needs to guess this from the data, which is non-trivial.
In general, it is difficult to get this right unless you are working on 1 particular GFF file as GFF is more general than GTF.