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/08_RNA_neighbourhood_analysis_chemokines.rmd
) and HTML (docs/08_RNA_neighbourhood_analysis_chemokines.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 | 73caa28 | toobiwankenobi | 2021-01-12 | minor corrections |
Rmd | 9442cb9 | toobiwankenobi | 2020-12-22 | add all new files |
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(ComplexHeatmap)
library(SingleCellExperiment)
library(ggplot2)
library(ggrepel)
library(dplyr)
library(data.table)
library(sf)
library(stringr)
library(RANN)
sce = readRDS(file = "data/sce_RNA.rds")
start = Sys.time()
cur_sce <- data.frame(colData(sce))
# loop through all chemokines
for(i in names(cur_sce[,grepl(glob2rx("C*L*"),names(cur_sce))])) {
# find clusters
sce <- findClusters(input_sce = sce,
IDs_of_interest = cur_sce[cur_sce[,names(cur_sce) == i] == 1,]$cellID,
'cellID',
'Center_X', 'Center_Y',
'ImageNumber',
distance = 25,
min_clust_size = 1,
output_colname = paste(tolower(i), "only_clust", sep = ""))
# define cells within/surrounding a cluster of chemokine producing cells
sce <- findCommunity(sce,
'cellID',
'Center_X',
'Center_Y',
'ImageNumber',
paste(tolower(i), "only_clust", sep = ""),
distance = 30,
output_colname = paste(tolower(i), "only_comm", sep = ""))
}
Time difference of 5.187181 secs
[1] "clusters successfully added to sce object"
Time difference of 14.9232 mins
[1] "communities successfully added to sce object"
Time difference of 4.491169 secs
[1] "clusters successfully added to sce object"
Time difference of 11.12614 mins
[1] "communities successfully added to sce object"
Time difference of 3.870585 secs
[1] "clusters successfully added to sce object"
Time difference of 10.66591 mins
[1] "communities successfully added to sce object"
Time difference of 16.96013 secs
[1] "clusters successfully added to sce object"
Time difference of 17.63512 mins
[1] "communities successfully added to sce object"
Time difference of 8.995049 secs
[1] "clusters successfully added to sce object"
Time difference of 18.19218 mins
[1] "communities successfully added to sce object"
Time difference of 11.43751 secs
[1] "clusters successfully added to sce object"
Time difference of 16.65584 mins
[1] "communities successfully added to sce object"
Time difference of 11.95486 secs
[1] "clusters successfully added to sce object"
Time difference of 23.00895 mins
[1] "communities successfully added to sce object"
Time difference of 1.511748 secs
[1] "clusters successfully added to sce object"
Time difference of 5.187876 mins
[1] "communities successfully added to sce object"
Time difference of 16.11653 secs
[1] "clusters successfully added to sce object"
Time difference of 14.75231 mins
[1] "communities successfully added to sce object"
Time difference of 0.7634459 secs
[1] "clusters successfully added to sce object"
Time difference of 2.904923 mins
[1] "communities successfully added to sce object"
Time difference of 8.040153 secs
[1] "clusters successfully added to sce object"
Time difference of 10.47013 mins
[1] "communities successfully added to sce object"
end = Sys.time()
print(end-start)
Time difference of 2.45044 hours
cur_sce <- data.frame(colData(sce))
clust_sum <- data.frame()
for(i in names(cur_sce[,grepl(glob2rx("*only_clust"),names(cur_sce))])) {
# select cluster with more than 10 producing cells
clust <- cur_sce %>%
group_by_at(i) %>%
summarise(n=n()) %>%
distinct_at(i, .keep_all = TRUE) %>%
filter(n>10)
# remove cluster 0
clust <- clust[clust[,i] > 0,]
# create new column
name <- str_split(i, "_")[[1]][1]
name <- paste0(name,"_pure")
cur_sce[,name] <- 0
# add cluster id to new column for all cells (producing AND non-producing) that are part of that community
if(nrow(clust) > 0){
colname_comm <- paste0(str_split(i, "_")[[1]][1],"_comm")
cur_sce[cur_sce[,colname_comm] %in% clust[,i][[1]], name] <- as.numeric(cur_sce[cur_sce[,colname_comm] %in% clust[,i][[1]], colname_comm])
}
}
Warning: The `i` argument of ``[`()` can't be a matrix as of tibble 3.0.0.
Convert to a vector.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
# add to sce
sce$ccl4_pure <- cur_sce$ccl4only_pure
sce$ccl18_pure <- cur_sce$ccl18only_pure
sce$cxcl8_pure <- cur_sce$cxcl8only_pure
sce$cxcl10_pure <- cur_sce$cxcl10only_pure
sce$cxcl12_pure <- cur_sce$cxcl12only_pure
sce$cxcl13_pure <- cur_sce$cxcl13only_pure
sce$ccl2_pure <- cur_sce$ccl2only_pure
sce$ccl22_pure <- cur_sce$ccl22only_pure
sce$cxcl9_pure <- cur_sce$cxcl9only_pure
sce$ccl8_pure <- cur_sce$ccl8only_pure
sce$ccl19_pure <- cur_sce$ccl19only_pure
saveRDS(sce, 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 grid stats graphics grDevices utils
[8] datasets methods base
other attached packages:
[1] RANN_2.6.1 stringr_1.4.0
[3] sf_0.9-7 data.table_1.13.6
[5] dplyr_1.0.2 ggrepel_0.9.0
[7] ggplot2_3.3.3 SingleCellExperiment_1.12.0
[9] SummarizedExperiment_1.20.0 Biobase_2.50.0
[11] GenomicRanges_1.42.0 GenomeInfoDb_1.26.2
[13] IRanges_2.24.1 S4Vectors_0.28.1
[15] BiocGenerics_0.36.0 MatrixGenerics_1.2.0
[17] matrixStats_0.57.0 ComplexHeatmap_2.4.3
[19] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] jsonlite_1.7.2 GenomeInfoDbData_1.2.4 yaml_2.2.1
[4] pillar_1.4.7 lattice_0.20-41 glue_1.4.2
[7] digest_0.6.27 RColorBrewer_1.1-2 promises_1.1.1
[10] XVector_0.30.0 colorspace_2.0-0 htmltools_0.5.0
[13] httpuv_1.5.4 Matrix_1.3-2 pkgconfig_2.0.3
[16] GetoptLong_1.0.5 zlibbioc_1.36.0 purrr_0.3.4
[19] scales_1.1.1 whisker_0.4 later_1.1.0.1
[22] git2r_0.28.0 tibble_3.0.4 generics_0.1.0
[25] ellipsis_0.3.1 withr_2.3.0 magrittr_2.0.1
[28] crayon_1.3.4 evaluate_0.14 fs_1.5.0
[31] class_7.3-17 tools_4.0.3 GlobalOptions_0.1.2
[34] lifecycle_0.2.0 V8_3.4.0 munsell_0.5.0
[37] cluster_2.1.0 DelayedArray_0.16.0 compiler_4.0.3
[40] e1071_1.7-4 concaveman_1.1.0 rlang_0.4.10
[43] classInt_0.4-3 units_0.6-7 RCurl_1.98-1.2
[46] rstudioapi_0.13 rjson_0.2.20 circlize_0.4.12
[49] bitops_1.0-6 rmarkdown_2.6 gtable_0.3.0
[52] curl_4.3 DBI_1.1.0 R6_2.5.0
[55] knitr_1.30 clue_0.3-58 rprojroot_2.0.2
[58] KernSmooth_2.23-18 shape_1.4.5 stringi_1.5.3
[61] Rcpp_1.0.5 vctrs_0.3.6 png_0.1-7
[64] tidyselect_1.1.0 xfun_0.20