Skip to content

Commit

Permalink
Fix GTEx URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-agostinho committed Feb 3, 2024
1 parent c640c99 commit 0c9b983
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions R/data_gtex.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,55 +182,50 @@ downloadGtexFiles <- function(link, folder) {
#' @keywords internal
getGtexDataURL <- function(release, domain="https://storage.googleapis.com",
offline=FALSE) {
path <- paste0("gtex_analysis_v", release)
resp <- try(GET(domain, path=path, timeout(3)))
path <- "adult-gtex"
date <- NULL
if (!is(resp, "try-error") && !http_error(resp) && !offline) {
doc <- xmlParse(resp)
df <- xmlToDataFrame(doc, nodes=xmlRoot(doc)[-c(seq(4))],
stringsAsFactors=FALSE)
files <- c("annotations/.*Annotations_SampleAttributesDS\\.txt",
"annotations/.*Annotations_SubjectPhenotypes.*DS\\.txt",
"rna_seq_data/GTEx.*_gene_reads\\.gct\\.gz",
"rna_seq_data/GTEx.*junction.*\\.gz")
index <- unlist(sapply(files, grep, df[[1]]))
if (length(Filter(length, index)) == 0) return(NULL)
res <- df[index, "Key"]
date <- max(as.Date(df[index, "LastModified"]))
} else if (release == 8) {
if (release == 8) {
res <- c(
"annotations/GTEx_Analysis_v8_Annotations_SampleAttributesDS.txt",
"annotations/GTEx_Analysis_v8_Annotations_SubjectPhenotypesDS.txt",
paste0("rna_seq_data/GTEx_Analysis_2017-06-05_v8_",
c("RNASeQCv1.1.9_gene_reads.gct.gz",
"STARv2.5.3a_junctions.gct.gz")))
"annotations/v8/metadata-files/GTEx_Analysis_v8_Annotations_SampleAttributesDS.txt",
"annotations/v8/metadata-files/GTEx_Analysis_v8_Annotations_SubjectPhenotypesDS.txt",
"bulk-gex/v8/rna-seq/GTEx_Analysis_2017-06-05_v8_RNASeQCv1.1.9_gene_reads.gct.gz",
"bulk-gex/v8/rna-seq/GTEx_Analysis_2017-06-05_v8_STARv2.5.3a_junctions.gct.gz")
date <- as.Date("2019-08-26")
} else if (release == 7) {
res <- c("annotations/GTEx_v7_Annotations_SampleAttributesDS.txt",
"annotations/GTEx_v7_Annotations_SubjectPhenotypesDS.txt",
paste0("rna_seq_data/GTEx_Analysis_2016-01-15_v7_",
c("RNASeQCv1.1.8_gene_reads.gct.gz",
"STARv2.4.2a_junctions.gct.gz")))
res <- c(
"annotations/v7/metadata-files/GTEx_v7_Annotations_SampleAttributesDS.txt",
"annotations/v7/metadata-files/GTEx_v7_Annotations_SubjectPhenotypesDS.txt",
"bulk-gex/v7/rna-seq/GTEx_Analysis_2016-01-15_v7_RNASeQCv1.1.8_gene_reads.gct.gz",
"bulk-gex/v7/rna-seq/GTEx_Analysis_2016-01-15_v7_STARv2.4.2a_junctions.gct.gz")
date <- as.Date("2017-09-05")
} else if (release == 6) {
res <- c("annotations/GTEx_Data_V6_Annotations_SampleAttributesDS.txt",
"annotations/GTEx_Data_V6_Annotations_SubjectPhenotypesDS.txt",
paste0("rna_seq_data/GTEx_Analysis_v6_RNA-seq_",
c("RNA-SeQCv1.1.8_gene_reads.gct.gz",
"Flux1.6_junction_reads.txt.gz")))
res <- c(
"annotations/v6/metadata-files/GTEx_Data_V6_Annotations_SampleAttributesDS.txt",
"annotations/v6/metadata-files/GTEx_Data_V6_Annotations_SubjectPhenotypesDS.txt",
"bulk-gex/v6/rna-seq/GTEx_Analysis_v6_RNA-seq_RNA-SeQCv1.1.8_gene_reads.gct.gz",
"bulk-gex/v6/rna-seq/GTEx_Analysis_v6_RNA-seq_Flux1.6_junction_reads.txt.gz")
date <- as.Date("2017-04-25")
} else if (release == 4) {
res <- c(
"annotations/GTEx_Data_V4_Annotations_SampleAttributesDS.txt",
"annotations/GTEx_Data_V4_Annotations_SubjectPhenotypes_DS.txt",
paste0("rna_seq_data/GTEx_Analysis_V4_RNA-seq_",
c("RNA-SeQCv1.1.8_gene_reads.gct.gz",
"Flux1.6_junction_reads.txt.gz")))
"annotations/v4/metadata-files/GTEx_Data_V4_Annotations_SampleAttributesDS.txt",
"annotations/v4/metadata-files/GTEx_Data_V4_Annotations_SubjectPhenotypes_DS.txt",
"bulk-gex/v4/rna-seq/GTEx_Analysis_V4_RNA-seq_RNA-SeQCv1.1.8_gene_reads.gct.gz",
"bulk-gex/v4/rna-seq/GTEx_Analysis_V4_RNA-seq_Flux1.6_junction_reads.txt.gz")
date <- as.Date("2017-04-24")
} else if (release == 3) {
res <- c(
"annotations/v3/metadata-files/GTEx_Analysis_Annotations_Sample_DS__Pilot_V3.txt",
"annotations/v3/metadata-files/GTEx_Analysis_Annotations_Subject_DS__Pilot_V3.txt",
"bulk-gex/v3/rna-seq/GTEx_Analysis_RNA-seq_RNA-SeQCv1.1.8_gene_reads__Pilot_V3_patch1.gct.gz",
"bulk-gex/v3/rna-seq/GTEx_Analysis_RNA-seq_Flux1.2.3_junction_readcount__Pilot_V3.txt.gz")
date <- as.Date("2017-04-24")
} else {
res <- NULL
}
if (!is.null(res)) {
res <- file.path(domain, path, res)
names(res) <- getGtexDataTypes()
attr(res, "date") <- date

}
return(res)
}
Expand Down

0 comments on commit 0c9b983

Please sign in to comment.