我们在千聊上的直播间为 MedGo干货课堂,由生物信息界的小红人左手柳叶刀右手小鼠标同学分享~
本期视频免费,不过需要我们发送千聊优惠券,前期会有9张优惠券直接领(不要问我为啥是9张啊,我想写999张的)需要代码和资料的话请您关注医科狗微信公众号:
回复三线表可获取本次课程的代码和课件
回复20190417获取优惠券啦
代码语言:javascript复制代码分享:
#清除环境变量
rm(list=ls())
#加载所需的包
library("survival")
library("survminer")
library(dplyr)
#设置参数
options(stringsAsFactors = F)
#修改工作目录
setwd("C:\Users\czh\Desktop\material")
#读取数据
data <- read.csv("dat.csv",header = T)
#删除缺失观测值
data <- na.omit(data)
#age单因素分析
data_age <- data %>%
dplyr::select(OS.Time, OS,age,ID)
res.cox <- coxph(Surv(OS.Time, OS) ~ age, data = data_age)
summary(res.cox)
#age数据提取
data_age <- data_age %>%
dplyr::select(age,ID)
#性别统计
tbl <- table(data$gender)
cbind(tbl,prop.table(tbl))
#gender数据提取
data_gender <- data
data_gender <- data %>%
dplyr::select(OS.Time, OS,gender,ID)
#gender单因素分析
data_gender <- subset(data_gender,gender =='FEMALE'| gender =='MALE')
data_gender$gender <- ifelse(data_gender$gender == 'FEMALE','1FEMALE','0MALE')
res.cox <- coxph(Surv(OS.Time, OS) ~ gender, data =data_gender)
summary(res.cox)
#grade数据提取
data_grade <- data
data_grade <- data %>%
dplyr::select(OS.Time, OS,grade,ID)
#grade单因素分析
data_grade <- subset(data_grade ,grade=='High Grade'| grade=='Low Grade')
data_grade$grade <- ifelse(data_grade$grade == 'High Grade','1High','0low')
res.cox <- coxph(Surv(OS.Time, OS) ~ grade, data =data_grade )
summary(res.cox)
#tcell数据提取
data_tcell <- data
data_tcell <- data %>%
dplyr::select(OS.Time, OS,Tcell,ID)
#tcell单因素分析
data_tcell$Tcell <- ifelse(data_tcell$Tcell < median(data_tcell[,'Tcell']),'0low','1high ')
res.cox <- coxph(Surv(OS.Time, OS) ~Tcell, data = data_tcell)
summary(res.cox)
#tcell数据提取
data_tcell <- data
data_tcell <- data %>%
dplyr::select(Tcell,ID)
#stage数据提取
data_stage <- data
data_stage <- data %>%
dplyr::select(OS.Time, OS,stage,ID)
#stage单因素分析
data_stage <- subset(data_stage, stage=='Stage II'|stage=='Stage III'| stage=='Stage IV')
res.cox <- coxph(Surv(OS.Time, OS) ~ stage, data =data_stage)
summary(res.cox)
#多因素分析数据准备
data_new <- merge(data_age,data_stage,by='ID')
data_new <- merge(data_new,data_tcell,by='ID')
#多因素分析
res.cox <- coxph(Surv(OS.Time, OS) ~ age stage Tcell ,
data = data_new )
summary(res.cox)
qrcode_for_gh_2f89822775fb_344.jpg