Regarding the GENCODE gtf file - for that you might want to use the makeTxDbFromGFF function from the GenomicFeatures package since the ensembldb::ensDbFromGtf works only for gtf files from Ensembl as it requires certain fields/columns to be present in the file.

Regarding the error you get with the release 88 GTF - I have to check that. The database is created, but there seems to be a discrepancy between the index of the exon within the transcript and its chromosomal coordinates for one transcript. It seems to be specific for GTF files for Homo sapiens Ensembl releases 88 and 89. I didn't get any error with the Ensembl 90 GTF.

Note that for newer releases of R/Bioconductor you can also fetch EnsDb databases from AnnotationHub. I am adding EnsDbs for every new Ensembl release. Note that the result below is for Bioconductor 3.6 devel. Bioconductor 3.5 has also EnsDbs in AnnotationHub, but not the most recent releases.

Checked into the problematic transcript: transcript ENST00000639671 was assigned to gene ENSG00000141198 in Ensembl release 88, but got re-assigned in Ensembl 90 to ENSG00000166260. Both genes are encoded at around the same region on chromosome 17, but on opposite strands. The order of the exons of ENST00000639671 was (and is) that of a transcript encoded on the reverse strand. With the transcript assigned to the + encoded ENST00000141198 this order did no longer match with the expected order of the chromosomal start coords. Seems to me that this might have been a bug in the Ensembl annotation pipeline. It is fixed since Ensembl 90.

This created a folder (containing "inst", "man", "R" subfolders as well as the Namespace and description) which I installed in R using devtools::install. I haven't tested it out on a dataset yet but it looks good:

That you don't get any results for the query in AnnotationHub is strange. Could you try to delete the .AnnotationHub folder in your home directory and re-run the commands above? Eventually the AnnotationHub database is still the one from your previous installation.

I deleted the .AnnotationHub folder in /Library/Frameworks/R.framework/Versions/3.4/Resources/library/AnnotationHub and the result is unchanged. I still get 0 queries after reinstalling AnnotationHub database using Biocinstaller.

Sorry, I was unclear. I didn't mean to remove the AnnotatioHub folder from the R library. AnnotationHub creates a hidden folder (called ".AnnotationHub" (note the dot before AnnotationHub), usually in the user's home directory. The cache as well as the database is stored there.

You should re-install AnnotationHub with BiocInstaller::biocLite("AnnotationHub"), remove the hidden ".AnnotationHub" folder and try again.

I missed that, thanks for the catch! Deleting the .AnnotationHub folder cleared the cache and did the trick.

I ran ensembldb using both the EnsDb I made from the Ensembl GRCh38 .gtf annotation file (v90) and the one I downloaded through AnnotationHub and both worked well. The only point I would make is with regard to the annotation files from GENCODE. They append the gene/transcript version number to ensembl gene ids. This results in 0 matches when using mapIds(). I fixed this by removing the version numbers from the gene ids in command line after doing the counts. I will probably just download all the fasta and annotation files from ensembl in future.