Last updated: 2025-03-28
Checks: 6 1
Knit directory: hruban_wflow/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of
the R Markdown file created these results, you’ll want to first commit
it to the Git repo. If you’re still working on the analysis, you can
ignore this warning. When you’re finished, you can run
wflow_publish
to commit the R Markdown file and build the
HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20250319)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 935a46e. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .DS_Store
Ignored: code/rlucas/.DS_Store
Ignored: data/estimates/.Rapp.history
Untracked files:
Untracked: code/pivot_wider_pacto.R
Untracked: data/allfeatures_pacto.5mb.hg19.csv
Untracked: extdata/
Unstaged changes:
Modified: analysis/ext-fig16b.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown (analysis/ext-fig16b.Rmd
) and HTML
(docs/ext-fig16b.html
) files. If you’ve configured a remote
Git repository (see ?wflow_git_remote
), click on the
hyperlinks in the table below to view the files as they were in that
past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 9bbcb47 | Shashikant Koul | 2025-03-27 | Initial commit |
html | 9bbcb47 | Shashikant Koul | 2025-03-27 | Initial commit |
Multivariate cox proportional hazard analyses were generated for each molecular method and fit to overall survival adjusting for clinical subgroups. Each of the indicated subgroups that have been shown to be significant on univariate analyses in previous studies(7) have been included in the multivariate analysis. Hazard ratios and P values are indicated on the right for individuals in the CheckPAC study, after excluding those who do not secrete CA19-9.
library(here)
library(readxl)
library(survival)
source(here("code/hr_plot_funcs.R"))
baseline_c <- read_excel(here("data/CheckPAC_clinical_annotated011622.xlsx")) %>%
select(subject_id = StudySubjectID,
age,
weightloss5_yn = weighttloss5_yn,
ecog_ps = PS_cycle1,
bor = `Best overall confirmed response (RECIST)`,
ca199 = LAB_CA199_E1_C4,
crp = LAB_CRP_E1_C4,
bilirubin = LAB_Bilirubin_E1_C4,
albumin = LAB_Albumin_E1_C4) %>%
mutate(mgps = case_when(crp <= 10 ~ 0,
crp > 10 & albumin >= 35 ~ 1,
crp > 10 & albumin < 35 ~ 2))
long_c <- read_excel(here("data/clinical_073123.xlsx")) %>%
select(subject_id = StudySubjectID,
arm = Arm,
nivo_start_date = Nivo_StartDate,
pfs_date = PFS_date,
surv_date = Survival_date,
surv_status = Survival_status) %>%
mutate(surv_status = case_when(surv_status == 2 ~ "Dead",
surv_status == 1 ~ "Alive"),
arm = factor(arm))
clin_c <- inner_join(baseline_c, long_c, by = "subject_id")
# Fix the date formats
for (i in colnames(clin_c)) {
if (str_detect(i, "[Dd]ate")) {
if (!any(class(clin_c[[i]]) == "POSIXt")) {
clin_c[[i]] <- as.Date(as.numeric(clin_c[[i]]), origin = "1899-12-30")
} else {
clin_c[[i]] <- as.Date(clin_c[[i]])
}
}
}
# Compute overall and progression-free survival time
surv_c <- clin_c %>%
mutate(pfs = as.numeric(difftime(pfs_date, nivo_start_date)),
os = as.numeric(difftime(surv_date, nivo_start_date))) %>%
mutate(death = ifelse(surv_status == "Dead", 1, 0))
ca199 <- read.csv(here("data/checkpac_ca199.csv")) %>%
mutate(visit = ifelse(lab_suffix == "E1_C4",
"baseline",
as.character(cyclenumber)),
ca199 = ifelse(ca199 == -999, NA, ca199),
subject_id = str_pad(subject_id, 3, "left", "0")) %>%
select(-c(lab_suffix, cyclenumber, visit)) %>%
drop_na()
secretor <- ca199 %>%
group_by(subject_id) %>%
summarize(secretor = all(ca199 > 37))
is_secretor <- secretor$secretor
names(is_secretor) <- secretor$subject_id
blood_draw_c <- read.csv(here("data/checkpac_ca199_baseline_p4_dates.csv"))
blood_draw_bl_and_p1_c <- blood_draw_c %>%
filter(!is.na(baseline) & !is.na(endpoint)) %>%
select(patient_id, baseline, endpoint) %>%
pivot_longer(cols = c("baseline", "endpoint"),
names_to = "visit",
values_to = "date_blood_draw")
exclude_c <- c("CGPLPA225", "CGPLPA783", "CGPLPA795")
id_map_c <- read_excel(here("data/ID_comparison.xlsx")) %>%
filter(!unlist(lapply(CGID, function(x) any(str_detect(x, exclude_c))))) %>%
select(patient_id = CGID, subject_id = StudySubjectID) %>%
mutate(patient_id = substring(patient_id, 1, 9))
surv_artemis_delfi_c <- surv_c %>%
select(-ca199) %>%
inner_join(id_map_c) %>%
inner_join(blood_draw_bl_and_p1_c) %>%
inner_join(ca199,
by = join_by("subject_id", "date_blood_draw" == "lab_date")) %>%
select(subject_id, patient_id,
arm, ca199, bilirubin, age, mgps, ecog_ps, weightloss5_yn, visit,
pfs, os, death) %>%
pivot_wider(names_from = visit, values_from = ca199) %>%
filter(is_secretor[subject_id]) %>%
mutate(bilirubin_bin = bilirubin > 25,
age_bin = age <= 65,
mgps_bin = factor(mgps, levels = c(0, 1, 2)),
ecog_ps_bin = ecog_ps == 1,
weightloss5_yn_bin = weightloss5_yn == 1)
Joining with `by = join_by(subject_id)`
Joining with `by = join_by(patient_id)`
covar_labels <- c("Age, years",
"> 65",
"\u2264 65",
"ECOG PS",
"0",
"1",
"Weight loss, %",
"< 5",
"\u2265 5",
"MGPS",
"0",
"1",
"2",
"Treatment",
"RT+Nivo",
"RT+Nivo/Ipi")
surv_data <- surv_artemis_delfi_c %>%
mutate(baseline = scale(baseline)[, 1],
endpoint = scale(endpoint)[, 1])
mf <- coxph(Surv(os, death) ~ age_bin + ecog_ps_bin + weightloss5_yn_bin +
mgps_bin + arm + baseline + endpoint, surv_data)
var_labels <- c(covar_labels,
"CA19-9",
"Baseline",
"CA19-9",
"On-treatment (week 8)")
cox_tb <- get_hr_tbl(surv_data, mf)
print(plot_hr(cox_tb, var_labels = var_labels))
Warning: Removed 8 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 21 rows containing missing values or values outside the scale range
(`geom_point()`).
sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.3.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] patchwork_1.3.0 lubridate_1.9.4 forcats_1.0.0 stringr_1.5.1
[5] dplyr_1.1.4 purrr_1.0.4 readr_2.1.5 tidyr_1.3.1
[9] tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0 survival_3.8-3
[13] readxl_1.4.5 here_1.0.1 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] sass_0.4.9 generics_0.1.3 stringi_1.8.4 lattice_0.22-6
[5] hms_1.1.3 digest_0.6.37 magrittr_2.0.3 timechange_0.3.0
[9] evaluate_1.0.3 grid_4.4.1 fastmap_1.2.0 cellranger_1.1.0
[13] rprojroot_2.0.4 jsonlite_1.9.1 Matrix_1.7-3 processx_3.8.6
[17] whisker_0.4.1 ps_1.9.0 promises_1.3.2 httr_1.4.7
[21] scales_1.3.0 jquerylib_0.1.4 cli_3.6.4 rlang_1.1.5
[25] munsell_0.5.1 splines_4.4.1 withr_3.0.2 cachem_1.1.0
[29] yaml_2.3.10 tools_4.4.1 tzdb_0.4.0 colorspace_2.1-1
[33] httpuv_1.6.15 vctrs_0.6.5 R6_2.6.1 lifecycle_1.0.4
[37] git2r_0.35.0 fs_1.6.5 pkgconfig_2.0.3 callr_3.7.6
[41] pillar_1.10.1 bslib_0.9.0 later_1.4.1 gtable_0.3.6
[45] glue_1.8.0 Rcpp_1.0.14 xfun_0.51 tidyselect_1.2.1
[49] rstudioapi_0.17.1 knitr_1.49 farver_2.1.2 htmltools_0.5.8.1
[53] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.1 getPass_0.2-4