Skip to content

Commit

Permalink
Merge pull request #464 from nuno-agostinho/dev
Browse files Browse the repository at this point in the history
Fix GTEx URLs and unit tests
  • Loading branch information
nuno-agostinho committed Feb 4, 2024
2 parents c640c99 + ce4e0fb commit d50294c
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 81 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Depends:
shinyBS
License: MIT + file LICENSE
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.3.1
Imports:
AnnotationDbi,
AnnotationHub,
Expand Down
10 changes: 6 additions & 4 deletions R/analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ processSurvTerms <- function(clinical, censoring, event, timeStart,

#' @inherit survival::survfit title details
#' @inheritParams survdiffTerms
#' @param formula \code{survTerms} object: survival terms obtained after
#' running \code{processSurvTerms} (see examples)
#' @inheritDotParams survival::survdiff -formula -data
#'
#' @importFrom survival survfit
Expand All @@ -436,12 +438,12 @@ processSurvTerms <- function(clinical, censoring, event, timeStart,
#' survTerms <- processSurvTerms(clinical, censoring="right", event, timeStart,
#' formulaStr=formulaStr)
#' survfit(survTerms)
survfit.survTerms <- function(survTerms, ...) {
res <- survfit(survTerms$form, data=survTerms$survTime, ...)
res$scale <- survTerms$scale
survfit.survTerms <- function(formula, ...) {
res <- survfit(formula$form, data=formula$survTime, ...)
res$scale <- formula$scale

# Correct group names
groups <- deparse(survTerms$form[[3]])
groups <- deparse(formula$form[[3]])
if (!is.null(res$strata) && groups == "groups") {
name <- paste0("^", groups, "=")
names(res$strata) <- gsub(name, "", names(res$strata))
Expand Down
2 changes: 1 addition & 1 deletion R/analysis_correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ plot.GEandAScorrelation <- function(
if (!is(loess, "error"))
plot <- plot + geom_line(
aes(x=loess$x, y=loess$y),
colour=loessColour, alpha=loessAlpha, size=loessWidth)
colour=loessColour, alpha=loessAlpha, linewidth=loessWidth)
}

if (density) {
Expand Down
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
4 changes: 2 additions & 2 deletions man/calculateLoadingsContribution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/colourInputMod.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getClinicalMatchFrom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getDifferentialExpression.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getDifferentialSplicing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getGroups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getHighlightedPoints.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/getSelectedDataPanel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/performPCA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 23 additions & 17 deletions man/plotDistribution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/plotICA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/processButton.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/processSurvival.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/psichomics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/styleModal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions man/survdiffTerms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d50294c

Please sign in to comment.