Last updated: 2021-02-10
Checks: 7 0
Knit directory: melanoma_publication_old_data/
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(20200728)
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 2e443a5. 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: .Rhistory
Ignored: .Rproj.user/
Ignored: ._.DS_Store
Ignored: code/.DS_Store
Ignored: code/._.DS_Store
Ignored: code/helper_functions/._findCommunity.R
Ignored: data/.DS_Store
Ignored: data/._.DS_Store
Ignored: data/._layer_1_classification_rna.csv
Ignored: data/._survdat_for_modelling.csv
Ignored: data/12plex_validation/
Ignored: data/200323_TMA_256_Hot Cold_Clinical Data_Updated Response Data_For Collaborators_latest updated_Mar_2020_for_Coxph_modeling.csv
Ignored: data/layer_1_classification_protein.csv
Ignored: data/layer_1_classification_rna.csv
Ignored: data/manual_infiltration/
Ignored: data/protein/
Ignored: data/rna/
Ignored: data/safety_copy_SCE/
Ignored: data/sce_RNA.rds
Ignored: data/sce_protein.rds
Ignored: data/survdat_for_modelling.csv
Ignored: output/.DS_Store
Ignored: output/._.DS_Store
Ignored: output/._protein_neutrophil.png
Ignored: output/._rna_neutrophil.png
Ignored: output/PSOCKclusterOut/
Ignored: output/bcell_grouping.png
Ignored: output/dysfunction_correlation.pdf
Unstaged changes:
Modified: .gitignore
Modified: analysis/04_1_Protein_celltype_classification.rmd
Modified: analysis/04_1_RNA_celltype_classification.rmd
Modified: analysis/Summary_Statistics.rmd
Modified: analysis/Supp-Figure_2.rmd
Modified: analysis/Supp-Figure_4.rmd
Deleted: code/findPackages.R
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/XX_hazard_ratio.rmd
) and HTML (docs/XX_hazard_ratio.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 | 3db41a4 | toobiwankenobi | 2021-02-04 | hazard ratio analysis |
First, we will load the libraries needed for this part of the analysis.
sapply(list.files("code/helper_functions", full.names = TRUE), source)
code/helper_functions/calculateSummary.R
value ?
visible FALSE
code/helper_functions/censor_dat.R
value ?
visible FALSE
code/helper_functions/detect_mRNA_expression.R
value ?
visible FALSE
code/helper_functions/DistanceToClusterCenter.R
value ?
visible FALSE
code/helper_functions/findClusters.R
value ?
visible FALSE
code/helper_functions/findCommunity.R
value ?
visible FALSE
code/helper_functions/getCellCount.R
value ?
visible FALSE
code/helper_functions/getInfoFromString.R
value ?
visible FALSE
code/helper_functions/getSpotnumber.R
value ?
visible FALSE
code/helper_functions/plotBarFracCluster.R
value ?
visible FALSE
code/helper_functions/plotCellCounts.R
value ?
visible FALSE
code/helper_functions/plotCellFrac.R
value ?
visible FALSE
code/helper_functions/plotCellFracGroups.R
value ?
visible FALSE
code/helper_functions/plotCellFracGroupsSubset.R
value ?
visible FALSE
code/helper_functions/plotCellFractions.R
value ?
visible FALSE
code/helper_functions/plotDist.R
value ?
visible FALSE
code/helper_functions/scatter_function.R
value ?
visible FALSE
code/helper_functions/sceChecks.R
value ?
visible FALSE
code/helper_functions/validityChecks.R
value ?
visible FALSE
library(SingleCellExperiment)
library(reshape2)
library(tidyverse)
library(dplyr)
library(data.table)
library(ggplot2)
library(survminer)
library(survival)
sce_rna = readRDS(file = "data/sce_RNA.rds")
sce_prot = readRDS(file = "data/sce_protein.rds")
# meta data
dat_survival = fread(file = "data/protein/clinical_data_protein.csv",stringsAsFactors = FALSE)
time_data = fread(file = "data/survdat_for_modelling.csv",stringsAsFactors = FALSE)
time_data$BlockID <- time_data$Block.ID
# Select for BlockID: Pre-Treatment, Mutation, Age, Cancer Stage
cur_dat <- data.frame(colData(sce_prot)) %>%
distinct(BlockID, .keep_all = T) %>%
select(BlockID, Mutation, Age, Cancer_Stage, treatment_status_before_surgery) %>%
filter(treatment_status_before_surgery != "control")
# derive Tcell Score for Block (max score per block)
score <- data.frame(colData(sce_prot)) %>%
distinct(Description, .keep_all = T) %>%
filter(paste(MM_location, Location, sep = "_") != "LN_M") %>% # remove LN margin samples as these are not relevant
group_by(BlockID, Tcell_density_score_image) %>%
summarise(n=n()) %>%
filter(row_number()==n()) %>% # select last row of groups since this will always be the highest ranking
select(BlockID, Tcell_density_score_image)
`summarise()` regrouping output by 'BlockID' (override with `.groups` argument)
cur_dat <- left_join(cur_dat, score)
Joining, by = "BlockID"
# change certain levels
cur_dat$Age <- ifelse(cur_dat$Age == "?60", ">60", cur_dat$Age)
cur_dat$Cancer_Stage <- ifelse(cur_dat$Cancer_Stage == "III or IV", "IV/III", cur_dat$Cancer_Stage)
# relevel factors
cur_dat$Age <- factor(cur_dat$Age, levels = c("<45", "45-59", ">60"))
cur_dat$Mutation <- factor(cur_dat$Mutation, levels = c("wt", "BRAF", "NRAS", "unknown"))
cur_dat$Cancer_Stage <- factor(cur_dat$Cancer_Stage, levels = c("III", "IV"))
cur_dat$treatment_status_before_surgery <- factor(cur_dat$treatment_status_before_surgery, levels = c("naive", "non-naive"))
cur_dat$Tcell_density_score_image <- factor(cur_dat$Tcell_density_score_image, levels = c("high", "med", "low", "absent"))
# join with survival dat
surv <- left_join(time_data[,c("BlockID", "Time_to_.progression_or_last_PET", "censoring_progression", "Time_to_death_or_last_PET", "censoring_death")], cur_dat)
Joining, by = "BlockID"
# exclude GNAQ and KRAS mutation due to too few data points
surv_sub <- surv[!(surv$Mutation %in% c("KRAS", "GNAQ")),]
surv_sub <- surv[!(surv$Cancer_Stage %in% c("III/IV", "unknown")),]
colnames(surv_sub) <- c("BlockID", "Time_progression", "censoring_progression", "Time_death", "censoring_death",
"Mutation", "Age", "Cancer Stage", "Treatment Status", "Max Tcell Score")
model <- coxph(Surv(Time_death, censoring_death) ~
Age + `Cancer Stage` + `Treatment Status` + `Max Tcell Score` + Mutation,
data = surv_sub)
ggforest(model, data=surv_sub)
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] survival_3.2-7 survminer_0.4.8
[3] ggpubr_0.4.0 data.table_1.13.6
[5] forcats_0.5.0 stringr_1.4.0
[7] dplyr_1.0.2 purrr_0.3.4
[9] readr_1.4.0 tidyr_1.1.2
[11] tibble_3.0.4 ggplot2_3.3.3
[13] tidyverse_1.3.0 reshape2_1.4.4
[15] SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0
[17] Biobase_2.50.0 GenomicRanges_1.42.0
[19] GenomeInfoDb_1.26.2 IRanges_2.24.1
[21] S4Vectors_0.28.1 BiocGenerics_0.36.0
[23] MatrixGenerics_1.2.0 matrixStats_0.57.0
[25] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] bitops_1.0-6 fs_1.5.0 lubridate_1.7.9.2
[4] httr_1.4.2 rprojroot_2.0.2 tools_4.0.3
[7] backports_1.2.1 R6_2.5.0 DBI_1.1.0
[10] colorspace_2.0-0 withr_2.3.0 gridExtra_2.3
[13] tidyselect_1.1.0 curl_4.3 compiler_4.0.3
[16] git2r_0.28.0 cli_2.2.0 rvest_0.3.6
[19] xml2_1.3.2 DelayedArray_0.16.0 labeling_0.4.2
[22] scales_1.1.1 survMisc_0.5.5 digest_0.6.27
[25] foreign_0.8-81 rmarkdown_2.6 rio_0.5.16
[28] XVector_0.30.0 pkgconfig_2.0.3 htmltools_0.5.0
[31] dbplyr_2.0.0 rlang_0.4.10 readxl_1.3.1
[34] rstudioapi_0.13 farver_2.0.3 generics_0.1.0
[37] zoo_1.8-8 jsonlite_1.7.2 zip_2.1.1
[40] car_3.0-10 RCurl_1.98-1.2 magrittr_2.0.1
[43] GenomeInfoDbData_1.2.4 Matrix_1.3-2 Rcpp_1.0.5
[46] munsell_0.5.0 fansi_0.4.1 abind_1.4-5
[49] lifecycle_0.2.0 stringi_1.5.3 whisker_0.4
[52] yaml_2.2.1 carData_3.0-4 zlibbioc_1.36.0
[55] plyr_1.8.6 grid_4.0.3 promises_1.1.1
[58] crayon_1.3.4 lattice_0.20-41 cowplot_1.1.1
[61] splines_4.0.3 haven_2.3.1 hms_0.5.3
[64] knitr_1.30 pillar_1.4.7 ggsignif_0.6.0
[67] reprex_0.3.0 glue_1.4.2 evaluate_0.14
[70] modelr_0.1.8 vctrs_0.3.6 httpuv_1.5.4
[73] cellranger_1.1.0 gtable_0.3.0 km.ci_0.5-2
[76] assertthat_0.2.1 openxlsx_4.2.3 xfun_0.20
[79] xtable_1.8-4 broom_0.7.3 rstatix_0.6.0
[82] later_1.1.0.1 KMsurv_0.1-5 ellipsis_0.3.1