Fetching Annotations

library(AnnotationHub)
library(tidyverse)
# Connect to AnnotationHub
ah <- AnnotationHub()

# Access the Ensembl database for organism
ahDb <- query(ah, 
              pattern = c("Homo sapiens", "EnsDb"), 
              ignore.case = TRUE)

# Acquire the latest annotation files
id <- ahDb %>%
        mcols() %>%
        rownames() %>%
        tail(n = 1)

# Download the appropriate Ensembldb database
edb <- ah[[id]]

# Extract gene-level information from database
annotations <- genes(edb, 
                     return.type = "data.frame")

# Select annotations of interest
annotations <- annotations %>%
        dplyr::select(gene_id, gene_name, seq_name, gene_biotype, description)
head(annotations)
           gene_id   gene_name seq_name                       gene_biotype
1  ENSG00000290825     DDX11L2        1                             lncRNA
6  ENSG00000223972     DDX11L1        1 transcribed_unprocessed_pseudogene
7  ENSG00000227232      WASH7P        1             unprocessed_pseudogene
8  ENSG00000278267   MIR6859-1        1                              miRNA
9  ENSG00000243485 MIR1302-2HG        1                             lncRNA
10 ENSG00000284332   MIR1302-2        1                              miRNA
                                                                                     description
1  DEAD/H-box helicase 11 like 2 (pseudogene) [Source:NCBI gene (formerly Entrezgene);Acc:84771]
6                 DEAD/H-box helicase 11 like 1 (pseudogene) [Source:HGNC Symbol;Acc:HGNC:37102]
7                          WASP family homolog 7, pseudogene [Source:HGNC Symbol;Acc:HGNC:38034]
8                                            microRNA 6859-1 [Source:HGNC Symbol;Acc:HGNC:50039]
9                                        MIR1302-2 host gene [Source:HGNC Symbol;Acc:HGNC:52482]
10                                           microRNA 1302-2 [Source:HGNC Symbol;Acc:HGNC:35294]