Skip to content

Commit

Permalink
return ElementName instead of ProbeName
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed Aug 3, 2024
1 parent 27f9223 commit 9f93941
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
25 changes: 16 additions & 9 deletions R/convenience.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ set_gemma_user <- function(username = NULL, password = NULL) {
#'
#' @return A table of annotations
#' \itemize{
#' \item \code{ProbeName}: Probeset names provided by the platform.
#' Gene symbols for generic annotations
#' \item \code{ElementName}: Probeset names provided by the platform.
#' Gene symbols for generic annotations typicall used for RNA-seq experiments.
#' \item \code{GeneSymbols}: Genes that were found to be aligned to
#' the probe sequence. Note that it is possible for probes to be
#' non-specific. Alignment to multiple genes are indicated with gene
Expand Down Expand Up @@ -100,6 +100,7 @@ get_platform_annotations <- function(platform,
} else {
file <- paste0(tools::file_path_sans_ext(file), ".gz")
}


doReadFile <- function(file) {
if (file.exists(file)) {
Expand Down Expand Up @@ -128,22 +129,28 @@ get_platform_annotations <- function(platform,
fread(tools::file_path_sans_ext(file))
}
}

if ((file.exists(file) || file.exists(tools::file_path_sans_ext(file))) && !overwrite) {
if((file.exists(file) || file.exists(tools::file_path_sans_ext(file))) && !overwrite){
warning(tools::file_path_sans_ext(file), " exists. Not overwriting.")
doReadFile(file)
} else {
response <- httr::GET(glue::glue(
paste0(dirname(dirname(gemmaPath())),
"/arrays/downloadAnnotationFile.html?id={platform}&fileType={annotType}")),
"/arrays/downloadAnnotationFile.html?id={platform}&fileType={annotType}")),
httr::write_disk(file))
if (response$status_code==200){
return(doReadFile(file))
} else{
if (response$status_code!=200){
warning(glue::glue("Unable to access annotation file for {platform}. Can get more information about the platform at https://gemma.msl.ubc.ca/arrays/showArrayDesign.html?id={platform}"))
return(NULL)
}
}

frame <- doReadFile(file)

# currently Gemma includes files mixed with ElementName and ProbeName
# we just return ElementName

names(frame)[names(frame) == 'ProbeName'] = 'ElementName'

return(frame)
}

#' Memoise get_platform_annotations
Expand Down
4 changes: 2 additions & 2 deletions man/get_platform_annotations.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/testConvenience.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("getPlatformAnnotation queries work", {
dat <- get_platform_annotations(1)
# ProbeName will turn to ElementName in a later version
expect_equal(colnames(dat), c("ProbeName", "GeneSymbols", "GeneNames", "GOTerms", "GemmaIDs", "NCBIids"))
expect_equal(colnames(dat), c("ElementName", "GeneSymbols", "GeneNames", "GOTerms", "GemmaIDs", "NCBIids"))
expect_false(nrow(dat) == 0)

dat <- expect_warning(get_platform_annotations(1313),"Unable to access annotation file")
Expand Down

0 comments on commit 9f93941

Please sign in to comment.