Quickly obtain gene and transcript annotations from Ensembl using AnnotationHub and ensembldb.

makeGRangesFromEnsembl(organism, level = c("genes", "transcripts"),
  genomeBuild = NULL, release = NULL)

annotable(organism, level = c("genes", "transcripts"),
  genomeBuild = NULL, release = NULL)

Arguments

organism

character(1). Full Latin organism name (e.g. "Homo sapiens").

level

character(1). Return as genes or transcripts.

genomeBuild

character(1). Ensembl genome build assembly name (e.g. "GRCh38"). If set NULL, defaults to the most recent build available. Note: don't pass in UCSC build IDs (e.g. "hg38").

release

integer(1). Ensembl release version (e.g. 90). If set NULL, defaults to the most recent release available.

Value

GRanges.

Details

Simply specify the desired organism, using the full latin name. For example, we can obtain human annotations with Homo sapiens. Optionally, specific Ensembl genome builds (e.g. GRCh38) and release versions (e.g. 87) are supported.

Under the hood, this function fetches annotations from AnnotationHub using the ensembldb package. AnnotationHub supports versioned Ensembl releases, back to version 87.

Genome build: use "GRCh38" instead of "hg38" for the genome build, since we're querying Ensembl and not UCSC.

Functions

  • annotable: Legacy convenience function that calls makeGRangesFromEnsembl() and returns a tibble instead of GRanges. Note that GRanges can also be coercing using as.data.frame().

Broad class definitions

For gene and transcript annotations, a broadClass column is added, which generalizes the gene types into a smaller number of semantically-meaningful groups:

  • coding.

  • noncoding.

  • pseudo.

  • small.

  • decaying.

  • ig (immunoglobulin).

  • tcr (T cell receptor).

  • other.

GRCh37 (hg19) legacy annotations

makeGRangesFromEnsembl() supports the legacy Homo sapiens GRCh37 (release 75) build by internally querying the EnsDb.Hsapiens.v75 package. Alternatively, the corresponding GTF/GFF file can be loaded directly from GENCODE or Ensembl.

AnnotationHub queries

Here's how to perform manual, customized AnnotationHub queries.

library(AnnotationHub)
library(ensembldb)
ah <- AnnotationHub()
    # Human ensembldb (EnsDb) records.
ahs <- query(
    x = ah,
    pattern = c(
        "Homo sapiens",
        "GRCh38",
        "Ensembl",
        "EnsDb"
    )
)
mcols(ahs)
print(ahs)
# EnsDb (Ensembl GRCh38 94; 2018-10-11)
ah[["AH64923"]]
    # Human UCSC TxDb records.
ahs <- query(
    x = ah,
    pattern = c(
        "Homo sapiens",
        "UCSC",
        "TxDb",
        "knownGene"
    )
)
mcols(ahs)
print(ahs)
# TxDb (UCSC hg38 GENCODE 24; 2016-12-22)
ah[["AH52260"]]

See also

Examples

## Genes x <- makeGRangesFromEnsembl("Homo sapiens", level = "genes")
#> Making GRanges from Ensembl.
#> Matching EnsDb from AnnotationHub 2.16.0 (2019-05-02).
#> AH69187: Ensembl 96 EnsDb for Homo sapiens #> Run this code to download EnsDb manually: #> > library(AnnotationHub) #> > ah <- AnnotationHub() #> > edb <- ah[["AH69187"]]
#> Making GRanges from EnsDb object.
#> - Organism: Homo sapiens #> - Genome Build: GRCh38 #> - Ensembl Release: 96 #> - Level: genes
#> Defining broadClass using: geneBiotype, geneName, seqnames
#> Arranging by geneID.
#> 65868 genes detected.
#> [1] "GRanges object with 65868 ranges and 8 metadata columns"
## Transcripts x <- makeGRangesFromEnsembl("Homo sapiens", level = "transcripts")
#> Making GRanges from Ensembl.
#> Matching EnsDb from AnnotationHub 2.16.0 (2019-05-02).
#> AH69187: Ensembl 96 EnsDb for Homo sapiens #> Run this code to download EnsDb manually: #> > library(AnnotationHub) #> > ah <- AnnotationHub() #> > edb <- ah[["AH69187"]]
#> Making GRanges from EnsDb object.
#> - Organism: Homo sapiens #> - Genome Build: GRCh38 #> - Ensembl Release: 96 #> - Level: transcripts
#> Merging gene-level annotations: gene_name, gene_biotype, seq_coord_system, description, gene_id_version, symbol, entrezid
#> Defining broadClass using: geneName, seqnames, transcriptBiotype
#> Arranging by transcriptID.
#> 14 invalid names: LRG_321t1-1, LRG_321t1-2, LRG_321t2-1, LRG_321t2-2, LRG_321t3-1, LRG_321t3-2, LRG_321t4-1, LRG_321t4-2, LRG_321t5-1, LRG_321t5-2, LRG_321t6-1, LRG_321t6-2, LRG_321t7-1, LRG_321t7-2
#> 230399 transcripts detected.
#> [1] "GRanges object with 230399 ranges and 15 metadata columns"