除了用X-tile以外,还可以用R确定最适Cut-off值,数据准备如下:
数据存成csv格式。
下面运行代码:
setwd("E:\\最适Cut-off值筛选")
dir()
data <- read.csv("Cut_off.csv",header = T,sep = ",")
head(data)
# > head(data)
# id futime fustat NNMT
#1 TCGA.3Z.A93Z.01 385 0 10.908259
#2 TCGA.6D.AA2E.01 362 0 7.212290
#3 TCGA.A3.3306.01 1120 0 10.814406
#4 TCGA.A3.3307.01 1436 0 10.216313
#5 TCGA.A3.3308.01 16 0 9.110011
#6 TCGA.A3.3311.01 1191 1 9.417845
library(survminer)
res.cut <- surv_cutpoint(data, #数据集
time = "futime", #生存状态
event = "fustat", #生存时间
variables = c("NNMT") #需要计算的数据列名
)
summary(res.cut)
# > summary(res.cut)
# cutpoint statistic
#NNMT 10.25023 2.711016
最适cut-off值为10.25023
下面绘制生存曲线:
data$TIMP1 <- ifelse(data$NNMT>10.25023,"High NNMT expression","Low NNMT expression")
library(survival)
library(coin)
library(survminer)
fit <- survfit(Surv(futime,fustat)~TIMP1,data=data)
fit
head(data)
d <- ggsurvplot_list(fit,data = data,pval = T,conf.int = T,
risk.table = T, # Add risk table
risk.table.col = "strata", # Change risk table color by groups
###linetype = "strata", # Change line type by groups
##surv.median.line = "hv", # Specify median survival
# 定义表格abs表示O绝对值,pct表示占比 absolute number and percentage at risk.
risk.table.y.text.col = F,# 设置为T表示在表格的左边是否显示颜色。colour risk table text annotations.
risk.table.y.text = F,# 设置为FALSE表示在颜色的上边是否显示文字,即“Male”和“Female”。 show bars instead of names in text annotations
# in legend of risk table.
ggtheme = theme_bw()+theme(legend.text = element_text(colour = c("red","blue")))
+theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())
+theme(plot.title = element_text(hjust = 0.5,size = 16,face = "bold"),
axis.title.y.left = element_text(size = 16,face = "bold",vjust = 1),
axis.title.x.bottom = element_text(size = 16,face = "bold",vjust = 0))
+theme(axis.text.x.bottom = element_text(size = 12,face = "bold",vjust = -0.8,colour = "black"))
+theme(axis.text.y.left = element_text(size = 12,face = "bold",vjust = 0.5,hjust = 0.5,
angle = 90,colour = "black"))
+theme(legend.title = element_text(face = "bold",family = "Times",colour = "black",size = 12))
+theme(legend.text = element_text(face = "bold",family = "Times",colour = "black",size =12)), # Change ggplot2 theme
palette = c("red3", "dodgerblue3"),xlim=c(0,5000),xlab = "Days",
legend.labs = c("High NNMT expression","Low NNMT expression"))
d