美文网首页
生存曲线——从GDC下载的临床数据分析

生存曲线——从GDC下载的临床数据分析

作者: 陈宇乔 | 来源:发表于2019-08-08 16:17 被阅读0次

这几句是关键

phe$days_to_death[phe$days_to_death=='']=0
phe$days_to_last_followup[phe$days_to_last_followup=='']=0
phe$days_to_death<- as.numeric(as.character(phe$days_to_death))
phe$days_to_last_followup<- as.numeric(as.character(phe$days_to_last_followup))
phe$time<- ifelse(phe$days_to_death!= 0,phe$days_to_death,phe$days_to_last_followup)
phe$event<- as.numeric(phe$vital_status)
# phe$time[phe$time==0]<- NA 这一句话有没有结果都一样,所以time==0 和time ==NA 效果是一样的

首先没有数据的设置为0,然后将factor转为numeric。最后做整合



exprSet<- as.data.frame(t(frac.m))
group_list=ifelse(as.numeric(substr(colnames(exprSet),14,15)) < 10,'tumor','normal')

exprSet<- exprSet[,group_list=='tumor']
phe<- clinical_data[clinical_data$tcag_barcode%in%colnames(exprSet),]
phe$days_to_death[phe$days_to_death=='']=0
phe$days_to_last_followup[phe$days_to_last_followup=='']=0
phe$days_to_death<- as.numeric(as.character(phe$days_to_death))
phe$days_to_last_followup<- as.numeric(as.character(phe$days_to_last_followup))
phe$time<- ifelse(phe$days_to_death!= 0,phe$days_to_death,phe$days_to_last_followup)
phe$event<- as.numeric(phe$vital_status)
# phe$time[phe$time==0]<- NA 这一句话有没有结果都一样,所以time==0 和time ==NA 效果是一样的


library(survminer)
library(survival)
library(ggplot2)
match(colnames(exprSet),phe$tcag_barcode)
#########################单基因生存分析
exprSet<- as.data.frame(t(exprSet))
colnames(exprSet)
cell_name<- 'Neutro'
# gene_name<- 'PAX1'

# dev.off()
if(cell_name%in%colnames(exprSet)){
  phe$group=ifelse(exprSet[,cell_name]>quantile(exprSet[,cell_name],0.5),'high','low')
  table(phe$group)
  ggsurvplot(survfit(Surv(time, event)~group, data=phe), conf.int=F, pval=TRUE,legend.title = cell_name)
}

cell_name<- colnames(exprSet)

for (x in cell_name) {
  phe$group=ifelse(exprSet[,x]>quantile(exprSet[,x],0.5),'high','low')
  table(phe$group)
  pp<- ggsurvplot(survfit(Surv(time, event)~group, data=phe), conf.int=F, pval=TRUE,legend.title = cell_name)
  ggsave(filename = paste("plot_",x,".pdf",sep = ""))
  print(x)
}
image.png

相关文章

网友评论

      本文标题:生存曲线——从GDC下载的临床数据分析

      本文链接:https://www.haomeiwen.com/subject/tcgxjctx.html