From 191efc014006299733588b8b9ab7108184ef0445 Mon Sep 17 00:00:00 2001 From: OganM Date: Thu, 12 Sep 2024 17:34:09 -0700 Subject: [PATCH] bring back gene symbol support --- DESCRIPTION | 2 +- R/ermineR.R | 18 ++++++++++++++++-- R/miscFuns.R | 8 +++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f893d48..2a4c82f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ermineR Title: Gene set analysis with multifunctionality assessment -Version: 1.0.1.9000 +Version: 1.0.2.9000 Authors@R: person("Ogan", "Mancarci", email = "ogan.mancarci@gmail.com", role = c("aut", "cre")) Description: ErmineR is an interface to the ermineJ gene set analysis software (http://erminej.msl.ubc.ca). Depends: R (>= 3.4.0) diff --git a/R/ermineR.R b/R/ermineR.R index 68d3819..967527a 100644 --- a/R/ermineR.R +++ b/R/ermineR.R @@ -69,7 +69,7 @@ ermineR = function(annotation = NULL, } else{ nullAnnot = FALSE } - if('character' %in% class(annotation)){ + if('character' %in% class(annotation) && !grepl('Generic_[a-z]*$',annotation)){ if(!file.exists(annotation)){ message('Attempting to download annotation file') annoTemp = tempfile() @@ -85,7 +85,21 @@ ermineR = function(annotation = NULL, annotation = annoTemp } - } else if('data.frame' %in% class(annotation)) { + }else if('character' %in% class(annotation) && grepl('Generic_[a-z]*$',annotation)){ + + annot = tryCatch(suppressWarnings(gemma.R::get_platform_annotations(platform = paste0(annotation,'_ncbiIds'), + annotType = 'noParents', + memoised = FALSE, + unzip = TRUE)), + error = function(e){ + stop('"annotation" is not a valid file or exists in Pavlidis lab annotations. Use listGemmaAnnotations() to get a list of available annotations.') + }) + annot$ElementName = annot$GeneSymbols + temp = tempfile() + annot %>% readr::write_tsv(temp) + annotation = temp + + }else if('data.frame' %in% class(annotation)) { temp = tempfile() annotation %>% readr::write_tsv(temp) annotation = temp # replace the annotation object with the newly created file name diff --git a/R/miscFuns.R b/R/miscFuns.R index 987e87d..b9f7ac3 100644 --- a/R/miscFuns.R +++ b/R/miscFuns.R @@ -8,7 +8,13 @@ listGemmaAnnotations = function(){ annots = httr::GET('https://gemma.msl.ubc.ca/annots/')$content %>% rawToChar() %>% XML::getHTMLLinks() %>% {.[grepl('noParents',.)]} %>% stringr::str_extract('.*?(?=_noParents)') - return(annots) + platforms = gemma.R::get_platforms_by_ids() %>% gemma.R::get_all_pages() + generics = platforms$platform.shortName %>% + grepl('Generic_[a-z]*_ncbiIds',.) %>% + {platforms$platform.shortName[.]} + + + return(c(platforms$platform.shortName,generics %>% gsub('_ncbiIds','',.))) }