##chargement des packages----
library(questionr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.1     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tableone)
library(labelled)
library(gtsummary)
library(GGally)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
library(readxl)
library(effects)
## Le chargement a nécessité le package : carData
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
library(survival)
library(survminer)
## Le chargement a nécessité le package : ggpubr
## 
## Attachement du package : 'survminer'
## 
## L'objet suivant est masqué depuis 'package:survival':
## 
##     myeloma
library(ggplot2)
library(dplyr)
library(knitr)
library(cowplot)
## 
## Attachement du package : 'cowplot'
## 
## L'objet suivant est masqué depuis 'package:ggpubr':
## 
##     get_legend
## 
## L'objet suivant est masqué depuis 'package:lubridate':
## 
##     stamp
##chargement des données 

recap_survies_v20260424 <- read_excel("C:/datar/recap_survies_v20260424.xlsx")
## New names:
## • `nom jeune fille` -> `nom jeune fille...19`
## • `date_os` -> `date_os...55`
## • `nom jeune fille` -> `nom jeune fille...59`
## • `date_os` -> `date_os...81`
## • `` -> `...99`
##recodage des variables et bases de données le cas échéant----

cbnpc<-filter(recap_survies_v20260424, c(eligible_v2=="oui" ))


##motif exclusions##

exclus<-filter(recap_survies_v20260424, c(eligible_v2=="non" ))

tbl_summary(
  exclus, include = c("motif_ineligibilite_2"),
  digits=all_categorical()~ c(0,1)
)
Characteristic N = 3,4241
motif_ineligibilite_2
    alk 29 (0.8%)
    chit 33 (1.0%)
    cpc 557 (16.3%)
    egfr 99 (2.9%)
    essais_clinique 421 (12.3%)
    her2 20 (0.6%)
    hors_onco 19 (0.6%)
    hors_oncothoracique 78 (2.3%)
    maladie_M0 681 (19.9%)
    mesotheliome 184 (5.4%)
    pas de donnee 25 (0.7%)
    patient_hors_chu 515 (15.0%)
    pediatrie 1 (0.0%)
    raf_mek 9 (0.3%)
    suite_traitement_1ere_ligne_ailleurs_ou_avant_2010 748 (21.8%)
    traitement_non_administré 4 (0.1%)
    vegfr 1 (0.0%)
1 n (%)
##création de variables à plusieurs catégorie selon valeurs variable continue

cbnpc$old70<-ifelse(cbnpc$age_initiation>70, 1, 0)
cbnpc$old65<-ifelse(cbnpc$age_initiation>65, 1, 0)
cbnpc$maigres<-ifelse(cbnpc$imc<18.5, 1, 0)
cbnpc$surpoids<-ifelse(cbnpc$imc>25, 1, 0)
cbnpc$obeses<-ifelse(cbnpc$imc>30, 1, 0)
cbnpc$bsa_cap<-ifelse(cbnpc$bsa>2, 1, 0)
cbnpc$young57<-ifelse(cbnpc$age_initiation<57, 1, 0)
cbnpc$ir60<-ifelse(cbnpc$dfg_ml_min<60, 1, 0)
cbnpc$ir30<-ifelse(cbnpc$dfg_ml_min<30, 1, 0)
cbnpc$ere <- cut(cbnpc$annee, c(2010, 2015, 2018, 2024))
cbnpc$initiation_period<-factor(cbnpc$periode, levels=c(1, 2, 3, 4),
                          labels=c("immunotherapy not available",
                                   "immunotherapy avilable as 2nd line",
                                   "immunotherapy available as 1st line monotherapy",
                                   "chemo_immunotherapy available as 1st line"))


##renommer des variables pour présentation dans les tableaux de résultats
library(labelled)
var_label(cbnpc$old65) <- "Patients older than 65 years"
var_label(cbnpc$old70) <- "Patients older than 70 years"
var_label(cbnpc$young57) <- "Patients younger than 57 years"
var_label(cbnpc$maigres) <- "Patients with BMI <18.5"
var_label(cbnpc$surpoids) <- "Patients with BMI >25"
var_label(cbnpc$obeses) <- "Patients with BMI >30"
var_label(cbnpc$bsa_cap) <- "Patients with BSA >2"
var_label(cbnpc$initiation_period) <- "period according to immunotherapy availability"
var_label(cbnpc$ir30) <- "Patients with GFR<30 ml/min"
var_label(cbnpc$ir60) <- "Patients with GFR<60 ml/min"
var_label(cbnpc$immuno) <- "Patients treated with immunotherapy at any line"
var_label(cbnpc$avastin) <- "Patients treated with bevacizumab at any line"
var_label(cbnpc$histologie) <- "Histologic category"
var_label(cbnpc$protocole_generique_initiation) <- "First line treatment"
var_label(cbnpc$age_initiation) <- "Age at the start of first line"
var_label(cbnpc$tt_initial) <- "First line treatment category"
var_label(cbnpc$imc) <- "Body Mass Index at the start of first line"
var_label(cbnpc$bsa) <- "Body Surface Area"
var_label(cbnpc$poids) <- "Body weight at the start of first line"
var_label(cbnpc$dfg_ml_min) <- "Glomerular filtration Rate at the start of first line"
var_label(cbnpc$sexe.cat) <- "Sex"

##tableau descriptif population globales ----

tbl_summary(
  cbnpc, include = c("age_initiation", "old65", "old70","young57","sexe.cat","poids",
                     "imc","maigres","surpoids","obeses","bsa_cap","dfg_ml_min", 
                     "tt_initial","histologie",
                     "imc","immuno", "avastin"),
  digits=all_categorical()~ c(0,1)
)
Characteristic N = 2,1301
Age at the start of first line 63 (57, 70)
Patients older than 65 years 899 (42.2%)
Patients older than 70 years 521 (24.5%)
Patients younger than 57 years 557 (26.2%)
Sex
    F 759 (35.6%)
    H 1,371 (64.4%)
Body weight at the start of first line 66 (56, 76)
Body Mass Index at the start of first line 22.9 (20.0, 25.8)
Patients with BMI <18.5 284 (13.3%)
Patients with BMI >25 664 (31.2%)
Patients with BMI >30 173 (8.1%)
Patients with BSA >2 315 (14.8%)
Glomerular filtration Rate at the start of first line 91 (76, 104)
    Unknown 27
First line treatment category
    chimio 1,563 (73.4%)
    chimio_immuno 403 (18.9%)
    immuno 164 (7.7%)
Histologic category
    epidermoide 775 (36.4%)
    non_epidermoide 1,355 (63.6%)
Patients treated with immunotherapy at any line 1,065 (50.0%)
Patients treated with bevacizumab at any line 263 (12.3%)
1 Median (IQR); n (%)
##détail traitements 1er ligne---
tbl_summary(
  cbnpc, include = c("protocole_generique_initiation"),
  digits=all_categorical()~ c(0,1)
)
Characteristic N = 2,1301
First line treatment
    cemiplimab 8 (0.4%)
    pembrolizumab 156 (7.3%)
    platine_alimta 756 (35.5%)
    platine_alimta_avastin 129 (6.1%)
    platine_alimta_nivolumab 6 (0.3%)
    platine_alimta_pembro 335 (15.7%)
    platine_docetaxel 56 (2.6%)
    platine_gemcitabine 67 (3.1%)
    platine_gemcitabine_avastin 6 (0.3%)
    platine_gemcitabine_nivolumab 1 (0.0%)
    platine_taxol 230 (10.8%)
    platine_taxol_avastin 8 (0.4%)
    platine_taxol_nivolumab 2 (0.1%)
    platine_taxol_pembro 59 (2.8%)
    platine_vinorelbine 311 (14.6%)
1 n (%)
##tableau descriptif population selon période d'initiation de tt----
tbl_summary(
  cbnpc, include = c("age_initiation", "old65","old70","young57","sexe.cat","poids",
                     "imc","maigres","obeses","surpoids","bsa_cap","dfg_ml_min", 
                     "tt_initial","histologie",
                     "imc","immuno", "avastin"),
    by="initiation_period", 
  digits=all_categorical()~ c(0,1)
)%>%
  add_p()
Characteristic immunotherapy not available, N = 5961 immunotherapy avilable as 2nd line, N = 3841 immunotherapy available as 1st line monotherapy, N = 3991 chemo_immunotherapy available as 1st line, N = 7511 p-value2
Age at the start of first line 62 (55, 69) 63 (56, 69) 65 (58, 71) 64 (58, 71) <0.001
Patients older than 65 years 220 (36.9%) 145 (37.8%) 189 (47.4%) 345 (45.9%) <0.001
Patients older than 70 years 119 (20.0%) 76 (19.8%) 117 (29.3%) 209 (27.8%) <0.001
Patients younger than 57 years 184 (30.9%) 110 (28.6%) 86 (21.6%) 177 (23.6%) 0.002
Sex 0.008
    F 185 (31.0%) 130 (33.9%) 163 (40.9%) 281 (37.4%)
    H 411 (69.0%) 254 (66.1%) 236 (59.1%) 470 (62.6%)
Body weight at the start of first line 66 (56, 76) 66 (56, 76) 66 (56, 77) 65 (56, 76) 0.9
Body Mass Index at the start of first line 22.9 (19.9, 25.6) 22.7 (19.9, 25.8) 23.2 (20.2, 26.4) 22.8 (20.0, 25.6) 0.4
Patients with BMI <18.5 76 (12.8%) 60 (15.6%) 46 (11.5%) 102 (13.6%) 0.4
Patients with BMI >30 50 (8.4%) 36 (9.4%) 27 (6.8%) 60 (8.0%) 0.6
Patients with BMI >25 180 (30.2%) 121 (31.5%) 144 (36.1%) 219 (29.2%) 0.10
Patients with BSA >2 89 (14.9%) 60 (15.6%) 61 (15.3%) 105 (14.0%) 0.9
Glomerular filtration Rate at the start of first line 90 (74, 102) 92 (77, 104) 90 (74, 103) 93 (79, 106) 0.007
    Unknown 14 5 2 6
First line treatment category <0.001
    chimio 596 (100.0%) 384 (100.0%) 319 (79.9%) 264 (35.2%)
    chimio_immuno 0 (0.0%) 0 (0.0%) 0 (0.0%) 403 (53.7%)
    immuno 0 (0.0%) 0 (0.0%) 80 (20.1%) 84 (11.2%)
Histologic category <0.001
    epidermoide 280 (47.0%) 141 (36.7%) 123 (30.8%) 231 (30.8%)
    non_epidermoide 316 (53.0%) 243 (63.3%) 276 (69.2%) 520 (69.2%)
Patients treated with immunotherapy at any line 53 (8.9%) 194 (50.5%) 241 (60.4%) 577 (76.8%) <0.001
Patients treated with bevacizumab at any line 75 (12.6%) 49 (12.8%) 53 (13.3%) 86 (11.5%) 0.8
1 Median (IQR); n (%)
2 Kruskal-Wallis rank sum test; Pearson’s Chi-squared test
##Courbe kaplan Meier Population globale
km_os<-survfit(Surv(cbnpc$os, cbnpc$evt_os)~1)
km_os
## Call: survfit(formula = Surv(cbnpc$os, cbnpc$evt_os) ~ 1)
## 
##         n events median 0.95LCL 0.95UCL
## [1,] 2130   1803   12.2    11.2    13.2
ggsurvplot(
  km_os,                     # survfit object with calculated statistics.
  data = cbnpc,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = FALSE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#2E9FDF"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

##Courbe kaplan Meier selon période d'intitation de tt

km_os_periode<-survfit(Surv(os, evt_os)~initiation_period, data=cbnpc)
km_os_periode
## Call: survfit(formula = Surv(os, evt_os) ~ initiation_period, data = cbnpc)
## 
##                                                                     n events
## initiation_period=immunotherapy not available                     596    570
## initiation_period=immunotherapy avilable as 2nd line              384    347
## initiation_period=immunotherapy available as 1st line monotherapy 399    341
## initiation_period=chemo_immunotherapy available as 1st line       751    545
##                                                                   median
## initiation_period=immunotherapy not available                       10.1
## initiation_period=immunotherapy avilable as 2nd line                12.1
## initiation_period=immunotherapy available as 1st line monotherapy   11.9
## initiation_period=chemo_immunotherapy available as 1st line         14.6
##                                                                   0.95LCL
## initiation_period=immunotherapy not available                        9.07
## initiation_period=immunotherapy avilable as 2nd line                 9.80
## initiation_period=immunotherapy available as 1st line monotherapy   10.03
## initiation_period=chemo_immunotherapy available as 1st line         13.03
##                                                                   0.95UCL
## initiation_period=immunotherapy not available                        11.2
## initiation_period=immunotherapy avilable as 2nd line                 14.3
## initiation_period=immunotherapy available as 1st line monotherapy    14.7
## initiation_period=chemo_immunotherapy available as 1st line          17.7
ggsurvplot(
  km_os_periode,                     # survfit object with calculated statistics.
  data = cbnpc,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = TRUE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#E7B800", "#2E9FDF", "green4", "red"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

##modèle de cox os 


##analyses univariée

tbl_uvregression(
  cbnpc,
  method = coxph,
  y = Surv(os, evt_os),
  exponentiate = TRUE,
  include = c(old70, old65, initiation_period, young57, maigres, surpoids, obeses,bsa_cap, sexe.cat, imc, immuno, avastin, tt_initial, ir30, ir60, histologie),
  pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic N HR1 95% CI1 p-value
Patients treated with immunotherapy at any line 2,130 0.63 0.57, 0.69 <0.001
Patients treated with bevacizumab at any line 2,130 0.79 0.69, 0.90 <0.001
Sex 2,130
    F
    H 1.10 1.00, 1.22 0.044
Body Mass Index at the start of first line 2,130 0.96 0.95, 0.97 <0.001
First line treatment category 2,130
    chimio
    chimio_immuno 0.69 0.61, 0.79 <0.001
    immuno 0.83 0.69, 1.00 0.048
Histologic category 2,130
    epidermoide
    non_epidermoide 0.87 0.79, 0.96 0.006
Patients older than 70 years 2,130 1.03 0.93, 1.15 0.585
Patients older than 65 years 2,130 1.03 0.94, 1.13 0.531
Patients with BMI <18.5 2,130 1.60 1.40, 1.83 <0.001
Patients with BMI >25 2,130 0.77 0.70, 0.85 <0.001
Patients with BMI >30 2,130 0.76 0.64, 0.90 0.002
Patients with BSA >2 2,130 0.82 0.72, 0.93 0.003
Patients younger than 57 years 2,130 0.94 0.85, 1.05 0.281
Patients with GFR<60 ml/min 2,103 1.03 0.88, 1.20 0.744
Patients with GFR<30 ml/min 2,103 1.79 1.18, 2.73 0.006
period according to immunotherapy availability 2,130
    immunotherapy not available
    immunotherapy avilable as 2nd line 0.89 0.78, 1.02 0.088
    immunotherapy available as 1st line monotherapy 0.82 0.71, 0.93 0.003
    chemo_immunotherapy available as 1st line 0.71 0.63, 0.80 <0.001
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Mutlivariée 

modsurv<-coxph(Surv(os, evt_os)~avastin+tt_initial+
                 sexe.cat+histologie+maigres+surpoids+bsa_cap+
                 ir30+initiation_period, data=cbnpc)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 0.79 0.68, 0.91 <0.001
First line treatment category
    chimio
    chimio_immuno 0.71 0.59, 0.85 <0.001
    immuno 0.84 0.68, 1.02 0.081
Sex
    F
    H 1.17 1.05, 1.29 0.003
Histologic category
    epidermoide
    non_epidermoide 0.99 0.89, 1.10 0.863
Patients with BMI <18.5 1.55 1.35, 1.79 <0.001
Patients with BMI >25 0.82 0.73, 0.92 0.001
Patients with BSA >2 0.91 0.78, 1.06 0.243
Patients with GFR<30 ml/min 1.61 1.05, 2.46 0.028
period according to immunotherapy availability
    immunotherapy not available
    immunotherapy avilable as 2nd line 0.89 0.78, 1.02 0.103
    immunotherapy available as 1st line monotherapy 0.87 0.76, 1.01 0.062
    chemo_immunotherapy available as 1st line 0.88 0.76, 1.03 0.108
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Mutlivariée sans BSA plafonnée

modsurv<-coxph(Surv(os, evt_os)~avastin+tt_initial+
                 sexe.cat+histologie+maigres+surpoids+
                 ir30+initiation_period, data=cbnpc)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 0.78 0.68, 0.90 <0.001
First line treatment category
    chimio
    chimio_immuno 0.71 0.59, 0.85 <0.001
    immuno 0.83 0.68, 1.02 0.073
Sex
    F
    H 1.15 1.04, 1.27 0.006
Histologic category
    epidermoide
    non_epidermoide 0.99 0.89, 1.10 0.844
Patients with BMI <18.5 1.56 1.35, 1.79 <0.001
Patients with BMI >25 0.80 0.72, 0.88 <0.001
Patients with GFR<30 ml/min 1.62 1.06, 2.47 0.026
period according to immunotherapy availability
    immunotherapy not available
    immunotherapy avilable as 2nd line 0.89 0.78, 1.02 0.093
    immunotherapy available as 1st line monotherapy 0.88 0.76, 1.01 0.067
    chemo_immunotherapy available as 1st line 0.88 0.76, 1.03 0.109
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Multivariée sans la période

modsurv<-coxph(Surv(os, evt_os)~avastin+tt_initial+
                 sexe.cat+histologie+maigres+surpoids+
                 ir30, data=cbnpc)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 0.78 0.68, 0.91 <0.001
First line treatment category
    chimio
    chimio_immuno 0.68 0.59, 0.77 <0.001
    immuno 0.79 0.65, 0.95 0.014
Sex
    F
    H 1.16 1.05, 1.28 0.004
Histologic category
    epidermoide
    non_epidermoide 0.99 0.89, 1.09 0.778
Patients with BMI <18.5 1.56 1.35, 1.79 <0.001
Patients with BMI >25 0.79 0.71, 0.88 <0.001
Patients with GFR<30 ml/min 1.65 1.08, 2.52 0.020
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Mutlivariée sans l'histologie = modèle final

modsurv<-coxph(Surv(os, evt_os)~avastin+tt_initial+
                 sexe.cat+maigres+surpoids+
                 ir30, data=cbnpc)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 0.78 0.68, 0.90 <0.001
First line treatment category
    chimio
    chimio_immuno 0.67 0.59, 0.77 <0.001
    immuno 0.79 0.65, 0.95 0.012
Sex
    F
    H 1.16 1.05, 1.28 0.003
Patients with BMI <18.5 1.56 1.35, 1.79 <0.001
Patients with BMI >25 0.79 0.71, 0.88 <0.001
Patients with GFR<30 ml/min 1.66 1.09, 2.53 0.019
1 HR = Hazard Ratio, CI = Confidence Interval
##Analyse en sous groupes 
###patients traités par immuno 1st line
immunofirst<-filter(cbnpc, c(tt_initial=="immuno" ))

####Description population immuno 1ere ligne 
tbl_summary(
  immunofirst, include = c("age_initiation", "old65","old70","young57","sexe.cat","poids",
                     "imc","maigres","surpoids","obeses","bsa_cap","dfg_ml_min","ir30" ,
                     "protocole_generique_initiation","histologie",
                     "avastin"),
  digits=all_categorical()~ c(0,1)
)
Characteristic N = 1641
Age at the start of first line 67 (61, 75)
Patients older than 65 years 93 (56.7%)
Patients older than 70 years 60 (36.6%)
Patients younger than 57 years 26 (15.9%)
Sex
    F 57 (34.8%)
    H 107 (65.2%)
Body weight at the start of first line 65 (55, 75)
Body Mass Index at the start of first line 22.7 (20.1, 25.3)
Patients with BMI <18.5 22 (13.4%)
Patients with BMI >25 45 (27.4%)
Patients with BMI >30 8 (4.9%)
Patients with BSA >2 22 (13.4%)
Glomerular filtration Rate at the start of first line 91 (71, 106)
    Unknown 8
Patients with GFR<30 ml/min 5 (3.2%)
    Unknown 8
First line treatment
    cemiplimab 8 (4.9%)
    pembrolizumab 156 (95.1%)
Histologic category
    epidermoide 35 (21.3%)
    non_epidermoide 129 (78.7%)
Patients treated with bevacizumab at any line 2 (1.2%)
1 Median (IQR); n (%)
##Courbe kaplan Meier Population immuno mono 1ere ligne
km_os_immunofirst<-survfit(Surv(immunofirst$os, immunofirst$evt_os)~1)
km_os_immunofirst
## Call: survfit(formula = Surv(immunofirst$os, immunofirst$evt_os) ~ 
##     1)
## 
##        n events median 0.95LCL 0.95UCL
## [1,] 164    127   11.4     8.7    17.1
ggsurvplot(
  km_os_immunofirst,                     # survfit object with calculated statistics.
  data = immunofirst,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = FALSE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#2E9FDF"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

##modèle de cox os population immuno mono 1ere ligne


##analyses univariée

tbl_uvregression(
  immunofirst,
  method = coxph,
  y = Surv(os, evt_os),
  exponentiate = TRUE,
  include = c(old70, old65,young57, maigres, surpoids, obeses,bsa_cap, sexe.cat,avastin, ir30, histologie),
  pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic N HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 164 0.37 0.05, 2.68 0.327
Sex 164
    F
    H 1.31 0.90, 1.90 0.156
Histologic category 164
    epidermoide
    non_epidermoide 0.88 0.58, 1.32 0.534
Patients older than 70 years 164 1.07 0.75, 1.54 0.703
Patients older than 65 years 164 1.10 0.77, 1.56 0.605
Patients with BMI <18.5 164 1.14 0.69, 1.91 0.608
Patients with BMI >25 164 0.82 0.55, 1.22 0.329
Patients with BMI >30 164 0.73 0.32, 1.66 0.455
Patients with BSA >2 164 0.63 0.37, 1.09 0.098
Patients younger than 57 years 164 1.08 0.67, 1.74 0.751
Patients with GFR<30 ml/min 156 3.03 1.23, 7.49 0.016
1 HR = Hazard Ratio, CI = Confidence Interval
##patients traités par chimio-immuno 1st line
chimioimmunofirst<-filter(cbnpc, c(tt_initial=="chimio_immuno" ))

####Description population chimio immuno 1ere ligne
tbl_summary(
  chimioimmunofirst, include = c("age_initiation", "old65","old70","young57","sexe.cat","poids",
                           "imc","maigres","surpoids","obeses","bsa_cap","dfg_ml_min","ir30", 
                           "protocole_generique_initiation","histologie",
                           "avastin"),
  digits=all_categorical()~ c(0,1)
)
Characteristic N = 4031
Age at the start of first line 62 (56, 68)
Patients older than 65 years 146 (36.2%)
Patients older than 70 years 70 (17.4%)
Patients younger than 57 years 116 (28.8%)
Sex
    F 154 (38.2%)
    H 249 (61.8%)
Body weight at the start of first line 66 (56, 76)
Body Mass Index at the start of first line 22.8 (19.9, 25.6)
Patients with BMI <18.5 57 (14.1%)
Patients with BMI >25 117 (29.0%)
Patients with BMI >30 37 (9.2%)
Patients with BSA >2 56 (13.9%)
Glomerular filtration Rate at the start of first line 96 (84, 108)
Patients with GFR<30 ml/min 0 (0.0%)
First line treatment
    platine_alimta_nivolumab 6 (1.5%)
    platine_alimta_pembro 335 (83.1%)
    platine_gemcitabine_nivolumab 1 (0.2%)
    platine_taxol_nivolumab 2 (0.5%)
    platine_taxol_pembro 59 (14.6%)
Histologic category
    epidermoide 62 (15.4%)
    non_epidermoide 341 (84.6%)
Patients treated with bevacizumab at any line 60 (14.9%)
1 Median (IQR); n (%)
##Courbe kaplan Meier Population chimio immuno mono 1ere ligne
km_os_chimioimmunofirst<-survfit(Surv(chimioimmunofirst$os, chimioimmunofirst$evt_os)~1)
km_os_chimioimmunofirst
## Call: survfit(formula = Surv(chimioimmunofirst$os, chimioimmunofirst$evt_os) ~ 
##     1)
## 
##        n events median 0.95LCL 0.95UCL
## [1,] 403    272   18.6      15    20.4
ggsurvplot(
  km_os_chimioimmunofirst,                     # survfit object with calculated statistics.
  data = chimioimmunofirst,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = FALSE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#2E9FDF"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

##modèle de cox os population chimio immuno 1ere ligne


##analyses univariée

tbl_uvregression(
  chimioimmunofirst,
  method = coxph,
  y = Surv(os, evt_os),
  exponentiate = TRUE,
  include = c(old70, old65,young57, maigres, surpoids, obeses,"bsa_cap", sexe.cat,avastin, ir30, histologie),
  pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic N HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 403 1.00 0.73, 1.36 0.977
Sex 403
    F
    H 1.02 0.80, 1.30 0.874
Histologic category 403
    epidermoide
    non_epidermoide 0.83 0.59, 1.15 0.260
Patients older than 70 years 403 0.96 0.70, 1.32 0.805
Patients older than 65 years 403 1.02 0.79, 1.30 0.905
Patients with BMI <18.5 403 1.26 0.90, 1.75 0.177
Patients with BMI >25 403 0.98 0.75, 1.27 0.865
Patients with BMI >30 403 1.07 0.71, 1.60 0.759
Patients with BSA >2 403 0.99 0.70, 1.40 0.961
Patients younger than 57 years 403 1.05 0.81, 1.37 0.693
Patients with GFR<30 ml/min 403
1 HR = Hazard Ratio, CI = Confidence Interval
#patients traités par chimio 1st line
chimio<-filter(cbnpc, c(tt_initial=="chimio" ))

####Description population chimio immuno 1ere ligne
tbl_summary(
  chimio, include = c("age_initiation", "old65","old70","young57","sexe.cat","poids",
                                 "imc","maigres","surpoids","obeses","bsa_cap","dfg_ml_min","ir30", 
                                 "protocole_generique_initiation","histologie",
                                 "avastin"),
  digits=all_categorical()~ c(0,1)
)
Characteristic N = 1,5631
Age at the start of first line 63 (57, 70)
Patients older than 65 years 660 (42.2%)
Patients older than 70 years 391 (25.0%)
Patients younger than 57 years 415 (26.6%)
Sex
    F 548 (35.1%)
    H 1,015 (64.9%)
Body weight at the start of first line 66 (56, 76)
Body Mass Index at the start of first line 22.9 (20.0, 25.9)
Patients with BMI <18.5 205 (13.1%)
Patients with BMI >25 502 (32.1%)
Patients with BMI >30 128 (8.2%)
Patients with BSA >2 237 (15.2%)
Glomerular filtration Rate at the start of first line 90 (75, 103)
    Unknown 19
Patients with GFR<30 ml/min 17 (1.1%)
    Unknown 19
First line treatment
    platine_alimta 756 (48.4%)
    platine_alimta_avastin 129 (8.3%)
    platine_docetaxel 56 (3.6%)
    platine_gemcitabine 67 (4.3%)
    platine_gemcitabine_avastin 6 (0.4%)
    platine_taxol 230 (14.7%)
    platine_taxol_avastin 8 (0.5%)
    platine_vinorelbine 311 (19.9%)
Histologic category
    epidermoide 678 (43.4%)
    non_epidermoide 885 (56.6%)
Patients treated with bevacizumab at any line 201 (12.9%)
1 Median (IQR); n (%)
##Courbe kaplan Meier Population chimio immuno mono 1ere ligne
km_os_chimio<-survfit(Surv(chimio$os, chimio$evt_os)~1)
km_os_chimio
## Call: survfit(formula = Surv(chimio$os, chimio$evt_os) ~ 1)
## 
##         n events median 0.95LCL 0.95UCL
## [1,] 1563   1404   10.9      10    12.1
ggsurvplot(
  km_os_chimio,                     # survfit object with calculated statistics.
  data = chimio,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = FALSE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#2E9FDF"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

##modèle de cox os population chimio  1ere ligne


##analyses univariée

tbl_uvregression(
  chimio,
  method = coxph,
  y = Surv(os, evt_os),
  exponentiate = TRUE,
  include = c(old70, old65,young57, maigres, surpoids, obeses,bsa_cap, sexe.cat,avastin, ir30, histologie),
  pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic N HR1 95% CI1 p-value
Patients treated with bevacizumab at any line 1,563 0.74 0.64, 0.87 <0.001
Sex 1,563
    F
    H 1.10 0.98, 1.22 0.099
Histologic category 1,563
    epidermoide
    non_epidermoide 0.95 0.85, 1.06 0.343
Patients older than 70 years 1,563 1.01 0.89, 1.14 0.884
Patients older than 65 years 1,563 1.01 0.91, 1.13 0.813
Patients with BMI <18.5 1,563 1.84 1.58, 2.14 <0.001
Patients with BMI >25 1,563 0.72 0.64, 0.80 <0.001
Patients with BMI >30 1,563 0.70 0.57, 0.86 <0.001
Patients with BSA >2 1,563 0.80 0.69, 0.93 0.003
Patients younger than 57 years 1,563 0.91 0.81, 1.03 0.135
Patients with GFR<30 ml/min 1,544 1.47 0.91, 2.37 0.117
1 HR = Hazard Ratio, CI = Confidence Interval
#Courbe de Kaplan Meier selon tt initial


##Courbe kaplan Meier selon période d'intitation de tt

km_os_tt_initial<-survfit(Surv(os, evt_os)~tt_initial, data=cbnpc)
km_os_tt_initial
## Call: survfit(formula = Surv(os, evt_os) ~ tt_initial, data = cbnpc)
## 
##                             n events median 0.95LCL 0.95UCL
## tt_initial=chimio        1563   1404   10.9    10.0    12.1
## tt_initial=chimio_immuno  403    272   18.6    15.0    20.4
## tt_initial=immuno         164    127   11.4     8.7    17.1
ggsurvplot(
  km_os_tt_initial,                     # survfit object with calculated statistics.
  data = cbnpc,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = TRUE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#E7B800", "#2E9FDF", "green4"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

###Analyse de la période depuis AMM chimio-immuno 1ere ligne 
moderne<-filter(cbnpc, c(periode==4))


##descriptif population selon traitement de 1ere ligne ere moderne

tbl_summary(
  moderne, include = c("age_initiation", "old65","old70","young57","sexe.cat","poids",
                     "imc","maigres","obeses","bsa_cap","dfg_ml_min", 
                     "histologie",
                     "imc","immuno", "avastin"),
  by="tt_initial", 
  digits=all_categorical()~ c(0,1)
)%>%
  add_p()
Characteristic chimio, N = 2641 chimio_immuno, N = 4031 immuno, N = 841 p-value2
Age at the start of first line 68 (59, 74) 62 (56, 68) 68 (62, 77) <0.001
Patients older than 65 years 148 (56.1%) 146 (36.2%) 51 (60.7%) <0.001
Patients older than 70 years 106 (40.2%) 70 (17.4%) 33 (39.3%) <0.001
Patients younger than 57 years 49 (18.6%) 116 (28.8%) 12 (14.3%) 0.001
Sex 0.2
    F 103 (39.0%) 154 (38.2%) 24 (28.6%)
    H 161 (61.0%) 249 (61.8%) 60 (71.4%)
Body weight at the start of first line 65 (57, 76) 66 (56, 76) 65 (55, 76) 0.9
Body Mass Index at the start of first line 22.8 (20.0, 25.6) 22.8 (19.9, 25.6) 22.8 (20.1, 26.0) >0.9
Patients with BMI <18.5 32 (12.1%) 57 (14.1%) 13 (15.5%) 0.7
Patients with BMI >30 16 (6.1%) 37 (9.2%) 7 (8.3%) 0.3
Patients with BSA >2 36 (13.6%) 56 (13.9%) 13 (15.5%) >0.9
Glomerular filtration Rate at the start of first line 90 (76, 103) 96 (84, 108) 86 (59, 98) <0.001
    Unknown 0 0 6
Histologic category <0.001
    epidermoide 152 (57.6%) 62 (15.4%) 17 (20.2%)
    non_epidermoide 112 (42.4%) 341 (84.6%) 67 (79.8%)
Patients treated with immunotherapy at any line 90 (34.1%) 403 (100.0%) 84 (100.0%) <0.001
Patients treated with bevacizumab at any line 26 (9.8%) 60 (14.9%) 0 (0.0%) <0.001
1 Median (IQR); n (%)
2 Kruskal-Wallis rank sum test; Pearson’s Chi-squared test
##Courbe kaplan Meier selon traitement initial période moderne uniquement (à partir de dec 2019)

km_os_moderne<-survfit(Surv(os, evt_os)~tt_initial, data=moderne)
km_os_moderne
## Call: survfit(formula = Surv(os, evt_os) ~ tt_initial, data = moderne)
## 
##                            n events median 0.95LCL 0.95UCL
## tt_initial=chimio        264    211   10.4    8.27    13.8
## tt_initial=chimio_immuno 403    272   18.6   15.00    20.4
## tt_initial=immuno         84     62   13.6    9.00    26.3
ggsurvplot(
  km_os_moderne,                     # survfit object with calculated statistics.
  data = cbnpc,             # data used to fit survival curves.
  risk.table = TRUE,       # show risk table.
  pval = TRUE,             # show p-value of log-rank test.
  conf.int = TRUE,         # show confidence intervals for 
  # point estimates of survival curves.
  palette = c("#E7B800", "#2E9FDF", "green4"),
  xlim = c(0,66),         # present narrower X axis, but not affect
  # survival estimates.
  xlab = "Time in months",   # customize X axis label.
  break.time.by = 6,     # break X axis in time intervals by 500.
  ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.height = 0.25, # the height of the risk table
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
  # in legend of risk table.
  ncensor.plot = FALSE,      # plot the number of censored subjects at time t
  ncensor.plot.height = 0.25,
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  #legend.labs =
  #c("no", "yes")    # change legend labels.
)

##Analyse de Cox univariée sur période moderne 
tbl_uvregression(
  moderne,
  method = coxph,
  y = Surv(os, evt_os),
  exponentiate = TRUE,
  include = c(old70, old65, young57, maigres, surpoids, obeses,bsa_cap, sexe.cat, imc, immuno, avastin, tt_initial, ir30, ir60, histologie),
  pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic N HR1 95% CI1 p-value
Patients treated with immunotherapy at any line 751 0.69 0.57, 0.84 <0.001
Patients treated with bevacizumab at any line 751 0.88 0.68, 1.13 0.305
Sex 751
    F
    H 1.06 0.89, 1.26 0.514
Body Mass Index at the start of first line 751 0.97 0.95, 0.99 0.002
First line treatment category 751
    chimio
    chimio_immuno 0.72 0.60, 0.87 <0.001
    immuno 0.80 0.60, 1.06 0.124
Histologic category 751
    epidermoide
    non_epidermoide 0.76 0.63, 0.91 0.002
Patients older than 70 years 751 1.15 0.95, 1.38 0.145
Patients older than 65 years 751 1.20 1.01, 1.42 0.034
Patients with BMI <18.5 751 1.60 1.26, 2.03 <0.001
Patients with BMI >25 751 0.80 0.66, 0.96 0.017
Patients with BMI >30 751 0.85 0.62, 1.17 0.326
Patients with BSA >2 751 0.82 0.64, 1.05 0.124
Patients younger than 57 years 751 0.84 0.69, 1.03 0.093
Patients with GFR<60 ml/min 745 1.46 1.09, 1.96 0.011
Patients with GFR<30 ml/min 745 2.61 1.35, 5.05 0.004
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Mutlivariée sur période moderne

modsurv<-coxph(Surv(os, evt_os)~tt_initial+
                 histologie+maigres+surpoids+young57+
                 ir30, data=moderne)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
First line treatment category
    chimio
    chimio_immuno 0.75 0.61, 0.92 0.005
    immuno 0.83 0.62, 1.12 0.234
Histologic category
    epidermoide
    non_epidermoide 0.86 0.70, 1.05 0.139
Patients with BMI <18.5 1.66 1.30, 2.13 <0.001
Patients with BMI >25 0.82 0.67, 1.00 0.047
Patients younger than 57 years 0.82 0.66, 1.00 0.054
Patients with GFR<30 ml/min 2.29 1.18, 4.47 0.015
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Mutlivariée sans histologie

modsurv<-coxph(Surv(os, evt_os)~tt_initial+
                 maigres+surpoids+young57+
                 ir30, data=moderne)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
First line treatment category
    chimio
    chimio_immuno 0.70 0.59, 0.84 <0.001
    immuno 0.79 0.59, 1.06 0.118
Patients with BMI <18.5 1.65 1.29, 2.12 <0.001
Patients with BMI >25 0.82 0.67, 1.0 0.044
Patients younger than 57 years 0.81 0.66, 0.99 0.042
Patients with GFR<30 ml/min 2.38 1.22, 4.64 0.011
1 HR = Hazard Ratio, CI = Confidence Interval
##analyses Mutlivariée sans histologie avec dfg<60 à la place de dfg<30

modsurv<-coxph(Surv(os, evt_os)~tt_initial+
                 maigres+surpoids+young57+
                 ir60, data=moderne)
modsurv%>%tbl_regression(
  exponentiate = TRUE,pvalue_fun = scales::label_pvalue(accuracy = .001)
)
Characteristic HR1 95% CI1 p-value
First line treatment category
    chimio
    chimio_immuno 0.71 0.59, 0.86 <0.001
    immuno 0.77 0.58, 1.04 0.087
Patients with BMI <18.5 1.65 1.29, 2.12 <0.001
Patients with BMI >25 0.82 0.68, 1.00 0.053
Patients younger than 57 years 0.82 0.66, 1.01 0.057
Patients with GFR<60 ml/min 1.31 0.96, 1.79 0.083
1 HR = Hazard Ratio, CI = Confidence Interval