Last updated: 2021-08-16
Checks: 7 0
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.
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(20200627)
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 01ec959. 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: bulkRNA/
Ignored: data/bulk4_counts.rda
Ignored: data/bulk4_dds.rda
Ignored: data/paper_palette.rda
Ignored: data/signatures.rda
Ignored: output/deseq2-mini_bulk4_dds.3pts-Treated-vs-Untreated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt1-Treated-vs-Untreated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt12-Treated-vs-Untreated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt13-Treated-vs-Untreated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt2-Acutely treated-vs-Chronically treated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt2-Acutely treated-vs-Never treated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt2-Chronically treated-vs-Never treated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt2-Relapse-vs-Never treated.rds
Ignored: output/deseq2-mini_bulk4_dds.pt2-Treatment withdrawn-vs-Never treated.rds
Ignored: output/fgsea_results.RDS
Ignored: output/figures/ExtFig5a_pca_3patients.pdf
Ignored: output/figures/ExtFig5b_pca_treatment_response.pdf
Ignored: output/figures/Fig5C_fgsea_selected_signatures.pdf
Ignored: output/figures/ItemS2.pdf
Ignored: output/tables/ExtFig5a_bulkRNAseq_data.xlsx
Ignored: output/tables/ExtFig5b_bulkRNAseq_data.xlsx
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/bulkRNA-deseq2.Rmd
) and HTML (docs/bulkRNA-deseq2.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 | 01ec959 | Javier Herrero | 2021-08-16 | wflow_publish(all = T) |
html | 01ec959 | Javier Herrero | 2021-08-16 | wflow_publish(all = T) |
html | e02ea6e | Javier Herrero | 2021-08-16 | Build site. |
html | b6f5b35 | Javier Herrero | 2021-08-13 | Build site. |
html | 537463a | Javier Herrero | 2021-08-13 | Update site |
Rmd | c2ccafd | Javier Herrero | 2021-08-13 | Add “Bulk RNAseq / DESeq2” page |
html | c2ccafd | Javier Herrero | 2021-08-13 | Add “Bulk RNAseq / DESeq2” page |
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)
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"))
}
}
}
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)
✓ Setting active project to '/Users/javier/Projects/Turati_NatCancer_2021'
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)
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)
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)
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)
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 workflowr_1.6.2
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 broom_0.5.5 annotate_1.64.0
[19] cluster_2.1.0 dbplyr_1.4.2 png_0.1-7
[22] compiler_3.6.3 httr_1.4.1 backports_1.1.5
[25] assertthat_0.2.1 Matrix_1.2-18 cli_3.0.0
[28] later_1.0.0 acepack_1.4.1 htmltools_0.5.1.1
[31] tools_3.6.3 gtable_0.3.0 glue_1.3.2
[34] GenomeInfoDbData_1.2.2 Rcpp_1.0.4 cellranger_1.1.0
[37] vctrs_0.3.0 nlme_3.1-145 crosstalk_1.1.0.1
[40] xfun_0.16 rvest_0.3.5 lifecycle_0.2.0
[43] XML_3.99-0.3 zlibbioc_1.32.0 scales_1.1.0
[46] hms_0.5.3 promises_1.1.0 RColorBrewer_1.1-2
[49] yaml_2.2.1 memoise_1.1.0 gridExtra_2.3
[52] rpart_4.1-15 latticeExtra_0.6-29 stringi_1.4.6
[55] RSQLite_2.2.0 genefilter_1.68.0 checkmate_2.0.0
[58] rlang_0.4.11 pkgconfig_2.0.3 bitops_1.0-6
[61] evaluate_0.14 lattice_0.20-40 htmlwidgets_1.5.1
[64] bit_1.1-15.2 tidyselect_1.1.0 magrittr_1.5
[67] R6_2.4.1 generics_0.0.2 Hmisc_4.3-1
[70] DBI_1.1.0 pillar_1.4.3 haven_2.2.0
[73] whisker_0.4 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