R/getdata.R

Defines functions getdata

Documented in getdata

#' Download TCGA data
#'
#' use the getdata() fuction to download TCGA data,
#'  based on gdc-client.exe and gdc_manifest.txt
#'
#' @param gdc the  path of gdc-client.exe
#' @param mainfest the path of gdc_mainfest file downloaded from TCGA
#' @export
getdata<-function(gdc,manifest){
  downloadedFiles=list.files(pattern = ".*\\-.*\\-.*\\-.*\\-")
  if(length(downloadedFiles)>0){
    listFiles=read.table(manifest,header=T,stringsAsFactors = F)
    #还有多少未下载?
    needToDownload=setdiff(listFiles$id,downloadedFiles)
    if(length(needToDownload)>0){
      message(paste0("还有",length(needToDownload),"个数据待下载..."))
      needToDownload_df=listFiles[listFiles$id%in%needToDownload,]
      write.table(needToDownload_df,"temp.txt",
                  quote = F,row.names = F,sep="\t")
      command=paste(gdc,"download -m","temp.txt",sep=" ")
      system(command)
      unlink("temp.txt")
    }else{
      message("全部数据均已完成下载")
    }
  }else{
    command=paste(gdc,"download -m",manifest,sep=" ")
    system(command)
  }

}
dming1024/TCGApackages0226 documentation built on April 9, 2021, 7:48 a.m.