基因表达量作为连续变量,可以利用单因素cox回归筛选目标基因,也可以根据基因表达的中位值分为高低表达组,用KM方法检测与预后的关系,下面就介绍下联合unicox、KM筛选预后目标基因的方法。直接上代码:
library(survival)
library(survminer)
outTab=data.frame()
for(i in colnames(rt[,3:ncol(rt)])){
#cox分析
cox <- coxph(Surv(futime, fustat) ~ rt[,i], data = rt)
coxSummary = summary(cox)
#KM分析
group=ifelse(rt[,i]>median(rt[,i]),"high","low")
if(length(table(group))==1) return(NULL) #去掉表达量无变化的基因
diff=survdiff(Surv(futime, fustat) ~group,data = rt)
pValue=1-pchisq(diff$chisq,df=1)
outTab=rbind(outTab,
cbind(id=i,
KM=pValue,
HR=coxSummary$conf.int[,"exp(coef)"],
HR.95L=coxSummary$conf.int[,"lower .95"],
HR.95H=coxSummary$conf.int[,"upper .95"],
pvalue=coxSummary$coefficients[,"Pr(>|z|)"]))
}
unicox+KM筛选目标基因
网友评论