丁香实验_LOGO
登录
提问
我要登录
|免费注册

R语言求助!

相关实验:基于 SPSS 的卡方检验

user-title

SHYABI

哪位大佬可以帮我看看这个代码不 一直在报错 debug之后提示不是所有的"check the url1"都是TURE 还有就是 download.file(url1,destfile = downfile)里面url参数不对

Downld_xena<-function(url1=NULL,outname="download.txt",destdir="./",datatype="rna",clean=T,RMraw=T){

if(!require(dplyr)){

install.packages("dplyr")

}

if(!require(tibble)){

install.packages("tibble")

}

if (!datatype %in% c("rna","clinical","survival")) {

stopifnot("datatype must be rna clinical or survival")

}

if(is.null(url1) | !is.character(url1)){

stopifnot("check the url1")

}

downfile<-paste(destdir="./",rev(strsplit(rna_url,"/")[[1]])[1],sep = "/")

download.file(url1,destfile = downfile)

downdata<-data.table::fread(downfile)

if(datatype=="clinical"&clean){

downdata<-downdata %>%

dplyr::rename(Age=age_at_inital_pathologic_diagnosis,

Gender=gender.demographic,

PID=submitter.id,

Sample_ID=submitter.id.samples,

Sample=sample_type.samples,

Stage=tumor_stage.diagnoses,

Mstage=pathologic_M,

Tstage=pathologic_T,

Nstage=pathologic_N) %>%

dplyr::select(-c(starts_with("additional"),starts_with("year"),

starts_with("bcr"),starts_with("pathology"),

starts_with("days"),starts_with("age",ignore.case = F)))%>%

dplyr::select(PID,Sample_ID,Sample_Type,Age,Gender,Stage,Tstage,Nstage,Mstage,everything())

downdata[downdata==""]<-NA

}else{

downdata<-tibble::column_to_rownames(var = "Ensembl_ID")

}

if(datatype=="survival"&clean){

downdata<-downdata %>%

dplyr::rename(OS.status=OS,OS=OS.time)

}

saveRDS(downdata,paste(destdir,outname,sep = "/"))

cat("File has downloaded and stored",destdir,"\n")

if(RMraw){

file.remove(downfile)

}

}

rna_url<-"https://gdc-hub.s3.us-east-1.amazonaws.com/download/TCGA-CHOL.htseq_counts.tsv.gz"

Downld_xena(url1=rna_url,outname = "Bileductcancer_rna.RDS",destdir = "./Readfiles/",datatype = "rna")

traceback()

debug(Downld_xena)

Downld_xena()

wx-share
分享

2 个回答

user-title

dxyc42u

有帮助

有时候是软件本身的问题,可以试下卸载了重新安装

user-title

毛利小五郎的徒弟

有帮助

这个需要下载个函数包,之后就不会报错了。

提问
扫一扫
丁香实验小程序二维码
实验小助手
丁香实验公众号二维码
扫码领资料
反馈
TOP
打开小程序