Last updated: 2021-02-18
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 ee1595d. 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: .Rproj.user/
Ignored: ._.DS_Store
Ignored: analysis/._clinical metadata preparation.Rmd
Ignored: code/.DS_Store
Ignored: code/._.DS_Store
Ignored: data/.DS_Store
Ignored: data/._.DS_Store
Ignored: data/data_for_analysis/
Ignored: data/full_data/
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/04_2_RNA_classification_subclustering.rmd
Modified: analysis/04_2_protein_classification_subclustering.rmd
Modified: analysis/07_TCF7_PD1_gating.rmd
Modified: analysis/08_color_vectors.rmd
Modified: analysis/09_Tcell_Score.Rmd
Modified: analysis/10_Dysfunction_Score.rmd
Modified: analysis/11_Bcell_Score.Rmd
Modified: analysis/Figure_1.rmd
Modified: analysis/Figure_2.rmd
Modified: analysis/Figure_3.rmd
Modified: analysis/Figure_4.rmd
Modified: analysis/Figure_5.rmd
Modified: analysis/Supp-Figure_1.rmd
Modified: analysis/Supp-Figure_2.rmd
Modified: analysis/Supp-Figure_3.rmd
Modified: analysis/Supp-Figure_4.rmd
Modified: analysis/Supp-Figure_5.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/00_prepare_clinical_dat.rmd
) and HTML (docs/00_prepare_clinical_dat.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 | ee1595d | toobiwankenobi | 2021-02-12 | clean repo and adapt files |
html | ee1595d | toobiwankenobi | 2021-02-12 | clean repo and adapt files |
In this script, we load the clinical data and clean and prepare the data for further analysis. Furthermore, we create two .csv files containing the clinical data for RNA and Protein TMA separately in order to attach them to the SingleCellExperiment in a later step.
knitr::opts_chunk$set(echo = TRUE, message= FALSE)
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
library(dplyr)
# load clinical data and TMA data to link images with patients
clinical_mat <- read.csv(file = "data/data_for_analysis/200323_TMA_256_clinical_data_March2020.csv",
sep=",",stringsAsFactors = FALSE)
clinical_mat <- clinical_mat[is.na(clinical_mat$SpotNr) == FALSE,]
spot_mat <- read.csv(file = "data/data_for_analysis/191119_TMA_spotmatrix.csv", sep= ";",stringsAsFactors = FALSE)
# remove missing value rows from spot_mat
spot_mat <- spot_mat[is.na(spot_mat$SpotNr) == FALSE,]
# in the spot_mat BlockID "B2017.47224" has a space incorporated: "B2017.47224 ". We will rename this BlockID here.
spot_mat[which(spot_mat$BlockID == "B2017.47224 "),]$BlockID <- "B2017.47224"
# load image metadata as output from CellProfiler
image_mat_prot <- read.csv(file = "data/data_for_analysis/protein/Image.csv", stringsAsFactors = FALSE)
image_mat_rna <- read.csv(file = "data/data_for_analysis/rna/Image.csv", stringsAsFactors = FALSE)
colnames(clinical_mat)
[1] "SpotNr"
[2] "Internal.Pat..ID"
[3] "Block.ID"
[4] "IHC.T.cell.scoring"
[5] "Age.range"
[6] "Gender"
[7] "MM.location"
[8] "melanoma.subtype..site.of.primary.tumor."
[9] "Cancer.Stage"
[10] "Mutation"
[11] "Number.of.treatments.before.surgery"
[12] "Name.of.last.drug.used"
[13] "Last.systemic.treatment.before.surgery"
[14] "date..last.prev.therapy"
[15] "Date.of.surgery"
[16] "Drug.used.after.surgery"
[17] "Next.systemic.treatment.after.surgery..PC.Paliative.Care."
[18] "Adjuvant"
[19] "start.of.treatment"
[20] "end.of.treatment"
[21] "Reason.to.stop.treatment..EOT..end.of.treatment..PD..progression..SE..side.effects..TC..therapy.change..NA..not.applicable."
[22] "Date.of.progression"
[23] "Response.at..3m..R.or.NR.or.NA..for.MR.or.no.treatment..or.adjuvant.at.3m."
[24] "X.at.3m..PD.progressive.disease..SD.stable.disease..PR.partial.response..CR.complete.response..MR.mixed.response..RFS.relapse.free.survival..adjuvant.patients."
[25] "Time.of.response.assesment..3m.for.all.except.for.adjuvant.12m."
[26] "Response.at..6m..PD.progressive.disease..SD.stable.disease..PR.partial.response..CR.complete.response..MR.mixed.response..RFS.relapse.free.survival..adjuvant.patients...TC..therapy.change"
[27] "Response.at..12m..PD.progressive.disease..SD.stable.disease..PR.partial.response..CR.complete.response..MR.mixed.response..RFS.relapse.free.survival..adjuvant...NY..not.yet"
[28] "Last.PET"
[29] "Death.Date"
clean_names <- c("SpotNr","PatientID","BlockID","IHC_T_score","Age_range","Gender",
"MM_location","Primary_melanoma_type","Cancer_Stage","Mutation",
"Nr_treatments_before_surgery","Name_last_drug_used","Last_sys_treatment_before_surgery",
"Last_prev_therapy","Date_surgery","Drug_after_surgery","Treatment_after_surgery","Adjuvant",
"Start_treatment","End_treatment","Reason_to_stop_treatment","Date_progression",
"Status_at_3m","Response_at_3m","Time_of_response_assesment","Response_at_6m",
"Response_at_12m","Last_PET","Date_death")
colnames(clinical_mat) <- clean_names
# empty but non NA date_progression is equal to no progression
clinical_mat <- data.frame(clinical_mat)
clinical_mat$relapse <- NA
clinical_mat[is.na(clinical_mat$Date_progression) & is.na(clinical_mat$Nr_treatments_before_surgery) == FALSE,]$relapse <- "untreated/lost"
clinical_mat[clinical_mat$Date_progression %in% c("") & is.na(clinical_mat$Nr_treatments_before_surgery) == FALSE,]$relapse <- "no relapse"
clinical_mat[is.na(clinical_mat$relapse) & is.na(clinical_mat$Nr_treatments_before_surgery) == FALSE,]$relapse <- "relapse"
clinical_mat[is.na(clinical_mat$Nr_treatments_before_surgery),]$relapse <- "control"
Starting point is the beginning of the surgery, end point is death/progression or last PET
clinical_mat$Date_surgery <- as.Date(clinical_mat$Date_surgery, format = "%d.%m.%Y")
clinical_mat$Date_death <- as.Date(clinical_mat$Date_death, format = "%d.%m.%Y")
clinical_mat$Date_progression <- as.Date(clinical_mat$Date_progression, format = "%d.%m.%Y")
clinical_mat$Last_PET <- as.Date(clinical_mat$Last_PET, format = "%d.%m.%Y")
clinical_mat$Start_treatment <- as.Date(clinical_mat$Start_treatment, format = "%d.%m.%Y")
clinical_mat$End_treatment <- as.Date(clinical_mat$End_treatment, format = "%d.%m.%Y")
clinical_mat$Time_to_death_or_last_PET <- ifelse(is.na(clinical_mat$Date_death) == TRUE, # if no death, then
clinical_mat$Last_PET - clinical_mat$Start_treatment, # time to last PET
clinical_mat$Date_death - clinical_mat$Start_treatment) # else: time to progression
clinical_mat$censoring_death <- ifelse(is.na(clinical_mat$Date_death) == TRUE, 0, 1) # 0: no Death, 1: Death
clinical_mat$Time_to_progression_or_last_PET <- ifelse(is.na(clinical_mat$Date_progression) == TRUE, # if no progression, then
clinical_mat$Last_PET - clinical_mat$Start_treatment, # time to last PET
clinical_mat$Date_progression - clinical_mat$Start_treatment) # else: time to progression
clinical_mat$censoring_progression <- ifelse(is.na(clinical_mat$Date_progression) == TRUE, 0, 1) # 0: no Relapse, 1: Relapse
# SpotNr and Description in one mat
full_mat_rna <- spot_mat[,c("SpotNr", "BlockID", "Description", "TissueType", "Location")]
# add respective ImageNumber
image_mat_rna$Description <- image_mat_rna$Metadata_Description
full_mat_rna <- left_join(full_mat_rna, image_mat_rna[,c("ImageNumber", "Description")], by = "Description")
# join with clinical_mat
full_mat_rna <- left_join(full_mat_rna, clinical_mat[,-1], by="BlockID")
# remove Images that were not acquired or removed after initial processing (missing on TMA or too bad quality)
full_mat_rna <- full_mat_rna[is.na(full_mat_rna$ImageNumber) == FALSE,]
# SpotNr and Description in one mat
full_mat_prot <- spot_mat[,c("SpotNr", "BlockID", "Description", "TissueType", "Location")]
image_mat_prot$Description <- image_mat_prot$Metadata_Description
# rename "G1 - split" row in image_mat (this core was acquired in two measurements because the machine stopped due to an error)
image_mat_prot$Description <- ifelse(image_mat_prot$Description == "G1 - split", "G1", image_mat_prot$Description)
# add respective ImageNumber
full_mat_prot <- left_join(full_mat_prot, image_mat_prot[,c("ImageNumber", "Description")], by = "Description")
# join with clinical_mat
full_mat_prot <- left_join(full_mat_prot, clinical_mat[,-1], by = "BlockID")
# remove Images that were not acquired or removed after initial processing (missing on TMA or too bad quality)
full_mat_prot <- full_mat_prot[is.na(full_mat_prot$ImageNumber) == FALSE,]
# check if the BlockID/PatientID of Description is the same in both data sets
rna_sub <- full_mat_rna[,c("Description", "BlockID", "PatientID")]
prot_sub <- full_mat_prot[,c("Description", "BlockID", "PatientID")]
compare <- left_join(prot_sub, rna_sub, by = "Description")
all(compare$BlockID.x == compare$BlockID.y)
[1] TRUE
unique(compare$PatientID.x == compare$PatientID.y)
[1] TRUE NA
write.csv(x = full_mat_prot, file = "data/data_for_analysis/protein/clinical_data_protein.csv", row.names = F)
write.csv(x = full_mat_rna, file = "data/data_for_analysis/rna/clinical_data_RNA.csv", row.names = F)
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] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.2 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.13 whisker_0.4 knitr_1.30
[5] magrittr_2.0.1 tidyselect_1.1.0 R6_2.5.0 rlang_0.4.10
[9] stringr_1.4.0 tools_4.0.3 xfun_0.20 git2r_0.28.0
[13] htmltools_0.5.0 ellipsis_0.3.1 rprojroot_2.0.2 yaml_2.2.1
[17] digest_0.6.27 tibble_3.0.4 lifecycle_0.2.0 crayon_1.3.4
[21] purrr_0.3.4 later_1.1.0.1 vctrs_0.3.6 promises_1.1.1
[25] fs_1.5.0 glue_1.4.2 evaluate_0.14 rmarkdown_2.6
[29] stringi_1.5.3 compiler_4.0.3 pillar_1.4.7 generics_0.1.0
[33] httpuv_1.5.4 pkgconfig_2.0.3