Downloads a GTF file for a specified species, release version, and annotation type from the GENCODE database. The file is saved to a user-specified directory or the current working directory by default.
Arguments
- species
A character string indicating the species. Supported values are:
"human"
"mouse"
- release_version
A character string specifying the release version. Options include:
"latest_release": Automatically fetches the latest release for the specified species.
"release_X": Specific human release (e.g., "release_47").
"release_MX": Specific mouse release (e.g., "release_M36").
- annotation_type
A character string specifying the annotation type. Valid options are:
"annotation.gtf.gz"
"basic.annotation.gtf.gz"
"chr_patch_hapl_scaff.annotation.gtf.gz"
"chr_patch_hapl_scaff.basic.annotation.gtf.gz"
"long_noncoding_RNAs.gtf.gz"
"primary_assembly.annotation.gtf.gz"
"primary_assembly.basic.annotation.gtf.gz"
"tRNAs.gtf.gz"
"polyAs.gtf.gz"
- dest_folder
A character string specifying the destination folder where the file will be downloaded. Defaults to the current working directory.
Details
The function dynamically determines the correct file URL based on the provided parameters and downloads the GTF file to the desired location.
If "latest_release" is specified for release_version
, the function will first determine the latest available release using get_latest_release()
.
Examples
# \donttest{
# Download the latest human GTF file with primary assembly annotations into a temp directory
temp_dir <- tempdir()
gtf_file <- get_gtf(
species = "human",
release_version = "latest_release",
annotation_type = "primary_assembly.basic.annotation.gtf.gz",
dest_folder = temp_dir
)
#> Error in function (type, msg, asError = TRUE) { if (!is.character(type)) { i = match(type, CURLcodeValues) typeName = if (is.na(i)) character() else names(CURLcodeValues)[i] } typeName = gsub("^CURLE_", "", typeName) fun = (if (asError) stop else warning) fun(structure(list(message = msg, call = sys.call()), class = c(typeName, "GenericCurlError", "error", "condition")))}(7L, "Failed to connect to ftp.ebi.ac.uk port 443 after 271 ms: Couldn't connect to server", TRUE): Failed to connect to ftp.ebi.ac.uk port 443 after 271 ms: Couldn't connect to server
print(gtf_file)
#> Error: object 'gtf_file' not found
# Download a specific mouse release with long noncoding RNA annotations into a temp directory
temp_dir <- tempdir()
gtf_file <- get_gtf(
species = "mouse",
release_version = "release_M36",
annotation_type = "long_noncoding_RNAs.gtf.gz",
dest_folder = temp_dir
)
#> Downloading GTF file from https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M36/gencode.vM36.long_noncoding_RNAs.gtf.gz
#> Warning: URL 'https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M36/gencode.vM36.long_noncoding_RNAs.gtf.gz': status was 'Couldn't connect to server'
#> Error downloading file: cannot open URL 'https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M36/gencode.vM36.long_noncoding_RNAs.gtf.gz'
#> Error in get_gtf(species = "mouse", release_version = "release_M36", annotation_type = "long_noncoding_RNAs.gtf.gz", dest_folder = temp_dir): Failed to download the GTF file. Please check the URL or your internet connection.
print(gtf_file)
#> Error: object 'gtf_file' not found
# }