Last updated: 2021-08-13

Checks: 6 1

Knit directory: Turati_NatCancer_2021/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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 staged 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(20210812) 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 24970e4. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/bulk4_counts.rda
    Ignored:    data/bulk4_dds.rda
    Ignored:    data/paper_palette.rda
    Ignored:    data/signatures.rda
    Ignored:    output/figures/ExtFig5a_pca_3patients.pdf
    Ignored:    output/figures/ExtFig5b_pca_treatment_response.pdf
    Ignored:    output/tables/ExtFig5a_bulkRNAseq_data.xlsx
    Ignored:    output/tables/ExtFig5b_bulkRNAseq_data.xlsx

Untracked files:
    Untracked:  analysis/data-index2.Rmd
    Untracked:  docs2/
    Untracked:  output/deseq2-mini_bulk4_dds.3pts-Treated-vs-Untreated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt1-Treated-vs-Untreated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt12-Treated-vs-Untreated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt13-Treated-vs-Untreated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt2-Acutely treated-vs-Chronically treated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt2-Acutely treated-vs-Never treated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt2-Chronically treated-vs-Never treated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt2-Relapse-vs-Never treated.rds
    Untracked:  output/deseq2-mini_bulk4_dds.pt2-Treatment withdrawn-vs-Never treated.rds

Staged changes:
    Modified1:  bulkRNA/bulk-deseq2.Rmd
    Modified2:  analysis/bulkRNA-deseq2.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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


htmltools::tagList(rmarkdown::html_dependency_font_awesome())
# knitr::opts_chunk$set(cache = T, autodep = T)

library(knitr)
library(tidyverse)
library(DESeq2)
library(annotables)
library(DT)

Introduction

In this document, we are looking at the differences between groups of samples.

Please refer to the Data - Bulk RNAseq page for more info on the starting data.

data("bulk4_dds")
DGE <- function(deseq, grouping, c1, c2) {
  res <- results(deseq, contrast = c(grouping, c1, c2))
  resOrdered <- res[order(res$stat), ]
  resOrdered <- resOrdered[complete.cases(resOrdered), ]
  resOrdered <- rownames_to_column(data.frame(resOrdered), var = "ensgene") %>%
    dplyr::select(ensgene, log2FoldChange, stat, pvalue, padj) %>%
    left_join(grch38, by = "ensgene")

  return(resOrdered)
}
run_DESeq2_for_combinations <- function(deseq_obj, combinations, factor, label,
                                        save_data = F, level = 2) {
  if (!missing(label)) {
    label <- paste0("deseq2-", label, "-")
  } else {
    label <- "deseq2-"
  }
  # fgsea_list <- list()
  for (i in 1:nrow(combinations)) {
    if (!is.null(opts_knit$get("output.dir"))) {
      cat(paste0("\n", paste0(rep("#", level), collapse = ""),
                 " ", combinations$first[i], " vs ", combinations$second[i], "\n\n"))
    }
  
    contrast_name <- paste0(combinations$first[i], "-vs-", combinations$second[i])
  
    my_res <- DGE(deseq_obj,
                  factor,
                  combinations$first[i],
                  combinations$second[i])
  
    filename = paste0(label, contrast_name)
    print(htmltools::tagList(
      datatable(my_res %>% filter(padj < 0.05 & stat > 0) %>% arrange(desc(stat)) %>% head(n = 100),
                caption = paste(combinations$first[i],
                                "vs", combinations$second[i]),
                options = list(dom = 'frtip',
                               searchHighlight = TRUE)
                ),
      htmltools::tags$br(),
      datatable(my_res %>% filter(padj < 0.05 & stat < 0) %>% arrange(stat) %>% head(n = 100),
                caption = paste(combinations$first[i],
                                "vs", combinations$second[i]),
                options = list(dom = 'frtip',
                               searchHighlight = TRUE)
                ),
      htmltools::tags$br()
    ))
    if (save_data) {
      save_obj <- my_res
      usethis::use_directory("output")
      saveRDS(save_obj, file = paste0("output/", filename, ".rds"))
    }
  }
}

DESeq2 object

Treated vs Untreated – 3 patients

mini_bulk4_dds <- bulk4_dds[, colData(bulk4_dds)$patient %in% c("PT1", "PT12", "PT13")]
mini_bulk4_dds$patient <- droplevels(mini_bulk4_dds$patient)
mini_bulk4_dds$group <- droplevels(mini_bulk4_dds$group)
design(mini_bulk4_dds) <- formula(~patient + group)
mini_bulk4_dds <- DESeq(mini_bulk4_dds)
estimating size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
-- replacing outliers and refitting for 6627 genes
-- DESeq argument 'minReplicatesForReplace' = 7 
-- original counts are preserved in counts(dds)
estimating dispersions
fitting model and testing
my_combinations <- colData(mini_bulk4_dds) %>% as_tibble() %>%
  group_by(patient, group) %>%
  summarise(n = n()) %>%
  left_join(filter(., group %in% c("Untreated", "Never treated")),
            by = c("patient")) %>%
  filter(group.x != group.y) %>%
  select(patient, first = group.x, second = group.y, first.n = n.x, second.n = n.y) %>%
  mutate_at(c("first", "second"), as.character)
`summarise()` regrouping output by 'patient' (override with `.groups` argument)
datatable(my_combinations, extensions = "Buttons",
          options = list(searchHighlight = TRUE,
                         buttons = list("copy", 'csv', 'excel')))
run_DESeq2_for_combinations(mini_bulk4_dds, my_combinations[1, ], "group",
                            label = "mini_bulk4_dds.3pts", save_data = T)

Treated vs Untreated



✓ Setting active project to '/Users/javier/Projects/Turati_NatCancer_2021'

Treated vs Untreated – PT1

mini_bulk4_dds <- bulk4_dds[, colData(bulk4_dds)$patient %in% c("PT1")]
mini_bulk4_dds$group <- droplevels(mini_bulk4_dds$group)
design(mini_bulk4_dds) <- formula(~group)
mini_bulk4_dds <- DESeq(mini_bulk4_dds)
estimating size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
-- replacing outliers and refitting for 9435 genes
-- DESeq argument 'minReplicatesForReplace' = 7 
-- original counts are preserved in counts(dds)
estimating dispersions
fitting model and testing
run_DESeq2_for_combinations(mini_bulk4_dds, my_combinations[1, ], "group",
                            label = "mini_bulk4_dds.pt1", save_data = T)

Treated vs Untreated



Treated vs Untreated – PT12

mini_bulk4_dds <- bulk4_dds[, colData(bulk4_dds)$patient %in% c("PT12")]
mini_bulk4_dds$group <- droplevels(mini_bulk4_dds$group)
design(mini_bulk4_dds) <- formula(~group)
mini_bulk4_dds <- DESeq(mini_bulk4_dds)
estimating size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
run_DESeq2_for_combinations(mini_bulk4_dds, my_combinations[1, ], "group",
                            label = "mini_bulk4_dds.pt12", save_data = T)

Treated vs Untreated



Treated vs Untreated – PT13

mini_bulk4_dds <- bulk4_dds[, colData(bulk4_dds)$patient %in% c("PT13")]
mini_bulk4_dds$group <- droplevels(mini_bulk4_dds$group)
design(mini_bulk4_dds) <- formula(~group)
mini_bulk4_dds <- DESeq(mini_bulk4_dds)
estimating size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
run_DESeq2_for_combinations(mini_bulk4_dds, my_combinations[1, ], "group",
                            label = "mini_bulk4_dds.pt13", save_data = T)

Treated vs Untreated



Treatment response – PT2

mini_bulk4_dds <- bulk4_dds[, colData(bulk4_dds)$patient %in% c("PT2")]
mini_bulk4_dds$group <- droplevels(mini_bulk4_dds$group)
design(mini_bulk4_dds) <- formula(~group)
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
mini_bulk4_dds <- DESeq(mini_bulk4_dds)
estimating size factors
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
final dispersion estimates
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
fitting model and testing
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
-- replacing outliers and refitting for 2572 genes
-- DESeq argument 'minReplicatesForReplace' = 7 
-- original counts are preserved in counts(dds)
estimating dispersions
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
fitting model and testing
  Note: levels of factors in the design contain characters other than
  letters, numbers, '_' and '.'. It is recommended (but not required) to use
  only letters, numbers, and delimiters '_' or '.', as these are safe characters
  for column names in R. [This is a message, not an warning or error]
my_combinations <- colData(mini_bulk4_dds) %>% as_tibble() %>%
  group_by(patient, group) %>%
  summarise(n = n()) %>%
  left_join(filter(., group %in% c("Untreated", "Never treated")),
            by = c("patient")) %>%
  filter(group.x != group.y) %>%
  select(patient, first = group.x, second = group.y, first.n = n.x, second.n = n.y) %>%
  mutate_at(c("first", "second"), as.character)
`summarise()` regrouping output by 'patient' (override with `.groups` argument)
additional_combination <- my_combinations %>%
  filter(grepl("Acute", first)) %>%
  mutate(second = my_combinations %>%
           filter(grepl("Chronic", first)) %>% pull(first),
         second.n = my_combinations %>%
           filter(grepl("Chronic", first)) %>% pull(first.n))

my_combinations <- rbind(my_combinations, additional_combination)

datatable(my_combinations)
run_DESeq2_for_combinations(mini_bulk4_dds, my_combinations, "group",
                            label = "mini_bulk4_dds.pt2", save_data = T)

Acutely treated vs Never treated



Chronically treated vs Never treated



Relapse vs Never treated



Treatment withdrawn vs Never treated



Acutely treated vs Chronically treated




sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] DT_0.13                     annotables_0.1.91          
 [3] DESeq2_1.26.0               SummarizedExperiment_1.16.1
 [5] DelayedArray_0.12.3         BiocParallel_1.20.1        
 [7] matrixStats_0.56.0          Biobase_2.46.0             
 [9] GenomicRanges_1.38.0        GenomeInfoDb_1.22.0        
[11] IRanges_2.20.2              S4Vectors_0.24.4           
[13] BiocGenerics_0.32.0         forcats_0.5.0              
[15] stringr_1.4.0               dplyr_1.0.0                
[17] purrr_0.3.3                 readr_1.3.1                
[19] tidyr_1.0.2                 tibble_2.1.3               
[21] ggplot2_3.3.1               tidyverse_1.3.0            
[23] knitr_1.28                 

loaded via a namespace (and not attached):
 [1] colorspace_1.4-1       ellipsis_0.3.0         rprojroot_1.3-2       
 [4] htmlTable_1.13.3       XVector_0.26.0         base64enc_0.1-3       
 [7] fs_1.3.2               rstudioapi_0.11        bit64_0.9-7           
[10] AnnotationDbi_1.48.0   lubridate_1.7.4        xml2_1.2.5            
[13] splines_3.6.3          geneplotter_1.64.0     Formula_1.2-3         
[16] jsonlite_1.6.1         workflowr_1.6.2        broom_0.5.5           
[19] annotate_1.64.0        cluster_2.1.0          dbplyr_1.4.2          
[22] png_0.1-7              compiler_3.6.3         httr_1.4.1            
[25] backports_1.1.5        assertthat_0.2.1       Matrix_1.2-18         
[28] cli_3.0.0              later_1.0.0            acepack_1.4.1         
[31] htmltools_0.5.1.1      tools_3.6.3            gtable_0.3.0          
[34] glue_1.3.2             GenomeInfoDbData_1.2.2 Rcpp_1.0.4            
[37] cellranger_1.1.0       vctrs_0.3.0            nlme_3.1-145          
[40] crosstalk_1.1.0.1      xfun_0.16              rvest_0.3.5           
[43] lifecycle_0.2.0        XML_3.99-0.3           zlibbioc_1.32.0       
[46] scales_1.1.0           hms_0.5.3              promises_1.1.0        
[49] RColorBrewer_1.1-2     yaml_2.2.1             memoise_1.1.0         
[52] gridExtra_2.3          rpart_4.1-15           latticeExtra_0.6-29   
[55] stringi_1.4.6          RSQLite_2.2.0          genefilter_1.68.0     
[58] checkmate_2.0.0        rlang_0.4.11           pkgconfig_2.0.3       
[61] bitops_1.0-6           evaluate_0.14          lattice_0.20-40       
[64] htmlwidgets_1.5.1      bit_1.1-15.2           tidyselect_1.1.0      
[67] magrittr_1.5           R6_2.4.1               generics_0.0.2        
[70] Hmisc_4.3-1            DBI_1.1.0              pillar_1.4.3          
[73] haven_2.2.0            foreign_0.8-76         withr_2.4.2           
[76] survival_3.1-11        RCurl_1.98-1.1         nnet_7.3-13           
[79] modelr_0.1.6           crayon_1.3.4           rmarkdown_2.1         
[82] usethis_2.0.1          jpeg_0.1-8.1           locfit_1.5-9.1        
[85] grid_3.6.3             readxl_1.3.1           data.table_1.12.8     
[88] blob_1.2.1             git2r_0.26.1           reprex_0.3.0          
[91] digest_0.6.25          xtable_1.8-4           httpuv_1.5.2          
[94] munsell_0.5.0         
LS0tCnRpdGxlOiAiQnVsayBSTkEtc2VxIERpZmZlcmVudGlhbCBFeHByZXNzaW9uIHdpdGggREVTZXEyIgpvdXRwdXQ6IHdvcmtmbG93cjo6d2Zsb3dfaHRtbAplZGl0b3Jfb3B0aW9uczoKICBjaHVua19vdXRwdXRfdHlwZTogY29uc29sZQotLS0KCmBgYHtyIHNldHVwLCB3YXJuaW5nID0gRkFMU0UsIG1lc3NhZ2UgPSBGQUxTRX0KaHRtbHRvb2xzOjp0YWdMaXN0KHJtYXJrZG93bjo6aHRtbF9kZXBlbmRlbmN5X2ZvbnRfYXdlc29tZSgpKQojIGtuaXRyOjpvcHRzX2NodW5rJHNldChjYWNoZSA9IFQsIGF1dG9kZXAgPSBUKQoKbGlicmFyeShrbml0cikKbGlicmFyeSh0aWR5dmVyc2UpCmxpYnJhcnkoREVTZXEyKQpsaWJyYXJ5KGFubm90YWJsZXMpCmxpYnJhcnkoRFQpCmBgYAoKCiMgSW50cm9kdWN0aW9uCgpJbiB0aGlzIGRvY3VtZW50LCB3ZSBhcmUgbG9va2luZyBhdCB0aGUgZGlmZmVyZW5jZXMgYmV0d2VlbiBncm91cHMgb2Ygc2FtcGxlcy4KClBsZWFzZSByZWZlciB0byB0aGUgW0RhdGEgLSBCdWxrIFJOQXNlcV0oZGF0YS1idWxrUk5Bc2VxLmh0bWwpIHBhZ2UgZm9yIG1vcmUgaW5mbyBvbiB0aGUgc3RhcnRpbmcgZGF0YS4KCmBgYHtyIHJlYWRfZGF0YX0KZGF0YSgiYnVsazRfZGRzIikKYGBgCgpgYGB7ciBER0VfZnVuY3Rpb259CkR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