Skip to content

Instantly share code, notes, and snippets.

@tomsing1
Created May 22, 2025 23:20
Show Gist options
  • Save tomsing1/63bd5f253b7802dcbfbce8748312c3b3 to your computer and use it in GitHub Desktop.
Save tomsing1/63bd5f253b7802dcbfbce8748312c3b3 to your computer and use it in GitHub Desktop.
Downloading Ensembl GTF file, creating an SQlite file and accessing the database as an EnsDb object in R
library(ensembldb)
# 1. retrieve the GTF file for Homo sapiens, Ensembl release 114
kEnsemblRelease <- 114
kUrl <- paste0("https://ftp.ensembl.org/pub/release-", kEnsemblRelease,
"/gtf/homo_sapiens/",
"Homo_sapiens.GRCh38.", kEnsemblRelease, ".gtf.gz")
gff_file <- file.path(tempdir(), basename(kUrl))
download.file(kUrl, gff_file)
# 2. Parse the GTF file and create a SQLite database
sqlite_file <- tempfile(fileext = ".sqlite")
dbFile <- ensDbFromGtf(gff_file, outfile = sqlite_file, path = tempdir(),
organism = "Homo_sapiens", genomeVersion = "GRCh38",
version = )
# 3. Access the SQLite database as an EnsDb object in R
edb <- EnsDb(dbFile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment