运行的代码
library(survival)
setwd("C:\\Users\\ANANQIQI\\Desktop\\6")
expFile="surSigExp.txt"
clinicalFile="clinical.csv"
exp=read.table(expFile,sep="\t",header=T,check.names=F,row.names=1)
cli=read.table(clinicalFile,sep="\t",header=T,check.names=F,row.names=1)
samSample=intersect(row.names(exp),row.names(cli))
exp=exp[samSample,]
cli=cli[samSample,]
pFilter=0.05
独立预后分析,输出表格
outTab=data.frame()
sigGenes=c("futime","fustat")
for(i in colnames(exp[,3:ncol(exp)])){
rt=cbind(exp[,1:2],cli,gene=exp[,i])
multiCox=coxph(Surv(futime, fustat) ~ ., data = rt)
coxSummary=summary(multiCox)
coxP[is.na(coxP)] <- 1
if(coxSummary$coefficients["gene","Pr(>|z|)"]<pFilter){
sigGenes=c(sigGenes,i)
outTab=rbind(outTab,
cbind(id=i,
HR=coxSummary$conf.int["gene","exp(coef)"],
HR.95L=coxSummary$conf.int["gene","lower .95"],
HR.95H=coxSummary$conf.int["gene","upper .95"],
pvalue=coxSummary$coefficients["gene","Pr(>|z|)"])
)
}
}
write.table(outTab,file="indep.xls",sep="\t",row.names=F,quote=F)
indepSigExp=exp[,sigGenes]
indepSigExp=cbind(id=row.names(indepSigExp),indepSigExp)
write.table(indepSigExp,file="indepSigExp.txt",sep="\t",row.names=F,quote=F)
运行结果及报错内容
Error in coxph(Surv(futime, fustat) ~ ., data = rt) :
No (non-missing) observations
In addition: Warning message:
In max(event[who2]) : no non-missing arguments to max; returning -Inf
我的解答思路和尝试过的方法
尝试改成:multiCox=coxph(Surv(futime, fustat) ~ rt[,i], data = rt)
###### 我想要达到的结果
代码目前出现错误无法运行
目的:各位大神路过的可不可以帮忙解答一下