OSCR

Machine learning models based on XGBoost algorithm to predict prognosis of lung cancer brain metastases.

Code ↔ Paper

5 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 5 matches
  1. [1] § Results › Benefits of surgical treatment in LCBM patients ↔ psm&km.R, lines 1–88 · score 0.71 · squamous cell carcinoma, liver metastases, bone metastases, N1, N2, N3
  2. [2] § Results › Benefits of surgical treatment in LCBM patients ↔ data_processing.R, lines 1–49 · score 0.57 · squamous cell carcinoma, N1, N2, N3, females, N0
  3. [3] § Methods › Feature selection and model validation ↔ md_24_36.R, lines 194–216 · score 0.54 · cross validation, confusion matrix, ROC, training, AUC, model
  4. [4] § Methods › Feature selection and model validation ↔ md_6_12.R, lines 192–214 · score 0.54 · cross validation, confusion matrix, ROC, training, AUC, model
  5. [5] § Results › Clinical characteristics of LCBM patients ↔ psm&km.R, lines 1–88 · score 0.53 · household income, NX, N3, lobe, female, N0

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R · 1,367 lines · 64 KB · no license · 2 matches

  1. library("MatchIt")
  2. library(tableone)
  3. library(dplyr)
  4. library("survival")
  5. library("survminer")
  6. set.seed(12345)
  7. data<-read.csv("C:/Users/12184/Desktop/脑转移/LCBM.csv")
  8. data=subset(data,select=-X)
  9. ## 保存为 CSV 格式文件
  10. #write.csv(tabMat, file = "C:/Users/Billy/Desktop/脑转移/合并table_test.csv",fileEncoding="gbk")
  11. data$Age=factor(data$Age,levels=c('15-54','55-64','65-74','75+'))
  12. data$Sex=factor(data$Sex,levels=c('Female','Male'))
  13. data$Race=factor(data$Race,levels=c('White','Black','Others'))
  14. data$Primary.Site=factor(data$Primary.Site,levels=c('Upper lobe, lung','Lower lobe, lung','Lung, NOS','Others'))
  15. data$Histologic.Type=factor(data$Histologic.Type,levels=c('Adenocarcinoma','Squamous cell carcinoma','Others'))
  16. data$Household.income=factor(data$Household.income,levels=c('<$50,000','$50,000-$59,999','$60,000-$69,999','$70,000-$79,999','>$80,000'))
  17. data$T_stage=factor(data$T_stage,levels=c('T1','T2','T3','T4','Others'))
  18. data$N_stage=factor(data$N_stage,levels=c('N0','N1','N2','N3','NX'))
  19. data$Chemotherapy=factor(data$Chemotherapy,levels=c('No/Unknown','Yes'))
  20. data$Radiotherapy=factor(data$Radiotherapy,levels=c('No/Unknown','Yes'))
  21. data$Surgery=factor(data$Surgery,levels=c('No/Unknown','Yes'))
  22. data$Bone.metastases=factor(data$Bone.metastases,levels=c('No/Unknown','Yes'))
  23. data$Liver.metastases=factor(data$Liver.metastases,levels=c('No/Unknown','Yes'))
  24. data$Lung.metastases=factor(data$Lung.metastases,levels=c('No/Unknown','Yes'))
  25. data$Laterality=factor(data$Laterality,levels=c('Right','Left','Others'))
  26. data$Marital.status=factor(data$Marital.status,levels=c('Married','Divorced','No/Unknown'))
  27. data$CS_size=factor(data$CS_size,levels=c('1-30','31-60','61-100','>100','No/Unknown'))
  28. data=subset(data,select=-Lung.metastases)
  29. data=subset(data,select=-Laterality)
  30. data=subset(data,select=-CS_size)
  31. data=subset(data,select=-Marital.status)
  32. #data=data[data$Year.of.diagnosis<=2014,]
  33. ##手术治疗
  34. #########################################################
  35. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income+T_stage
  36. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  37. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=data)
  38. psm_matchit_data = get_matches(psm_matchit)
  39. tabmatched <- CreateTableOne(vars = c("Age","Sex","Race","Primary.Site","Histologic.Type","Household.income",
  40. "T_stage","N_stage","Chemotherapy","Radiotherapy","Bone.metastases","Liver.metastases"),
  41. strata = "Surgery", data = psm_matchit_data, addOverall = TRUE)
  42. a=print(tabmatched, smd = TRUE)## Show table with SMD
  43. tab_before_matched <- CreateTableOne(vars = c("Age","Sex","Race","Primary.Site","Histologic.Type","Household.income",
  44. "T_stage","N_stage","Chemotherapy","Radiotherapy","Bone.metastases","Liver.metastases"),
  45. strata = "Surgery", data = data, addOverall = TRUE)
  46. b=print(tab_before_matched, smd = TRUE)
  47. write.csv(a,"C:/Users/12184/Desktop/脑转移/0513/after_psm_mached.csv", row.names = TRUE)
  48. write.csv(b,"C:/Users/12184/Desktop/脑转移/0513/before_psm_mached.csv", row.names = TRUE)
  49. matched_data<- data[psm_matchit_data$id, ]
  50. fit <- survfit(Surv(Months, Status) ~ Surgery, data = matched_data)
  51. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = matched_data)
  52. sum_cox<-summary(sur_cox)
  53. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  54. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  55. if(p_value<0.0001){
  56. p="P<0.0001"
  57. }else if(p_value<0.001){
  58. p="P<0.001"
  59. }else if(p_value<0.01){
  60. p="P<0.01"
  61. }else if(p_value<0.05){
  62. p="P<0.05"
  63. }else{
  64. p=paste("P=",sprintf("%.3f", p_value))
  65. }
  66. ci <- confint(sur_cox) # 95%置信区间
  67. ci_lower <- exp(ci[, 1]) # 置信区间下限
  68. ci_upper <- exp(ci[, 2])
  69. g<-ggsurvplot(fit, # 创建的拟合对象
  70. #conf.int = TRUE, # 显示置信区间
  71. surv.median.line = "hv", # 添加中位生存时间线
  72. xlab = "Time(months)", # 指定x轴标签
  73. legend = c(0.8,0.75), # 指定图例位置
  74. legend.title = "Surgery", # 设置图例标题
  75. legend.labs = c("No/Unknown", "Yes"), # 指定图例分组标签
  76. title="After PSM-adjusted" # 指定图例分组标签
  77. )
  78. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  79. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  80. color = "Black", size = 5)
  81. print(g)
  82. ##化疗
  83. #########################################################
  84. psm_matchit <- matchit(Chemotherapy ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income+T_stage
  85. +N_stage+Surgery+Radiotherapy+Bone.metastases+Liver.metastases,
  86. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=data)
  87. psm_matchit_data = get_matches(psm_matchit)
  88. tabmatched <- CreateTableOne(vars = c("Age","Sex","Race","Primary.Site","Histologic.Type","Household.income",
  89. "T_stage","N_stage","Surgery","Radiotherapy","Bone.metastases","Liver.metastases"),
  90. strata = "Chemotherapy", data = psm_matchit_data, addOverall = TRUE)
  91. print(tabmatched, smd = TRUE)## Show table with SMD
  92. matched_data<- data[psm_matchit_data$id, ]
  93. fit <- survfit(Surv(Months, Status) ~ Chemotherapy, data = matched_data)
  94. sur_cox<-coxph(Surv(Months,Status) ~ Chemotherapy, data = matched_data)
  95. sum_cox<-summary(sur_cox)
  96. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  97. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  98. if(p_value<0.0001){
  99. p="P<0.0001"
  100. }else if(p_value<0.001){
  101. p="P<0.001"
  102. }else if(p_value<0.01){
  103. p="P<0.01"
  104. }else if(p_value<0.05){
  105. p="P<0.05"
  106. }else{
  107. p=paste("P=",sprintf("%.3f", p_value))
  108. }
  109. ci <- confint(sur_cox) # 95%置信区间
  110. ci_lower <- exp(ci[, 1]) # 置信区间下限
  111. ci_upper <- exp(ci[, 2])
  112. g<-ggsurvplot(fit, # 创建的拟合对象
  113. #conf.int = TRUE, # 显示置信区间
  114. surv.median.line = "hv", # 添加中位生存时间线
  115. xlab = "Time(months)", # 指定x轴标签
  116. legend = c(0.8,0.75), # 指定图例位置
  117. legend.title = "Chemotherapy", # 设置图例标题
  118. legend.labs = c("No/Unknown", "Yes"), # 指定图例分组标签
  119. )
  120. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  121. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  122. color = "Black", size = 5)
  123. print(g)
  124. ##放疗
  125. #########################################################
  126. psm_matchit <- matchit(Radiotherapy ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income+T_stage
  127. +N_stage+Surgery+Chemotherapy+Bone.metastases+Liver.metastases,
  128. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=data)
  129. psm_matchit_data = get_matches(psm_matchit)
  130. tabmatched <- CreateTableOne(vars = c("Age","Sex","Race","Primary.Site","Histologic.Type","Household.income",
  131. "T_stage","N_stage","Surgery","Chemotherapy","Bone.metastases","Liver.metastases"),
  132. strata = "Radiotherapy", data = psm_matchit_data, addOverall = TRUE)
  133. print(tabmatched, smd = TRUE)## Show table with SMD
  134. matched_data<- data[psm_matchit_data$id, ]
  135. fit <- survfit(Surv(Months, Status) ~ Radiotherapy, data = matched_data)
  136. sur_cox<-coxph(Surv(Months,Status) ~ Radiotherapy, data = matched_data)
  137. sum_cox<-summary(sur_cox)
  138. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  139. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  140. if(p_value<0.0001){
  141. p="P<0.0001"
  142. }else if(p_value<0.001){
  143. p="P<0.001"
  144. }else if(p_value<0.01){
  145. p="P<0.01"
  146. }else if(p_value<0.05){
  147. p="P<0.05"
  148. }else{
  149. p=paste("P=",sprintf("%.3f", p_value))
  150. }
  151. ci <- confint(sur_cox) # 95%置信区间
  152. ci_lower <- exp(ci[, 1]) # 置信区间下限
  153. ci_upper <- exp(ci[, 2])
  154. g<-ggsurvplot(fit, # 创建的拟合对象
  155. #conf.int = TRUE, # 显示置信区间
  156. surv.median.line = "hv", # 添加中位生存时间线
  157. xlab = "Time(months)", # 指定x轴标签
  158. legend = c(0.8,0.75), # 指定图例位置
  159. legend.title = "Radiotherapy", # 设置图例标题
  160. legend.labs = c("No/Unknown", "Yes"), # 指定图例分组标签
  161. )
  162. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  163. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  164. color = "Black", size = 5)
  165. print(g)
  166. ##组织学类型
  167. #########################################################################################################################################
  168. temp=data[data$Histologic.Type=="Adenocarcinoma",]
  169. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Household.income+T_stage
  170. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  171. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  172. psm_matchit_data = get_matches(psm_matchit)
  173. H0<- temp[psm_matchit_data$id, ]
  174. fit <- survfit(Surv(Months, Status) ~ Surgery, data = H0)
  175. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = H0)
  176. summary(sur_cox)
  177. sum_cox<-summary(sur_cox)
  178. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  179. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  180. if(p_value<0.0001){
  181. p="P<0.0001"
  182. }else if(p_value<0.001){
  183. p="P<0.001"
  184. }else if(p_value<0.01){
  185. p="P<0.01"
  186. }else if(p_value<0.05){
  187. p="P<0.05"
  188. }else{
  189. p=paste("P=",sprintf("%.3f", p_value))
  190. }
  191. ci <- confint(sur_cox) # 95%置信区间
  192. ci_lower <- exp(ci[, 1]) # 置信区间下限
  193. ci_upper <- exp(ci[, 2])
  194. g<-ggsurvplot(fit, # 创建的拟合对象
  195. surv.median.line = "hv", # 添加中位生存时间线
  196. xlab = "Time(months)", # 指定x轴标签
  197. legend = c(0.8,0.75), # 指定图例位置
  198. legend.title = "Surgery", # 设置图例标题
  199. legend.labs = c("No/Unknown", "Yes"),
  200. title="Histologic Type:Adenocarcinoma" # 指定图例分组标签
  201. )
  202. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  203. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  204. color = "Black", size = 5)
  205. print(g)
  206. ###############################################################################
  207. temp=data[data$Histologic.Type=="Squamous cell carcinoma",]
  208. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Household.income+T_stage
  209. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  210. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  211. psm_matchit_data = get_matches(psm_matchit)
  212. H0<- temp[psm_matchit_data$id, ]
  213. fit <- survfit(Surv(Months, Status) ~ Surgery, data = H0)
  214. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = H0)
  215. summary(sur_cox)
  216. sum_cox<-summary(sur_cox)
  217. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  218. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  219. if(p_value<0.0001){
  220. p="P<0.0001"
  221. }else if(p_value<0.001){
  222. p="P<0.001"
  223. }else if(p_value<0.01){
  224. p="P<0.01"
  225. }else if(p_value<0.05){
  226. p="P<0.05"
  227. }else{
  228. p=paste("P=",sprintf("%.3f", p_value))
  229. }
  230. ci <- confint(sur_cox) # 95%置信区间
  231. ci_lower <- exp(ci[, 1]) # 置信区间下限
  232. ci_upper <- exp(ci[, 2])
  233. g<-ggsurvplot(fit, # 创建的拟合对象
  234. surv.median.line = "hv", # 添加中位生存时间线
  235. xlab = "Time(months)", # 指定x轴标签
  236. legend = c(0.8,0.75), # 指定图例位置
  237. legend.title = "Surgery", # 设置图例标题
  238. legend.labs = c("No/Unknown", "Yes"),
  239. title="Histologic Type:Squamous cell carcinoma" # 指定图例分组标签
  240. )
  241. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  242. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  243. color = "Black", size = 5)
  244. print(g)
  245. ##############################################################################
  246. temp=data[data$Histologic.Type=="Others",]
  247. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Household.income+T_stage
  248. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  249. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  250. psm_matchit_data = get_matches(psm_matchit)
  251. H0<- temp[psm_matchit_data$id, ]
  252. fit <- survfit(Surv(Months, Status) ~ Surgery, data = H0)
  253. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = H0)
  254. sum_cox<-summary(sur_cox)
  255. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  256. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  257. if(p_value<0.0001){
  258. p="P<0.0001"
  259. }else if(p_value<0.001){
  260. p="P<0.001"
  261. }else if(p_value<0.01){
  262. p="P<0.01"
  263. }else if(p_value<0.05){
  264. p="P<0.05"
  265. }else{
  266. p=paste("P=",sprintf("%.3f", p_value))
  267. }
  268. ci <- confint(sur_cox) # 95%置信区间
  269. ci_lower <- exp(ci[, 1]) # 置信区间下限
  270. ci_upper <- exp(ci[, 2])
  271. g<-ggsurvplot(fit, # 创建的拟合对象
  272. surv.median.line = "hv", # 添加中位生存时间线
  273. xlab = "Time(months)", # 指定x轴标签
  274. legend = c(0.8,0.75), # 指定图例位置
  275. legend.title = "Surgery", # 设置图例标题
  276. legend.labs = c("No/Unknown", "Yes"),
  277. title="Histologic Type:Others" # 指定图例分组标签
  278. )
  279. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  280. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  281. color = "Black", size = 5)
  282. print(g)
  283. ##T分期
  284. ######################################################################################################################################################
  285. temp=data[data$T_stage=="T1",]
  286. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  287. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  288. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  289. psm_matchit_data = get_matches(psm_matchit)
  290. T0<- temp[psm_matchit_data$id, ]
  291. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  292. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  293. sum_cox<-summary(sur_cox)
  294. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  295. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  296. if(p_value<0.0001){
  297. p="P<0.0001"
  298. }else if(p_value<0.001){
  299. p="P<0.001"
  300. }else if(p_value<0.01){
  301. p="P<0.01"
  302. }else if(p_value<0.05){
  303. p="P<0.05"
  304. }else{
  305. p=paste("P=",sprintf("%.3f", p_value))
  306. }
  307. ci <- confint(sur_cox) # 95%置信区间
  308. ci_lower <- exp(ci[, 1]) # 置信区间下限
  309. ci_upper <- exp(ci[, 2])
  310. g<-ggsurvplot(fit, # 创建的拟合对象
  311. surv.median.line = "hv", # 添加中位生存时间线
  312. xlab = "Time(months)", # 指定x轴标签
  313. legend = c(0.8,0.75), # 指定图例位置
  314. legend.title = "Surgery", # 设置图例标题
  315. legend.labs = c("No/Unknown", "Yes"),
  316. title="T-stage:T1" # 指定图例分组标签
  317. )
  318. g <- g$plot + annotate("text", x = 60, y = 0.55,
  319. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  320. color = "Black", size = 5)
  321. print(g)
  322. ###########################################################################
  323. temp=data[data$T_stage=="T2",]
  324. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  325. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  326. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  327. psm_matchit_data = get_matches(psm_matchit)
  328. T0<- temp[psm_matchit_data$id, ]
  329. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  330. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  331. sum_cox<-summary(sur_cox)
  332. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  333. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  334. if(p_value<0.0001){
  335. p="P<0.0001"
  336. }else if(p_value<0.001){
  337. p="P<0.001"
  338. }else if(p_value<0.01){
  339. p="P<0.01"
  340. }else if(p_value<0.05){
  341. p="P<0.05"
  342. }else{
  343. p=paste("P=",sprintf("%.3f", p_value))
  344. }
  345. ci <- confint(sur_cox) # 95%置信区间
  346. ci_lower <- exp(ci[, 1]) # 置信区间下限
  347. ci_upper <- exp(ci[, 2])
  348. g<-ggsurvplot(fit, # 创建的拟合对象
  349. surv.median.line = "hv", # 添加中位生存时间线
  350. xlab = "Time(months)", # 指定x轴标签
  351. legend = c(0.8,0.75), # 指定图例位置
  352. legend.title = "Surgery", # 设置图例标题
  353. legend.labs = c("No/Unknown", "Yes"),
  354. title="T-stage:T2" # 指定图例分组标签
  355. )
  356. g <- g$plot + annotate("text", x = 60, y = 0.55,
  357. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  358. color = "Black", size = 5)
  359. print(g)
  360. ###########################################################################
  361. temp=data[data$T_stage=="T3",]
  362. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  363. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  364. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  365. psm_matchit_data = get_matches(psm_matchit)
  366. T0<- temp[psm_matchit_data$id, ]
  367. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  368. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  369. sum_cox<-summary(sur_cox)
  370. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  371. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  372. if(p_value<0.0001){
  373. p="P<0.0001"
  374. }else if(p_value<0.001){
  375. p="P<0.001"
  376. }else if(p_value<0.01){
  377. p="P<0.01"
  378. }else if(p_value<0.05){
  379. p="P<0.05"
  380. }else{
  381. p=paste("P=",sprintf("%.3f", p_value))
  382. }
  383. ci <- confint(sur_cox) # 95%置信区间
  384. ci_lower <- exp(ci[, 1]) # 置信区间下限
  385. ci_upper <- exp(ci[, 2])
  386. g<-ggsurvplot(fit, # 创建的拟合对象
  387. surv.median.line = "hv", # 添加中位生存时间线
  388. xlab = "Time(months)", # 指定x轴标签
  389. legend = c(0.8,0.75), # 指定图例位置
  390. legend.title = "Surgery", # 设置图例标题
  391. legend.labs = c("No/Unknown", "Yes"),
  392. title="T-stage:T3" # 指定图例分组标签
  393. )
  394. g <- g$plot + annotate("text", x = 60, y = 0.55,
  395. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  396. color = "Black", size = 5)
  397. print(g)
  398. ###########################################################################
  399. temp=data[data$T_stage=="T4",]
  400. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  401. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  402. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  403. psm_matchit_data = get_matches(psm_matchit)
  404. T0<- temp[psm_matchit_data$id, ]
  405. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  406. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  407. sum_cox<-summary(sur_cox)
  408. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  409. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  410. if(p_value<0.0001){
  411. p="P<0.0001"
  412. }else if(p_value<0.001){
  413. p="P<0.001"
  414. }else if(p_value<0.01){
  415. p="P<0.01"
  416. }else if(p_value<0.05){
  417. p="P<0.05"
  418. }else{
  419. p=paste("P=",sprintf("%.3f", p_value))
  420. }
  421. ci <- confint(sur_cox) # 95%置信区间
  422. ci_lower <- exp(ci[, 1]) # 置信区间下限
  423. ci_upper <- exp(ci[, 2])
  424. g<-ggsurvplot(fit, # 创建的拟合对象
  425. surv.median.line = "hv", # 添加中位生存时间线
  426. xlab = "Time(months)", # 指定x轴标签
  427. legend = c(0.8,0.75), # 指定图例位置
  428. legend.title = "Surgery", # 设置图例标题
  429. legend.labs = c("No/Unknown", "Yes"),
  430. title="T-stage:T4" # 指定图例分组标签
  431. )
  432. g<- g$plot + annotate("text", x = 60, y = 0.55,
  433. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  434. color = "Black", size = 5)
  435. print(g)
  436. #################################################################################
  437. temp=data[data$T_stage=="Others",]
  438. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  439. +N_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  440. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  441. psm_matchit_data = get_matches(psm_matchit)
  442. T0<- temp[psm_matchit_data$id, ]
  443. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  444. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  445. sum_cox<-summary(sur_cox)
  446. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  447. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  448. if(p_value<0.0001){
  449. p="P<0.0001"
  450. }else if(p_value<0.001){
  451. p="P<0.001"
  452. }else if(p_value<0.01){
  453. p="P<0.01"
  454. }else if(p_value<0.05){
  455. p="P<0.05"
  456. }else{
  457. p=paste("P=",sprintf("%.3f", p_value))
  458. }
  459. ci <- confint(sur_cox) # 95%置信区间
  460. ci_lower <- exp(ci[, 1]) # 置信区间下限
  461. ci_upper <- exp(ci[, 2])
  462. g<-ggsurvplot(fit, # 创建的拟合对象
  463. surv.median.line = "hv", # 添加中位生存时间线
  464. xlab = "Time(months)", # 指定x轴标签
  465. legend = c(0.8,0.75), # 指定图例位置
  466. legend.title = "Surgery", # 设置图例标题
  467. legend.labs = c("No/Unknown", "Yes"),
  468. title="T-stage:Others" # 指定图例分组标签
  469. )
  470. g <- g$plot + annotate("text", x = 60, y = 0.55,
  471. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  472. color = "Black", size = 5)
  473. print(g)
  474. ##N分期
  475. ######################################################################################################################################################
  476. temp=data[data$N_stage=="N0",]
  477. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  478. +T_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  479. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  480. psm_matchit_data = get_matches(psm_matchit)
  481. N0<- temp[psm_matchit_data$id, ]
  482. fit <- survfit(Surv(Months, Status) ~ Surgery, data = N0)
  483. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = N0)
  484. sum_cox<-summary(sur_cox)
  485. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  486. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  487. if(p_value<0.0001){
  488. p="P<0.0001"
  489. }else if(p_value<0.001){
  490. p="P<0.001"
  491. }else if(p_value<0.01){
  492. p="P<0.01"
  493. }else if(p_value<0.05){
  494. p="P<0.05"
  495. }else{
  496. p=paste("P=",sprintf("%.3f", p_value))
  497. }
  498. ci <- confint(sur_cox) # 95%置信区间
  499. ci_lower <- exp(ci[, 1]) # 置信区间下限
  500. ci_upper <- exp(ci[, 2])
  501. g<-ggsurvplot(fit, # 创建的拟合对象
  502. surv.median.line = "hv", # 添加中位生存时间线
  503. xlab = "Time(months)", # 指定x轴标签
  504. legend = c(0.8,0.75), # 指定图例位置
  505. legend.title = "Surgery", # 设置图例标题
  506. legend.labs = c("No/Unknown", "Yes"),
  507. title="N-stage:N0" # 指定图例分组标签
  508. )
  509. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  510. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  511. color = "Black", size = 5)
  512. print(g)
  513. ###########################################################################
  514. temp=data[data$N_stage=="N1",]
  515. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  516. +T_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  517. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  518. psm_matchit_data = get_matches(psm_matchit)
  519. N0<- temp[psm_matchit_data$id, ]
  520. fit <- survfit(Surv(Months, Status) ~ Surgery, data = N0)
  521. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = N0)
  522. sum_cox<-summary(sur_cox)
  523. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  524. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  525. if(p_value<0.0001){
  526. p="P<0.0001"
  527. }else if(p_value<0.001){
  528. p="P<0.001"
  529. }else if(p_value<0.01){
  530. p="P<0.01"
  531. }else if(p_value<0.05){
  532. p="P<0.05"
  533. }else{
  534. p=paste("P=",sprintf("%.3f", p_value))
  535. }
  536. ci <- confint(sur_cox) # 95%置信区间
  537. ci_lower <- exp(ci[, 1]) # 置信区间下限
  538. ci_upper <- exp(ci[, 2])
  539. g<-ggsurvplot(fit, # 创建的拟合对象
  540. surv.median.line = "hv", # 添加中位生存时间线
  541. xlab = "Time(months)", # 指定x轴标签
  542. legend = c(0.8,0.75), # 指定图例位置
  543. legend.title = "Surgery", # 设置图例标题
  544. legend.labs = c("No/Unknown", "Yes"),
  545. title="N-stage:N1" # 指定图例分组标签
  546. )
  547. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  548. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  549. color = "Black", size = 5)
  550. print(g)
  551. ###########################################################################
  552. temp=data[data$N_stage=="N2",]
  553. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  554. +T_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  555. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  556. psm_matchit_data = get_matches(psm_matchit)
  557. N0<- temp[psm_matchit_data$id, ]
  558. fit <- survfit(Surv(Months, Status) ~ Surgery, data = N0)
  559. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = N0)
  560. sum_cox<-summary(sur_cox)
  561. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  562. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  563. if(p_value<0.0001){
  564. p="P<0.0001"
  565. }else if(p_value<0.001){
  566. p="P<0.001"
  567. }else if(p_value<0.01){
  568. p="P<0.01"
  569. }else if(p_value<0.05){
  570. p="P<0.05"
  571. }else{
  572. p=paste("P=",sprintf("%.3f", p_value))
  573. }
  574. ci <- confint(sur_cox) # 95%置信区间
  575. ci_lower <- exp(ci[, 1]) # 置信区间下限
  576. ci_upper <- exp(ci[, 2])
  577. g<-ggsurvplot(fit, # 创建的拟合对象
  578. surv.median.line = "hv", # 添加中位生存时间线
  579. xlab = "Time(months)", # 指定x轴标签
  580. legend = c(0.8,0.75), # 指定图例位置
  581. legend.title = "Surgery", # 设置图例标题
  582. legend.labs = c("No/Unknown", "Yes"),
  583. title="N-stage:N2" # 指定图例分组标签
  584. )
  585. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  586. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  587. color = "Black", size = 5)
  588. print(g)
  589. ###########################################################################
  590. temp=data[data$N_stage=="N3",]
  591. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  592. +T_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  593. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  594. psm_matchit_data = get_matches(psm_matchit)
  595. N0<- temp[psm_matchit_data$id, ]
  596. fit <- survfit(Surv(Months, Status) ~ Surgery, data = N0)
  597. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = N0)
  598. sum_cox<-summary(sur_cox)
  599. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  600. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  601. if(p_value<0.0001){
  602. p="P<0.0001"
  603. }else if(p_value<0.001){
  604. p="P<0.001"
  605. }else if(p_value<0.01){
  606. p="P<0.01"
  607. }else if(p_value<0.05){
  608. p="P<0.05"
  609. }else{
  610. p=paste("P=",sprintf("%.3f", p_value))
  611. }
  612. ci <- confint(sur_cox) # 95%置信区间
  613. ci_lower <- exp(ci[, 1]) # 置信区间下限
  614. ci_upper <- exp(ci[, 2])
  615. g<-ggsurvplot(fit, # 创建的拟合对象
  616. surv.median.line = "hv", # 添加中位生存时间线
  617. xlab = "Time(months)", # 指定x轴标签
  618. legend = c(0.8,0.75), # 指定图例位置
  619. legend.title = "Surgery", # 设置图例标题
  620. legend.labs = c("No/Unknown", "Yes"),
  621. title="N-stage:N3" # 指定图例分组标签
  622. )
  623. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  624. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  625. color = "Black", size = 5)
  626. print(g)
  627. #################################################################################
  628. temp=data[data$N_stage=="NX",]
  629. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  630. +T_stage+Chemotherapy+Radiotherapy+Bone.metastases+Liver.metastases,
  631. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  632. psm_matchit_data = get_matches(psm_matchit)
  633. N0<- temp[psm_matchit_data$id, ]
  634. fit <- survfit(Surv(Months, Status) ~ Surgery, data = N0)
  635. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = N0)
  636. sum_cox<-summary(sur_cox)
  637. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  638. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  639. if(p_value<0.0001){
  640. p="P<0.0001"
  641. }else if(p_value<0.001){
  642. p="P<0.001"
  643. }else if(p_value<0.01){
  644. p="P<0.01"
  645. }else if(p_value<0.05){
  646. p="P<0.05"
  647. }else{
  648. p=paste("P=",sprintf("%.3f", p_value))
  649. }
  650. ci <- confint(sur_cox) # 95%置信区间
  651. ci_lower <- exp(ci[, 1]) # 置信区间下限
  652. ci_upper <- exp(ci[, 2])
  653. g<-ggsurvplot(fit, # 创建的拟合对象
  654. surv.median.line = "hv", # 添加中位生存时间线
  655. xlab = "Time(months)", # 指定x轴标签
  656. legend = c(0.8,0.75), # 指定图例位置
  657. legend.title = "Surgery", # 设置图例标题
  658. legend.labs = c("No/Unknown", "Yes"),
  659. title="N-stage:NX" # 指定图例分组标签
  660. )
  661. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  662. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  663. color = "Black", size = 5)
  664. print(g)
  665. ##肝转移
  666. ######################################################################################################################################################
  667. temp=data[data$Liver.metastases=="Yes",]
  668. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  669. +T_stage+N_stage+Chemotherapy+Radiotherapy+Bone.metastases,
  670. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  671. psm_matchit_data = get_matches(psm_matchit)
  672. T0<- temp[psm_matchit_data$id, ]
  673. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  674. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  675. sum_cox<-summary(sur_cox)
  676. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  677. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  678. if(p_value<0.0001){
  679. p="P<0.0001"
  680. }else if(p_value<0.001){
  681. p="P<0.001"
  682. }else if(p_value<0.01){
  683. p="P<0.01"
  684. }else if(p_value<0.05){
  685. p="P<0.05"
  686. }else{
  687. p=paste("P=",sprintf("%.3f", p_value))
  688. }
  689. ci <- confint(sur_cox) # 95%置信区间
  690. ci_lower <- exp(ci[, 1]) # 置信区间下限
  691. ci_upper <- exp(ci[, 2])
  692. g<-ggsurvplot(fit, # 创建的拟合对象
  693. surv.median.line = "hv", # 添加中位生存时间线
  694. xlab = "Time(months)", # 指定x轴标签
  695. legend = c(0.8,0.75), # 指定图例位置
  696. legend.title = "Surgery", # 设置图例标题
  697. legend.labs = c("No/Unknown", "Yes"),
  698. title="Liver metastases:Yes" # 指定图例分组标签
  699. )
  700. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  701. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  702. color = "Black", size = 5)
  703. print(g)
  704. ######################################################################################################################################################
  705. temp=data[data$Liver.metastases=="No/Unknown",]
  706. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  707. +T_stage+N_stage+Chemotherapy+Radiotherapy+Bone.metastases,
  708. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  709. psm_matchit_data = get_matches(psm_matchit)
  710. T0<- temp[psm_matchit_data$id, ]
  711. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  712. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  713. sum_cox<-summary(sur_cox)
  714. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  715. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  716. if(p_value<0.0001){
  717. p="P<0.0001"
  718. }else if(p_value<0.001){
  719. p="P<0.001"
  720. }else if(p_value<0.01){
  721. p="P<0.01"
  722. }else if(p_value<0.05){
  723. p="P<0.05"
  724. }else{
  725. p=paste("P=",sprintf("%.3f", p_value))
  726. }
  727. ci <- confint(sur_cox) # 95%置信区间
  728. ci_lower <- exp(ci[, 1]) # 置信区间下限
  729. ci_upper <- exp(ci[, 2])
  730. g<-ggsurvplot(fit, # 创建的拟合对象
  731. surv.median.line = "hv", # 添加中位生存时间线
  732. xlab = "Time(months)", # 指定x轴标签
  733. legend = c(0.8,0.75), # 指定图例位置
  734. legend.title = "Surgery", # 设置图例标题
  735. legend.labs = c("No/Unknown", "Yes"),
  736. title="Liver metastases:No/Unknown" # 指定图例分组标签
  737. )
  738. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  739. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  740. color = "Black", size = 5)
  741. print(g)
  742. ##骨转移
  743. ######################################################################################################################################################
  744. temp=data[data$Bone.metastases=="Yes",]
  745. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  746. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases,
  747. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  748. psm_matchit_data = get_matches(psm_matchit)
  749. T0<- temp[psm_matchit_data$id, ]
  750. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  751. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  752. sum_cox<-summary(sur_cox)
  753. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  754. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  755. if(p_value<0.0001){
  756. p="P<0.0001"
  757. }else if(p_value<0.001){
  758. p="P<0.001"
  759. }else if(p_value<0.01){
  760. p="P<0.01"
  761. }else if(p_value<0.05){
  762. p="P<0.05"
  763. }else{
  764. p=paste("P=",sprintf("%.3f", p_value))
  765. }
  766. ci <- confint(sur_cox) # 95%置信区间
  767. ci_lower <- exp(ci[, 1]) # 置信区间下限
  768. ci_upper <- exp(ci[, 2])
  769. g<-ggsurvplot(fit, # 创建的拟合对象
  770. surv.median.line = "hv", # 添加中位生存时间线
  771. xlab = "Time(months)", # 指定x轴标签
  772. legend = c(0.8,0.75), # 指定图例位置
  773. legend.title = "Surgery", # 设置图例标题
  774. legend.labs = c("No/Unknown", "Yes"),
  775. title="Bone metastases:Yes" # 指定图例分组标签
  776. )
  777. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  778. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  779. color = "Black", size = 5)
  780. print(g)
  781. ######################################################################################################################################################
  782. temp=data[data$Bone.metastases=="No/Unknown",]
  783. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Primary.Site+Histologic.Type+Household.income
  784. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases,
  785. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  786. psm_matchit_data = get_matches(psm_matchit)
  787. T0<- temp[psm_matchit_data$id, ]
  788. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  789. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  790. sum_cox<-summary(sur_cox)
  791. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  792. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  793. if(p_value<0.0001){
  794. p="P<0.0001"
  795. }else if(p_value<0.001){
  796. p="P<0.001"
  797. }else if(p_value<0.01){
  798. p="P<0.01"
  799. }else if(p_value<0.05){
  800. p="P<0.05"
  801. }else{
  802. p=paste("P=",sprintf("%.3f", p_value))
  803. }
  804. ci <- confint(sur_cox) # 95%置信区间
  805. ci_lower <- exp(ci[, 1]) # 置信区间下限
  806. ci_upper <- exp(ci[, 2])
  807. g<-ggsurvplot(fit, # 创建的拟合对象
  808. surv.median.line = "hv", # 添加中位生存时间线
  809. xlab = "Time(months)", # 指定x轴标签
  810. legend = c(0.8,0.75), # 指定图例位置
  811. legend.title = "Surgery", # 设置图例标题
  812. legend.labs = c("No/Unknown", "Yes"),
  813. title="Bone metastases:No/Unknown" # 指定图例分组标签
  814. )
  815. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  816. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  817. color = "Black", size = 5)
  818. print(g)
  819. ##原发位点
  820. ######################################################################################################################################################
  821. temp=data[data$Primary.Site=="Upper lobe, lung",]
  822. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Histologic.Type+Household.income
  823. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  824. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  825. psm_matchit_data = get_matches(psm_matchit)
  826. T0<- temp[psm_matchit_data$id, ]
  827. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  828. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  829. sum_cox<-summary(sur_cox)
  830. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  831. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  832. if(p_value<0.0001){
  833. p="P<0.0001"
  834. }else if(p_value<0.001){
  835. p="P<0.001"
  836. }else if(p_value<0.01){
  837. p="P<0.01"
  838. }else if(p_value<0.05){
  839. p="P<0.05"
  840. }else{
  841. p=paste("P=",sprintf("%.3f", p_value))
  842. }
  843. ci <- confint(sur_cox) # 95%置信区间
  844. ci_lower <- exp(ci[, 1]) # 置信区间下限
  845. ci_upper <- exp(ci[, 2])
  846. g<-ggsurvplot(fit, # 创建的拟合对象
  847. surv.median.line = "hv", # 添加中位生存时间线
  848. xlab = "Time(months)", # 指定x轴标签
  849. legend = c(0.8,0.75), # 指定图例位置
  850. legend.title = "Surgery", # 设置图例标题
  851. legend.labs = c("No/Unknown", "Yes"),
  852. title="Primary.Site:Upper lobe, lung" # 指定图例分组标签
  853. )
  854. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  855. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  856. color = "Black", size = 5)
  857. print(g)
  858. ######################################################################################################################################################
  859. temp=data[data$Primary.Site=="Lower lobe, lung",]
  860. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Histologic.Type+Household.income
  861. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  862. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  863. psm_matchit_data = get_matches(psm_matchit)
  864. T0<- temp[psm_matchit_data$id, ]
  865. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  866. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  867. sum_cox<-summary(sur_cox)
  868. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  869. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  870. if(p_value<0.0001){
  871. p="P<0.0001"
  872. }else if(p_value<0.001){
  873. p="P<0.001"
  874. }else if(p_value<0.01){
  875. p="P<0.01"
  876. }else if(p_value<0.05){
  877. p="P<0.05"
  878. }else{
  879. p=paste("P=",sprintf("%.3f", p_value))
  880. }
  881. ci <- confint(sur_cox) # 95%置信区间
  882. ci_lower <- exp(ci[, 1]) # 置信区间下限
  883. ci_upper <- exp(ci[, 2])
  884. g<-ggsurvplot(fit, # 创建的拟合对象
  885. surv.median.line = "hv", # 添加中位生存时间线
  886. xlab = "Time(months)", # 指定x轴标签
  887. legend = c(0.8,0.75), # 指定图例位置
  888. legend.title = "Surgery", # 设置图例标题
  889. legend.labs = c("No/Unknown", "Yes"),
  890. title="Primary.Site:Lower lobe, lung" # 指定图例分组标签
  891. )
  892. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  893. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  894. color = "Black", size = 5)
  895. print(g)
  896. ######################################################################################################################################################
  897. temp=data[data$Primary.Site=="Lung, NOS",]
  898. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Histologic.Type+Household.income
  899. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  900. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  901. psm_matchit_data = get_matches(psm_matchit)
  902. T0<- temp[psm_matchit_data$id, ]
  903. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  904. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  905. sum_cox<-summary(sur_cox)
  906. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  907. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  908. if(p_value<0.0001){
  909. p="P<0.0001"
  910. }else if(p_value<0.001){
  911. p="P<0.001"
  912. }else if(p_value<0.01){
  913. p="P<0.01"
  914. }else if(p_value<0.05){
  915. p="P<0.05"
  916. }else{
  917. p=paste("P=",sprintf("%.3f", p_value))
  918. }
  919. ci <- confint(sur_cox) # 95%置信区间
  920. ci_lower <- exp(ci[, 1]) # 置信区间下限
  921. ci_upper <- exp(ci[, 2])
  922. g<-ggsurvplot(fit, # 创建的拟合对象
  923. surv.median.line = "hv", # 添加中位生存时间线
  924. xlab = "Time(months)", # 指定x轴标签
  925. legend = c(0.8,0.75), # 指定图例位置
  926. legend.title = "Surgery", # 设置图例标题
  927. legend.labs = c("No/Unknown", "Yes"),
  928. title="Primary.Site:Lung, NOS" # 指定图例分组标签
  929. )
  930. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  931. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  932. color = "Black", size = 5)
  933. print(g)
  934. ######################################################################################################################################################
  935. temp=data[data$Primary.Site=="Others",]
  936. psm_matchit <- matchit(Surgery ~ Age+Sex+Race+Histologic.Type+Household.income
  937. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  938. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  939. psm_matchit_data = get_matches(psm_matchit)
  940. T0<- temp[psm_matchit_data$id, ]
  941. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  942. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  943. sum_cox<-summary(sur_cox)
  944. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  945. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  946. if(p_value<0.0001){
  947. p="P<0.0001"
  948. }else if(p_value<0.001){
  949. p="P<0.001"
  950. }else if(p_value<0.01){
  951. p="P<0.01"
  952. }else if(p_value<0.05){
  953. p="P<0.05"
  954. }else{
  955. p=paste("P=",sprintf("%.3f", p_value))
  956. }
  957. ci <- confint(sur_cox) # 95%置信区间
  958. ci_lower <- exp(ci[, 1]) # 置信区间下限
  959. ci_upper <- exp(ci[, 2])
  960. g<-ggsurvplot(fit, # 创建的拟合对象
  961. surv.median.line = "hv", # 添加中位生存时间线
  962. xlab = "Time(months)", # 指定x轴标签
  963. legend = c(0.8,0.75), # 指定图例位置
  964. legend.title = "Surgery", # 设置图例标题
  965. legend.labs = c("No/Unknown", "Yes"),
  966. title="Primary.Site:Others" # 指定图例分组标签
  967. )
  968. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  969. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  970. color = "Black", size = 5)
  971. print(g)
  972. ##性别
  973. ######################################################################################################################################################
  974. temp=data[data$Sex=="Female",]
  975. psm_matchit <- matchit(Surgery ~ Age+Race+Primary.Site+Histologic.Type+Household.income
  976. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  977. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  978. psm_matchit_data = get_matches(psm_matchit)
  979. T0<- temp[psm_matchit_data$id, ]
  980. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  981. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  982. sum_cox<-summary(sur_cox)
  983. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  984. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  985. if(p_value<0.0001){
  986. p="P<0.0001"
  987. }else if(p_value<0.001){
  988. p="P<0.001"
  989. }else if(p_value<0.01){
  990. p="P<0.01"
  991. }else if(p_value<0.05){
  992. p="P<0.05"
  993. }else{
  994. p=paste("P=",sprintf("%.3f", p_value))
  995. }
  996. ci <- confint(sur_cox) # 95%置信区间
  997. ci_lower <- exp(ci[, 1]) # 置信区间下限
  998. ci_upper <- exp(ci[, 2])
  999. g<-ggsurvplot(fit, # 创建的拟合对象
  1000. surv.median.line = "hv", # 添加中位生存时间线
  1001. xlab = "Time(months)", # 指定x轴标签
  1002. legend = c(0.8,0.75), # 指定图例位置
  1003. legend.title = "Surgery", # 设置图例标题
  1004. legend.labs = c("No/Unknown", "Yes"),
  1005. title="Sex:Female" # 指定图例分组标签
  1006. )
  1007. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1008. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1009. color = "Black", size = 5)
  1010. print(g)
  1011. ######################################################################################################################################################
  1012. temp=data[data$Sex=="Male",]
  1013. psm_matchit <- matchit(Surgery ~ Age+Race+Primary.Site+Histologic.Type+Household.income
  1014. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1015. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1016. psm_matchit_data = get_matches(psm_matchit)
  1017. T0<- temp[psm_matchit_data$id, ]
  1018. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1019. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1020. sum_cox<-summary(sur_cox)
  1021. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1022. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1023. if(p_value<0.0001){
  1024. p="P<0.0001"
  1025. }else if(p_value<0.001){
  1026. p="P<0.001"
  1027. }else if(p_value<0.01){
  1028. p="P<0.01"
  1029. }else if(p_value<0.05){
  1030. p="P<0.05"
  1031. }else{
  1032. p=paste("P=",sprintf("%.3f", p_value))
  1033. }
  1034. ci <- confint(sur_cox) # 95%置信区间
  1035. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1036. ci_upper <- exp(ci[, 2])
  1037. g<-ggsurvplot(fit, # 创建的拟合对象
  1038. surv.median.line = "hv", # 添加中位生存时间线
  1039. xlab = "Time(months)", # 指定x轴标签
  1040. legend = c(0.8,0.75), # 指定图例位置
  1041. legend.title = "Surgery", # 设置图例标题
  1042. legend.labs = c("No/Unknown", "Yes"),
  1043. title="Sex:Male" # 指定图例分组标签
  1044. )
  1045. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1046. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1047. color = "Black", size = 5)
  1048. print(g)
  1049. ##种族
  1050. ######################################################################################################################################################
  1051. temp=data[data$Race=="White",]
  1052. psm_matchit <- matchit(Surgery ~ Age+Sex+Primary.Site+Histologic.Type+Household.income
  1053. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1054. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1055. psm_matchit_data = get_matches(psm_matchit)
  1056. T0<- temp[psm_matchit_data$id, ]
  1057. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1058. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1059. sum_cox<-summary(sur_cox)
  1060. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1061. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1062. if(p_value<0.0001){
  1063. p="P<0.0001"
  1064. }else if(p_value<0.001){
  1065. p="P<0.001"
  1066. }else if(p_value<0.01){
  1067. p="P<0.01"
  1068. }else if(p_value<0.05){
  1069. p="P<0.05"
  1070. }else{
  1071. p=paste("P=",sprintf("%.3f", p_value))
  1072. }
  1073. ci <- confint(sur_cox) # 95%置信区间
  1074. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1075. ci_upper <- exp(ci[, 2])
  1076. g<-ggsurvplot(fit, # 创建的拟合对象
  1077. surv.median.line = "hv", # 添加中位生存时间线
  1078. xlab = "Time(months)", # 指定x轴标签
  1079. legend = c(0.8,0.75), # 指定图例位置
  1080. legend.title = "Surgery", # 设置图例标题
  1081. legend.labs = c("No/Unknown", "Yes"),
  1082. title="Race:White" # 指定图例分组标签
  1083. )
  1084. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1085. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1086. color = "Black", size = 5)
  1087. print(g)
  1088. ######################################################################################################################################################
  1089. temp=data[data$Race=="Black",]
  1090. psm_matchit <- matchit(Surgery ~ Age+Sex+Primary.Site+Histologic.Type+Household.income
  1091. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1092. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1093. psm_matchit_data = get_matches(psm_matchit)
  1094. T0<- temp[psm_matchit_data$id, ]
  1095. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1096. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1097. sum_cox<-summary(sur_cox)
  1098. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1099. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1100. if(p_value<0.0001){
  1101. p="P<0.0001"
  1102. }else if(p_value<0.001){
  1103. p="P<0.001"
  1104. }else if(p_value<0.01){
  1105. p="P<0.01"
  1106. }else if(p_value<0.05){
  1107. p="P<0.05"
  1108. }else{
  1109. p=paste("P=",sprintf("%.3f", p_value))
  1110. }
  1111. ci <- confint(sur_cox) # 95%置信区间
  1112. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1113. ci_upper <- exp(ci[, 2])
  1114. g<-ggsurvplot(fit, # 创建的拟合对象
  1115. surv.median.line = "hv", # 添加中位生存时间线
  1116. xlab = "Time(months)", # 指定x轴标签
  1117. legend = c(0.8,0.75), # 指定图例位置
  1118. legend.title = "Surgery", # 设置图例标题
  1119. legend.labs = c("No/Unknown", "Yes"),
  1120. title="Race:Black" # 指定图例分组标签
  1121. )
  1122. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1123. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1124. color = "Black", size = 5)
  1125. print(g)
  1126. ######################################################################################################################################################
  1127. temp=data[data$Race=="Others",]
  1128. psm_matchit <- matchit(Surgery ~ Age+Sex+Primary.Site+Histologic.Type+Household.income
  1129. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1130. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1131. psm_matchit_data = get_matches(psm_matchit)
  1132. T0<- temp[psm_matchit_data$id, ]
  1133. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1134. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1135. sum_cox<-summary(sur_cox)
  1136. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1137. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1138. if(p_value<0.0001){
  1139. p="P<0.0001"
  1140. }else if(p_value<0.001){
  1141. p="P<0.001"
  1142. }else if(p_value<0.01){
  1143. p="P<0.01"
  1144. }else if(p_value<0.05){
  1145. p="P<0.05"
  1146. }else{
  1147. p=paste("P=",sprintf("%.3f", p_value))
  1148. }
  1149. ci <- confint(sur_cox) # 95%置信区间
  1150. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1151. ci_upper <- exp(ci[, 2])
  1152. g<-ggsurvplot(fit, # 创建的拟合对象
  1153. surv.median.line = "hv", # 添加中位生存时间线
  1154. xlab = "Time(months)", # 指定x轴标签
  1155. legend = c(0.8,0.75), # 指定图例位置
  1156. legend.title = "Surgery", # 设置图例标题
  1157. legend.labs = c("No/Unknown", "Yes"),
  1158. title="Race:Others" # 指定图例分组标签
  1159. )
  1160. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1161. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1162. color = "Black", size = 5)
  1163. print(g)
  1164. ##年龄
  1165. ######################################################################################################################################################
  1166. temp=data[data$Age=="15-54",]
  1167. psm_matchit <- matchit(Surgery ~ Race+Sex+Primary.Site+Histologic.Type+Household.income
  1168. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1169. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1170. psm_matchit_data = get_matches(psm_matchit)
  1171. T0<- temp[psm_matchit_data$id, ]
  1172. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1173. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1174. sum_cox<-summary(sur_cox)
  1175. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1176. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1177. if(p_value<0.0001){
  1178. p="P<0.0001"
  1179. }else if(p_value<0.001){
  1180. p="P<0.001"
  1181. }else if(p_value<0.01){
  1182. p="P<0.01"
  1183. }else if(p_value<0.05){
  1184. p="P<0.05"
  1185. }else{
  1186. p=paste("P=",sprintf("%.3f", p_value))
  1187. }
  1188. ci <- confint(sur_cox) # 95%置信区间
  1189. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1190. ci_upper <- exp(ci[, 2])
  1191. g<-ggsurvplot(fit, # 创建的拟合对象
  1192. surv.median.line = "hv", # 添加中位生存时间线
  1193. xlab = "Time(months)", # 指定x轴标签
  1194. legend = c(0.8,0.75), # 指定图例位置
  1195. legend.title = "Surgery", # 设置图例标题
  1196. legend.labs = c("No/Unknown", "Yes"),
  1197. title="Age:15-54" # 指定图例分组标签
  1198. )
  1199. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1200. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1201. color = "Black", size = 5)
  1202. print(g)
  1203. ######################################################################################################################################################
  1204. temp=data[data$Age=="55-64",]
  1205. psm_matchit <- matchit(Surgery ~ Race+Sex+Primary.Site+Histologic.Type+Household.income
  1206. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1207. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1208. psm_matchit_data = get_matches(psm_matchit)
  1209. T0<- temp[psm_matchit_data$id, ]
  1210. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1211. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1212. sum_cox<-summary(sur_cox)
  1213. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1214. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1215. if(p_value<0.0001){
  1216. p="P<0.0001"
  1217. }else if(p_value<0.001){
  1218. p="P<0.001"
  1219. }else if(p_value<0.01){
  1220. p="P<0.01"
  1221. }else if(p_value<0.05){
  1222. p="P<0.05"
  1223. }else{
  1224. p=paste("P=",sprintf("%.3f", p_value))
  1225. }
  1226. ci <- confint(sur_cox) # 95%置信区间
  1227. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1228. ci_upper <- exp(ci[, 2])
  1229. g<-ggsurvplot(fit, # 创建的拟合对象
  1230. surv.median.line = "hv", # 添加中位生存时间线
  1231. xlab = "Time(months)", # 指定x轴标签
  1232. legend = c(0.8,0.75), # 指定图例位置
  1233. legend.title = "Surgery", # 设置图例标题
  1234. legend.labs = c("No/Unknown", "Yes"),
  1235. title="Age:55-64" # 指定图例分组标签
  1236. )
  1237. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1238. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1239. color = "Black", size = 5)
  1240. print(g)
  1241. ######################################################################################################################################################
  1242. temp=data[data$Age=="65-74",]
  1243. psm_matchit <- matchit(Surgery ~ Race+Sex+Primary.Site+Histologic.Type+Household.income
  1244. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1245. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1246. psm_matchit_data = get_matches(psm_matchit)
  1247. T0<- temp[psm_matchit_data$id, ]
  1248. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1249. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1250. sum_cox<-summary(sur_cox)
  1251. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1252. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1253. if(p_value<0.0001){
  1254. p="P<0.0001"
  1255. }else if(p_value<0.001){
  1256. p="P<0.001"
  1257. }else if(p_value<0.01){
  1258. p="P<0.01"
  1259. }else if(p_value<0.05){
  1260. p="P<0.05"
  1261. }else{
  1262. p=paste("P=",sprintf("%.3f", p_value))
  1263. }
  1264. ci <- confint(sur_cox) # 95%置信区间
  1265. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1266. ci_upper <- exp(ci[, 2])
  1267. g<-ggsurvplot(fit, # 创建的拟合对象
  1268. surv.median.line = "hv", # 添加中位生存时间线
  1269. xlab = "Time(months)", # 指定x轴标签
  1270. legend = c(0.8,0.75), # 指定图例位置
  1271. legend.title = "Surgery", # 设置图例标题
  1272. legend.labs = c("No/Unknown", "Yes"),
  1273. title="Age:65-74" # 指定图例分组标签
  1274. )
  1275. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1276. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1277. color = "Black", size = 5)
  1278. print(g)
  1279. ######################################################################################################################################################
  1280. temp=data[data$Age=="75+",]
  1281. psm_matchit <- matchit(Surgery ~ Race+Sex+Primary.Site+Histologic.Type+Household.income
  1282. +T_stage+N_stage+Chemotherapy+Radiotherapy+Liver.metastases+Bone.metastases,
  1283. method='nearest', distance = 'glm', ratio=1, replace=F, caliper=0.2, data=temp)
  1284. psm_matchit_data = get_matches(psm_matchit)
  1285. T0<- temp[psm_matchit_data$id, ]
  1286. fit <- survfit(Surv(Months, Status) ~ Surgery, data = T0)
  1287. sur_cox<-coxph(Surv(Months,Status) ~ Surgery, data = T0)
  1288. sum_cox<-summary(sur_cox)
  1289. hr <- exp(sum_cox$coefficients[, "coef"]) # 回归系数
  1290. p_value <- sum_cox$coefficients[, "Pr(>|z|)"] # P值
  1291. if(p_value<0.0001){
  1292. p="P<0.0001"
  1293. }else if(p_value<0.001){
  1294. p="P<0.001"
  1295. }else if(p_value<0.01){
  1296. p="P<0.01"
  1297. }else if(p_value<0.05){
  1298. p="P<0.05"
  1299. }else{
  1300. p=paste("P=",sprintf("%.3f", p_value))
  1301. }
  1302. ci <- confint(sur_cox) # 95%置信区间
  1303. ci_lower <- exp(ci[, 1]) # 置信区间下限
  1304. ci_upper <- exp(ci[, 2])
  1305. g<-ggsurvplot(fit, # 创建的拟合对象
  1306. surv.median.line = "hv", # 添加中位生存时间线
  1307. xlab = "Time(months)", # 指定x轴标签
  1308. legend = c(0.8,0.75), # 指定图例位置
  1309. legend.title = "Surgery", # 设置图例标题
  1310. legend.labs = c("No/Unknown", "Yes"),
  1311. title="Age:75+" # 指定图例分组标签
  1312. )
  1313. g$plot <- g$plot + annotate("text", x = 60, y = 0.55,
  1314. label = paste("HR:", sprintf("%.3f", hr), "\n(95% CI:", sprintf("%.3f", ci_lower), "-", sprintf("%.3f", ci_upper),")","\n",p),
  1315. color = "Black", size = 5)
  1316. print(g)

psm&km.R at commit b02b9bd, no license · at the source

Overview

Authors: Chutong Lin1, Zhijie Gong2, Xinyu Zhang3, Fangjun Chen4, Guangliang Qiang1
  1. Thoracic Surgery Department, Peking University Third Hospital, Beijing, China
  2. School of Management, University of Science and Technology of China, Hefei, China
  3. Academy of Mathematics and Systems Science, Chinese Academy of Sciences, Beijing, China
  4. Thoracic Surgery Department, China-Japan Friendship Institute of Clinical Medicine Research, Beijing, China
Journal: Journal of thoracic disease, volume 18, issue 7, article 767
Dates: received 13 April 2026; accepted 28 May 2026; published online 10 June 2026; in print 31 July 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.21037/jtd-2026-0997 · PMID 42583236 · PMCID PMC13460187 · OpenAlex W7171831482
Open access: diamond, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), other condition (population), clinical / translational (subfield)
Methods: Machine learning, Statistics
Keywords: Lung cancer, brain metastasis, prognosis, extreme gradient boosting algorithm (XGBoost algorithm), machine learning
Topic: Brain Tumor Detection and Classification (Neurology, Neuroscience), according to OpenAlex
Funding: Key Clinical Projects of Peking University Third Hospital (Nos. BYSYRCYJ2023001, BYSYZD2025049)
Citations: not cited yet (Europe PMC); 45 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 5 matches between paragraphs and lines of code.

linastro/machine-learning-models-based-on-xgboost

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: b02b9bda0082f1ae3acbd6f8bc0f55ba8fe8ac2b, 29 May 2025
Languages: R (6)
Size: 6 files, 6 scripts
Software Heritage: not archived
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (6 files), survival (5 files), caret (3 files), ggplot2 (3 files), pROC (3 files), XGBoost (3 files), randomForest (2 files)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
6 files

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.21037/jtd-2026-0997.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 6 scripts, each with its path and the digest of its content;
  • 5 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 5 keywords, 1 funder, 44 references.

Cite

This paper

Lin, C., Gong, Z., Zhang, X., Chen, F., & Qiang, G. (2026). Machine learning models based on XGBoost algorithm to predict prognosis of lung cancer brain metastases. Journal of thoracic disease, 18(7), 767. https://doi.org/10.21037/jtd-2026-0997

BibTeX

@article{lin2026machine,
author = {Lin, Chutong and Gong, Zhijie and Zhang, Xinyu and Chen, Fangjun and Qiang, Guangliang},
title = {{Machine learning models based on XGBoost algorithm to predict prognosis of lung cancer brain metastases}},
journal = {Journal of thoracic disease},
year = {2026},
month = jun,
volume = {18},
number = {7},
pages = {767},
publisher = {AME Publications},
issn = {2072-1439},
doi = {10.21037/jtd-2026-0997},
url = {https://doi.org/10.21037/jtd-2026-0997},
pmid = {42583236},
pmcid = {PMC13460187}
}

RIS

TY - JOUR
AU - Lin, Chutong
AU - Gong, Zhijie
AU - Zhang, Xinyu
AU - Chen, Fangjun
AU - Qiang, Guangliang
TI - Machine learning models based on XGBoost algorithm to predict prognosis of lung cancer brain metastases
T2 - Journal of thoracic disease
J2 - J Thorac Dis
PY - 2026
DA - 2026/06/10
VL - 18
IS - 7
SP - 767
SN - 2072-1439
PB - AME Publications
DO - 10.21037/jtd-2026-0997
UR - https://doi.org/10.21037/jtd-2026-0997
LA - en
ER -

CSL-JSON

{
"id": "10.21037/jtd-2026-0997",
"type": "article-journal",
"title": "Machine learning models based on XGBoost algorithm to predict prognosis of lung cancer brain metastases",
"container-title": "Journal of thoracic disease",
"author": [
{
"family": "Lin",
"given": "Chutong"
},
{
"family": "Gong",
"given": "Zhijie"
},
{
"family": "Zhang",
"given": "Xinyu"
},
{
"family": "Chen",
"given": "Fangjun"
},
{
"family": "Qiang",
"given": "Guangliang"
}
],
"container-title-short": "J Thorac Dis",
"volume": "18",
"issue": "7",
"page": "767",
"DOI": "10.21037/jtd-2026-0997",
"PMID": "42583236",
"PMCID": "PMC13460187",
"ISSN": "2072-1439",
"publisher": "AME Publications",
"URL": "https://doi.org/10.21037/jtd-2026-0997",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
10
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.3390/ijms27156925 [code]
XGBoost-SHAP Interpretable Modeling Identifies and Validates an Eight-Gene Biomarker for Hepatic Encephalopathy Risk Prediction in Cirrhosis.
Journal: International journal of molecular sciences
In common: randomForest, pROC, survival, 4 other tools, other condition
[2] doi:10.1038/s41467-026-77170-3 [code]
DNA methylation profiling identifies long-range epigenetic silencing of clustered protocadherins as a key determinant of meningioma progression.
Journal: Nature communications
In common: randomForest, pROC, survival, 3 other tools, other condition
[3] doi:10.1038/s42003-026-10957-8 [code]
Brain defence by the extracellular matrix protein Cochlin.
Journal: Communications biology
In common: randomForest, survival, caret, 3 other tools
[4] doi:10.3390/ijms27125533 [code]
Discovery-Driven Plasma Proteomics Identifies a Multi-Protein Signature for Amyloid PET Positivity: A Machine Learning Analysis of the Bio-Hermes Cohort.
Journal: International journal of molecular sciences
In common: randomForest, pROC, caret, 2 other tools
[5] doi:10.1093/neuonc/noag128 [code]
Spatially-resolved single-cell imaging of melanoma brain metastases identifies localized immune patterns predictive of immune checkpoint blockade response.
Journal: Neuro-oncology
In common: pROC, survival, caret, 2 other tools, clinical / translational, other condition
[6] doi:10.1371/journal.pmed.1004868 [code]
Plasma proteomic signatures of early retinal neurodegeneration in diabetes: A multi-cohort study.
Journal: PLoS medicine
In common: pROC, survival, caret, 2 other tools, clinical / translational, other condition
[7] doi:10.1093/bioinformatics/btag592 [code]
Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.
Journal: Bioinformatics (Oxford, England)
In common: randomForest, pROC, survival, 2 other tools, other condition
[8] doi:10.1177/13872877261471049 [code]
Predicting future brain atrophy based on longitudinal MRI.
Journal: Journal of Alzheimer's disease : JAD
In common: randomForest, pROC, caret, 2 other tools, clinical / translational
[9] doi:10.1073/pnas.2516601123 [code]
Unveiling the glymphatic system's role in brain aging: A comprehensive biomarker and modifiable intervention target.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: pROC, survival, XGBoost, 2 other tools, clinical / translational
[10] doi:10.7717/peerj.21426 [code]
Integrated transcriptomic identification and validation reveal key autophagy-associated biomarkers in sleep deprivation.
Journal: PeerJ
In common: randomForest, pROC, caret, 2 other tools

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.