Last updated: 2025-03-28

Checks: 7 0

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.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

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 03bf6cf. 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/process_tcga_beta.html
    Ignored:    code/rlucas/.DS_Store
    Ignored:    data/estimates/.Rapp.history

Untracked files:
    Untracked:  code/pivot_wider_pacto.R
    Untracked:  code/process_ab_v0.Rmd
    Untracked:  data/allfeatures_pacto.5mb.hg19.csv
    Untracked:  data/paad_bins_100kb_sel_chr.rds
    Untracked:  extdata/

Unstaged changes:
    Modified:   README.Rmd
    Modified:   analysis/ext-fig9.Rmd
    Modified:   analysis/fig4.Rmd
    Modified:   code/process_tcga_beta.Rmd
    Modified:   output/process_tcga_beta.Rmd/paad_bins_100kb_sel_chr.rds

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-fig22a.Rmd) and HTML (docs/ext-fig22a.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 29a8876 Shashikant Koul 2025-03-28 Fix patient selection in S8 and S22
html 29a8876 Shashikant Koul 2025-03-28 Fix patient selection in S8 and S22
Rmd 9bbcb47 Shashikant Koul 2025-03-27 Initial commit
html 9bbcb47 Shashikant Koul 2025-03-27 Initial commit

cfDNA fragmentation profiles from PACTO patients are shown as short to long ratios of fragment size in 473 5-Mb bins across the genome. Profiles are shown for all patients with plasma samples at baseline, and at follow-up for each of the clinical RECIST 1.1 response categories. Each profile is colored by correlation to the median of 10 healthy reference samples.

library(cowplot)
library(fs)
library(grid)
library(here)
library(readxl)
library(tidyverse)
devtools::load_all(here("code/rlucas"))
df <- list.files(path = here("data/pacto_5mb_bins"), full.names = TRUE) %>%
  lapply(read_csv) %>%
  bind_rows %>%
  filter(chr != "chrX") %>%
  as_tibble() %>%
  mutate(ratio.cor = short.cor / long.cor) %>%
  group_by(id) %>%
  mutate(ratio.centered = scale(ratio.cor, scale = FALSE)[, 1])

clean_data<-read_excel(here("data/supplementary_tables.xlsx"),
                       sheet="Table S4",range="A2:S42")
delfi_pred<-read_excel(here("data/supplementary_tables.xlsx"),
                       sheet="Table S5",range="A2:N207")
clean_data <- clean_data %>%
  filter(`BOR RECIST 1.1` != "Not Evaluable")
delfi_pred <- delfi_pred %>%
  filter(Timepoint %in% c("Baseline", "Endpoint"))
DELFI_complete <- delfi_pred %>%
  inner_join(clean_data, by="Patient") %>%
  mutate(class = case_when((Timepoint == "Baseline") ~ "Baseline",
                           TRUE ~ `BOR RECIST 1.1`)) %>%
  distinct(Patient, class, .keep_all = TRUE)
DELFI_complete$id <- DELFI_complete$Sample

fp2 <- inner_join(DELFI_complete, df, by="id")

fp2 <-  arrange(fp2, id, bin) %>%
    mutate(bin=factor(bin),
           arm=factor(arm, levels=unique(arm))) %>%
    mutate(dx=factor(class, levels=c("Baseline","Progressive Disease","Stable Disease","Partial Response")))

panel.labels <- fp2 %>%
    group_by(dx) %>%
    summarize(n=length(unique(id)),
              .groups="drop") %>%
    mutate(labels=paste0(c("Baseline (n=",
                           "Progressive Disease (n=",
                           "Stable Disease (n=", 
                           "Partial Response (n="
                           ),
                         n, ")"),
           arm="1p") %>%
    mutate(x=rep(5,4), y=rep(0.2, 4))


arm <- fp2 %>% group_by(arm) %>%
  summarize(n=n(), .groups="drop") %>%
  mutate(arm = as.character(arm))
arm.labels <- setNames(arm$arm, arm$arm)
#baseline
b<-read.csv(here("data/fp2_lucas_healthy.csv"))
medians<-b%>%group_by(bin)%>% summarise(Median=median(ratio.centered))
medians$bin <- as.factor(medians$bin)

cors<-left_join(fp2, medians, by="bin")

cors<-cors %>% group_by(id) %>% summarize(c=cor(ratio.centered, Median, method="spearman"))

fp2<-left_join(fp2,cors, by = "id")
df5<-fp2

df5<-df5 %>% mutate(d= case_when((c<=.25) ~ "0.00-0.25",
                                     (c<=.5) ~ "0.25-0.50",
                                     (c<= .75) ~ "0.50-0.75",
                                     (c<=1) ~"0.75-1.00"))

df5$class <- ordered(df5$class, levels = c("Baseline","Progressive Disease" , "Stable Disease","Partial Response"))
fig <- df5 %>%
   group_by(dx) %>%
    ggplot(aes(x = bin, y = ratio.centered, group=reorder(id, -c), col=d))+
    geom_line(size = 0.75) + 
  scale_color_manual(values=c("#B71643CA","#EB6429FF","grey70"))+
          #    alpha = 0.33) +
    labs(x = "",
         y = "Fragmentation profile\n", color = "") +
    facet_grid(dx~arm,  ##switch="x",
               space="free_x", scales="free_x",
               labeller=labeller(arm=arm.labels),
               switch="x") +    
    theme_classic(base_size=25) +
    theme(axis.text.x = element_blank(),
          panel.spacing.y = unit(2, "lines"),
          panel.spacing.x = unit(.2, "lines"),
          axis.ticks.x = element_blank(),
          strip.background=element_blank(),
          strip.text.y=element_blank(),
          axis.text.y=element_text(size=26),
           strip.text.x =element_text(angle=90),
          axis.title.y=element_text(size=30), legend.position=c(0.8, 0.95), legend.direction="horizontal") +
    scale_y_continuous(breaks=c(-0.2,-0.1, 0, 0.1, 0.2)) +
    coord_cartesian(ylim=c(-0.19, 0.19))
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.
Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
3.5.0.
ℹ Please use the `legend.position.inside` argument of `theme()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.
ggdraw(fig) +
  draw_grob(textGrob(label=panel.labels$labels[1],
                     x = unit(0.15, "npc"),
                     y = unit(0.97, "npc"),
                     hjust = 0,
                     gp = gpar(cex=2)))  +
  draw_grob(textGrob(label=panel.labels$labels[2],
                     x = unit(0.15, "npc"),
                     y = unit(0.75, "npc"),
                     hjust = 0,
                     gp = gpar(cex=2))) +
  draw_grob(textGrob(label=panel.labels$labels[3],
                     x = unit(0.15, "npc"),
                     y = unit(0.53, "npc"),
                     hjust = 0,
                     gp = gpar(cex=2))) + 
  draw_grob(textGrob(label=panel.labels$labels[4],
                     x = unit(0.15, "npc"),
                     y = unit(0.30, "npc"),
                     hjust = 0,
                     gp = gpar(cex=2)))

Version Author Date
29a8876 Shashikant Koul 2025-03-28
9bbcb47 Shashikant Koul 2025-03-27

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] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] rlucas_0.0.3    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 readxl_1.4.5   
[13] here_1.0.1      fs_1.6.5        cowplot_1.1.3   workflowr_1.7.1

loaded via a namespace (and not attached):
 [1] remotes_2.5.0               rlang_1.1.5                
 [3] magrittr_2.0.3              git2r_0.35.0               
 [5] matrixStats_1.5.0           compiler_4.4.1             
 [7] getPass_0.2-4               callr_3.7.6                
 [9] vctrs_0.6.5                 profvis_0.4.0              
[11] pkgconfig_2.0.3             crayon_1.5.3               
[13] fastmap_1.2.0               XVector_0.44.0             
[15] ellipsis_0.3.2              promises_1.3.2             
[17] rmarkdown_2.29              sessioninfo_1.2.3          
[19] tzdb_0.4.0                  UCSC.utils_1.0.0           
[21] ps_1.9.0                    bit_4.6.0                  
[23] xfun_0.51                   zlibbioc_1.50.0            
[25] cachem_1.1.0                GenomeInfoDb_1.40.1        
[27] jsonlite_1.9.1              later_1.4.1                
[29] DelayedArray_0.30.1         parallel_4.4.1             
[31] R6_2.6.1                    bslib_0.9.0                
[33] stringi_1.8.4               pkgload_1.4.0              
[35] GenomicRanges_1.56.2        jquerylib_0.1.4            
[37] cellranger_1.1.0            Rcpp_1.0.14                
[39] SummarizedExperiment_1.34.0 knitr_1.49                 
[41] usethis_3.1.0               IRanges_2.38.1             
[43] httpuv_1.6.15               Matrix_1.7-3               
[45] timechange_0.3.0            tidyselect_1.2.1           
[47] rstudioapi_0.17.1           abind_1.4-8                
[49] yaml_2.3.10                 miniUI_0.1.1.1             
[51] processx_3.8.6              pkgbuild_1.4.6             
[53] lattice_0.22-6              shiny_1.10.0               
[55] Biobase_2.64.0              withr_3.0.2                
[57] evaluate_1.0.3              desc_1.4.3                 
[59] urlchecker_1.0.1            pillar_1.10.1              
[61] MatrixGenerics_1.16.0       whisker_0.4.1              
[63] stats4_4.4.1                generics_0.1.3             
[65] vroom_1.6.5                 rprojroot_2.0.4            
[67] S4Vectors_0.42.1            hms_1.1.3                  
[69] munsell_0.5.1               scales_1.3.0               
[71] xtable_1.8-4                glue_1.8.0                 
[73] tools_4.4.1                 devtools_2.4.5             
[75] colorspace_2.1-1            GenomeInfoDbData_1.2.12    
[77] cli_3.6.4                   S4Arrays_1.4.1             
[79] rematch_2.0.0               gtable_0.3.6               
[81] sass_0.4.9                  digest_0.6.37              
[83] BiocGenerics_0.50.0         SparseArray_1.4.8          
[85] farver_2.1.2                htmlwidgets_1.6.4          
[87] memoise_2.0.1               htmltools_0.5.8.1          
[89] lifecycle_1.0.4             httr_1.4.7                 
[91] mime_0.12                   bit64_4.6.0-1