R/update_refData.R

# dataDirectory <- system.file("extdata", package="iProfile")

#' Update extended data
#'
#' Update information of bioconductor annotation platforms about gene chips and
#' ALL HUGO genes (>45,000)
#' @param identifier a name character identify what information you want to update. You can use "platform", "HUGO" and "ALL" for now.
#' @return Nothing
#' @author Shixiang Wang
#' @references \url{https://www.genenames.org/cgi-bin/statistics} for HUGO genes and \url{https://gist.github.com/ShixiangWang/b4a0d22183f916a122aeee1b9d0e7166} for platforms
#' @export
update_refData <- function(identifier=c("platform", "HUGO", "ALL")){
    if(!identifier%in%c("platform", "HUGO", "ALL")){
        stop("Wrong Input! Please choose one of c('platform', 'HUGO', 'ALL') for argument 'identifier'")
    }

    identifier <- match.arg(identifier)

    dataDirectory <- system.file("extdata", package="iProfile")
    hugo.name <- grep(pattern="HUGO", dir(dataDirectory), value = TRUE)
    platforms.name <- grep(pattern="platformMap", dir(dataDirectory), value = TRUE)

    if(identifier=="platform"){
        platformMap <- read.delim(paste(dataDirectory,platforms.name,sep="/"))
        save(platformMap,
             file=paste(system.file("data", package="iProfile"),"platformMap.rda",sep="/"))
    }

    if(identifier=="HUGO"){
        hugo <- read.delim(paste(dataDirectory,hugo.name,sep="/"))
        hugo <- hugo[, c("hgnc_id", "symbol", "name", "entrez_id", "ensembl_gene_id")]
        save(hugo,
             file=paste(system.file("data", package="iProfile"),"hugo.rda",sep="/"))
    }

    if(identifier=="ALL"){
        platformMap <- read.delim(paste(dataDirectory,platforms.name,sep="/"))
        save(platformMap,
             file=paste(system.file("data", package="iProfile"),"platformMap.rda",sep="/"))

        hugo <- read.delim(paste(dataDirectory,hugo.name,sep="/"))
        hugo <- hugo[, c("hgnc_id", "symbol", "name", "entrez_id", "ensembl_gene_id")]
        save(hugo,
             file=paste(system.file("data", package="iProfile"),"hugo.rda",sep="/"))
    }
    return(print("Update data information successfully!"))
}
ShixiangWang/iProfile documentation built on May 11, 2019, 6:25 p.m.