使用coxph函数绘制森林图,警告相关性无穷,最后报错不知道是什么东西,不知道是不是数据问题
risk=read.table(riskFile, header=T, sep="\t", check.names=F, row.names=1)
> cli=read.table(cliFile, header=T, sep="\t", check.names=F, row.names=1)
> cli=cli[apply(cli,1,function(x)any(is.na(match('unknow',x)))),,drop=F]
> cli$Age=as.numeric(cli$Age)
> sameSample=intersect(row.names(cli), row.names(risk))
> risk=risk[sameSample,]
> cli=cli[sameSample,]
> rt=cbind(futime=risk[,1], fustat=risk[,2], cli, riskScore=risk[,(ncol(risk)-1)])
> multiCox=coxph(Surv(futime, fustat) ~ ., data = rt)
Warning message:
In coxph.fit(X, Y, istrat, offset, init, control, weights = weights, :
Loglik converged before variable 7 ; coefficient may be infinite.
> multiCoxSum=summary(multiCox)
> multiTab=data.frame()
> multiTab=cbind(
+ HR=multiCoxSum$conf.int[,"exp(coef)"],
+ HR.95L=multiCoxSum$conf.int[,"lower .95"],
+ HR.95H=multiCoxSum$conf.int[,"upper .95"],
+ pvalue=multiCoxSum$coefficients[,"Pr(>|z|)"])
> multiTab=cbind(id=row.names(multiTab),multiTab)
> write.table(multiTab, file="cox.result.txt", sep="\t", row.names=F, quote=F)
> #????ɭ??ͼ
> pdf(file="forest.pdf", width=8, height=6, onefile = FALSE)
> ggforest(multiCox,
+ main = "Hazard ratio",
+ cpositions = c(0.02, 0.22, 0.4),
+ fontsize = 0.8,
+ refLabel = "reference",
+ noDigits = 3)
Error in axisTicks(rangeb/2, log = TRUE, nint = 7) :
log - axis(), 'at' creation, _LARGE_ range: invalid {xy}axp or par; nint=7
axp[0:1]=(1e-307,1e+308), usr[0:1]=(0,inf); i=615, ni=87
In addition: Warning message:
In .get_data(model, data = data) :
The `data` argument is not provided. Data will be extracted from model fit.