Last updated: 2021-02-04
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 20a1458. 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/._density_infiltration_BlockID.csv
Ignored: data/._layer_1_classification_rna.csv
Ignored: data/._manual_infiltration_scoring.csv
Ignored: data/._manual_infiltration_scoring_BlockID.csv
Ignored: data/._manual_infiltration_scoring_RC.csv
Ignored: data/._manual_infiltration_scoring_TH.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/colour_vector.rds
Ignored: data/density_infiltration_BlockID.csv
Ignored: data/fraction_and_infiltration_scoring.csv
Ignored: data/layer_1_classification_protein.csv
Ignored: data/layer_1_classification_protein.rds
Ignored: data/layer_1_classification_rna.csv
Ignored: data/manual_infiltration_scoring.csv
Ignored: data/manual_infiltration_scoring_BlockID.csv
Ignored: data/manual_infiltration_scoring_RC.csv
Ignored: data/manual_infiltration_scoring_TH.csv
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
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/06_Protein_Ki67status.Rmd
) and HTML (docs/06_Protein_Ki67status.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 | 9442cb9 | toobiwankenobi | 2020-12-22 | add all new files |
Rmd | 7affca0 | toobiwankenobi | 2020-10-13 | clean branch and add suppfigure 2 |
Rmd | d8819f2 | toobiwankenobi | 2020-10-08 | read new data (nuclei expansion) and adapt scripts |
knitr::opts_chunk$set(echo = TRUE, message= FALSE)
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
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(dplyr)
library(ggplot2)
library(reshape2)
library(ggridges)
sce_protein <- readRDS(file = "data/sce_protein.rds")
sce_rna <- readRDS(file = "data/sce_RNA.rds")
y <- c(rep(1:10,16),rep(11,7))
# add the group information to the sce object
sce_protein$groups <- y[colData(sce_protein)$ImageNumber]
# now we use the function written by Nils
plotDist(sce_protein["Ki67",], plot_type = "ridges",
colour_by = "groups", split_by = "rows",
exprs_values = "asinh") +
geom_vline(xintercept = 1)
We define the Ki67 treshold at 1 (asinh) count. This corresponds to a mean pixel count of 1.175 per cell. This is robust enough to detect all Ki67+ cells (verified using histoCAT web version). All cells that are visible identifiable as Ki67+ have a mean count of clearly more than 1.
# remove exisiting columns
sce_rna$Ki67_fraction <- NULL
sce_rna$Ki67_status <- NULL
sce_protein$Ki67_fraction <- NULL
sce_protein$Ki67_status <- NULL
sce_protein$Ki67 <- ifelse(assay(sce_protein["Ki67",], "asinh") > 1, "positive", "negative")
# calculate percentage of positive tumor cells over all tumor cells
cur_df <- data.frame(colData(sce_protein)) %>%
group_by(Description, celltype, Ki67) %>%
summarise(n = n()) %>%
filter(celltype == "Tumor") %>%
reshape2::dcast(Description ~ Ki67, value.var = "n", fill = 0) %>%
group_by(Description) %>%
mutate(Ki67_fraction = (positive / (positive + negative)))
# add staging (<6% low, 6-10% intermediate, >10% high)
cur_df$Ki67_status <- ""
cur_df[cur_df$Ki67_fraction < 0.06,]$Ki67_status <- "low"
cur_df[cur_df$Ki67_fraction >= 0.06 & cur_df$Ki67_fraction <= 0.1,]$Ki67_status <- "intermediate"
cur_df[cur_df$Ki67_fraction > 0.1,]$Ki67_status <- "high"
# remove unwanted columns from cur_df
cur_df[,2:3] <- NULL
# add to colData
cur_prot <- data.frame(colData(sce_protein))
cur_prot <- left_join(cur_prot, cur_df, by="Description")
# add to rna set based on protein staging
cur_rna <- data.frame(colData(sce_rna))
cur_rna <- left_join(cur_rna, cur_df, by="Description")
# add new column to SCE
sce_protein$Ki67_status <- cur_prot$Ki67_status
sce_rna$Ki67_status <- cur_rna$Ki67_status
sce_protein$Ki67_fraction <- cur_prot$Ki67_fraction
sce_rna$Ki67_fraction <- cur_rna$Ki67_fraction
# relevel
sce_protein$Ki67_status <- factor(sce_protein$Ki67_status, levels = c("low", "intermediate", "high"))
sce_rna$Ki67_status <- factor(sce_rna$Ki67_status, levels = c("low", "intermediate", "high"))
saveRDS(sce_protein, file = "data/sce_protein.rds")
saveRDS(sce_rna, file = "data/sce_RNA.rds")
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] ggridges_0.5.3 reshape2_1.4.4
[3] ggplot2_3.3.3 dplyr_1.0.2
[5] SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0
[7] Biobase_2.50.0 GenomicRanges_1.42.0
[9] GenomeInfoDb_1.26.2 IRanges_2.24.1
[11] S4Vectors_0.28.1 BiocGenerics_0.36.0
[13] MatrixGenerics_1.2.0 matrixStats_0.57.0
[15] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] tidyselect_1.1.0 xfun_0.20 purrr_0.3.4
[4] lattice_0.20-41 colorspace_2.0-0 vctrs_0.3.6
[7] generics_0.1.0 htmltools_0.5.0 yaml_2.2.1
[10] rlang_0.4.10 later_1.1.0.1 pillar_1.4.7
[13] withr_2.3.0 glue_1.4.2 plyr_1.8.6
[16] GenomeInfoDbData_1.2.4 lifecycle_0.2.0 stringr_1.4.0
[19] zlibbioc_1.36.0 munsell_0.5.0 gtable_0.3.0
[22] evaluate_0.14 labeling_0.4.2 knitr_1.30
[25] httpuv_1.5.4 Rcpp_1.0.5 promises_1.1.1
[28] scales_1.1.1 DelayedArray_0.16.0 XVector_0.30.0
[31] farver_2.0.3 fs_1.5.0 digest_0.6.27
[34] stringi_1.5.3 rprojroot_2.0.2 grid_4.0.3
[37] tools_4.0.3 bitops_1.0-6 magrittr_2.0.1
[40] RCurl_1.98-1.2 tibble_3.0.4 crayon_1.3.4
[43] whisker_0.4 pkgconfig_2.0.3 ellipsis_0.3.1
[46] Matrix_1.3-2 rmarkdown_2.6 rstudioapi_0.13
[49] R6_2.5.0 git2r_0.28.0 compiler_4.0.3