Last updated: 2025-10-02
Checks: 7 0
Knit directory:
2025_cytoconnect_spatial_workshop/
This reproducible R Markdown analysis was created with workflowr (version 1.7.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(20251002) 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 383f3f1. 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
Untracked files:
Untracked: data/sc_seurat_object_10x.qs
Untracked: data/visium/
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/setup.Rmd) and HTML
(docs/setup.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 | 383f3f1 | Givanna Putri | 2025-10-02 | First publish for website |
Please ensure you follow the instructions below prior to attending the workshop.
You can either create a new R script and copy paste the content of the code blocks or download this Rmd file and run each code block step by step.
Do not just blindly run the code! Make sure you read the description above each of the code block to understand what the code is doing before running them! Sourcing the entire Rmd file will not run anything as every code block has been deliberately annotated such that they won’t execute when the whole file is sourced.
If you have any problems, please reach out to either:
Please install the packages that we will be using in the workshop by running the code block below.
cran_packages <- c(
"BiocManager", "Seurat", "ggplot2", "scales", "patchwork", "qs2",
"viridis", "pak", "here", "hdf5r", "Rfast2"
)
install.packages(cran_packages)
# RCTD only available on Github
pak::pkg_install("dmcable/spacexr")
bioc_packages <- c()
if(length(bioc_packages) > 0) {BiocManager::install(bioc_packages)}
Running this chunk will let you know if the packages have been installed properly.
checkSetup <- function() {
library(cli)
cat("\n--------------------------------------\n")
cat(style_bold(col_magenta("\n***Installing General Packages***\n\n")))
not <- c(); not2 <- c()
packages1 <- c(cran_packages, bioc_packages)#, "Test")
for (i in 1:length(packages1)){
if(requireNamespace(packages1[i], quietly = TRUE)==F) {
cat(paste(style_bold(col_red(packages1[i])), "has not been installed\n"))
not <- c(not,i)
} else {
suppressWarnings(suppressMessages(library(as.character(packages1[i]), character.only = TRUE)))
cat(col_yellow(packages1[i]), "is loaded!\n")
}
}
cat("\n--------------------------------------\n")
if (length(not) > 0){
cat(style_bold(bg_red("\n **IMPORTANT** ")),
style_bold(col_yellow("\n\nYou need to install: \n")),
paste(paste(c(packages1[not]), collapse=", ")),
"\n\n--------------------------------------",
"\n\n Use:\n - install.packages(),\n - BiocManager::install() or, \n - use Google to find installation instructions.\n\n", style_bold(col_green("Then run this function again!\n\n")))
} else {
cat("",col_green(style_bold("\n All packages are loaded!\n\n Happy Coding! :)\n\n")))
}
}
checkSetup()
The code block below will create a bunch of folders in the location where this script is stored.
# This sets the working directory for all subsequent code chunks to be run
# to the location of this file.
raw_data_dir <- file.path(here::here(), "data", "visium", "raw")
data_dir <- file.path(here::here(), "data", "visium", "data")
if(!dir.exists(raw_data_dir)){dir.create(raw_data_dir, recursive = TRUE)}
if(!dir.exists(data_dir)){dir.create(data_dir, recursive = TRUE)}
Please source the code block below to load a function to check the integrity of the downloaded files.
check_md5 <- function(files_expected_md5sum) {
# files_expected_md5sum must be a named vector where the name is the path to the file
# and the value is the expected md5sum
library(cli)
library(tools)
error <- combine_ansi_styles("red", "bold")
need_redownload <- FALSE
for (filename in names(files_expected_md5sum)) {
actual_md5sum <- md5sum(filename)
expected_md5sum <- files_expected_md5sum[filename]
if (actual_md5sum != expected_md5sum) {
cat(error(paste(
filename, "is corrupted. Actual md5sum:", actual_md5sum, "!= Expected md5sum:", expected_md5sum, "\n"
)
))
need_redownload <- TRUE
}
}
if (need_redownload) {
cat(error("Some files are corrupted. Please redownload"))
}
}
Note: if you encounter a timeout error
(after 60 seconds) while downloading the files, you can increase the
timeout to say 6,000 seconds to give R more time to download the files
by running
options(timeout = max(6000, getOption("timeout")))
The code block below will download the count matrix and spatial information required to load the Visium data in.
download.file("https://cf.10xgenomics.com/samples/spatial-exp/3.0.0/Visium_V2_Human_Colon_Cancer_P2/Visium_V2_Human_Colon_Cancer_P2_filtered_feature_bc_matrix.h5",
destfile = file.path(raw_data_dir, "Visium_V2_Human_Colon_Cancer_P2_filtered_feature_bc_matrix.h5"),
method = "curl")
download.file("https://cf.10xgenomics.com/samples/spatial-exp/3.0.0/Visium_V2_Human_Colon_Cancer_P2/Visium_V2_Human_Colon_Cancer_P2_spatial.tar.gz",
destfile = file.path(raw_data_dir, "spatial.tar.gz"),
method = "curl")
The code below will check the integrity of the downloaded files. If you get any red warning, please re-download the files that were found to be corrupted using the code block above.
# check md5sum of the downloaded files.
md5sum_str <- c(
"0a9733cf0dfd3dfaa3b6c1c5c24bcbed",
"a32edc825ab7089fca7848fc80cd5113"
)
names(md5sum_str) <- c(
file.path(raw_data_dir, "Visium_V2_Human_Colon_Cancer_P2_filtered_feature_bc_matrix.h5"),
file.path(raw_data_dir, "spatial.tar.gz")
)
check_md5(md5sum_str)
If there are no warning from the code block above, proceed to untar
the spatial.tar.gz file using the code block below.
untar(file.path(raw_data_dir, "spatial.tar.gz"), exdir = raw_data_dir)
TODO. Need to upload the qs2 file somewhere they can download.
The following file is optional and is only required if you would like to try out the demo we will be showing on how to use loupe browser to make some QC step simpler.
download.file(
"https://cf.10xgenomics.com/samples/spatial-exp/3.0.0/Visium_V2_Human_Colon_Cancer_P2/Visium_V2_Human_Colon_Cancer_P2_cloupe.cloupe",
destfile = file.path(raw_data_dir, "Visium_V2_Human_Colon_Cancer_P2_cloupe.cloupe"),
method = "curl"
)
md5sum_str <- c("c5726e203c21a2fc3432831ea7c74252")
names(md5sum_str) <- c(
file.path(raw_data_dir, "Visium_V2_Human_Colon_Cancer_P2_cloupe.cloupe")
)
check_md5(md5sum_str)
Install Loupe Browser at this link: https://www.10xgenomics.com/support/software/loupe-browser/latest
sessionInfo()
R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.5
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Australia/Melbourne
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] workflowr_1.7.2
loaded via a namespace (and not attached):
[1] vctrs_0.6.5 httr_1.4.7 cli_3.6.5 knitr_1.50
[5] rlang_1.1.6 xfun_0.53 stringi_1.8.7 processx_3.8.6
[9] promises_1.3.3 jsonlite_2.0.0 glue_1.8.0 rprojroot_2.1.1
[13] git2r_0.36.2 htmltools_0.5.8.1 httpuv_1.6.16 ps_1.9.1
[17] sass_0.4.10 rmarkdown_2.29 jquerylib_0.1.4 tibble_3.3.0
[21] evaluate_1.0.5 fastmap_1.2.0 yaml_2.3.10 lifecycle_1.0.4
[25] whisker_0.4.1 stringr_1.5.2 compiler_4.5.1 fs_1.6.6
[29] pkgconfig_2.0.3 Rcpp_1.1.0 rstudioapi_0.17.1 later_1.4.4
[33] digest_0.6.37 R6_2.6.1 pillar_1.11.0 callr_3.7.6
[37] magrittr_2.0.4 bslib_0.9.0 tools_4.5.1 cachem_1.1.0
[41] getPass_0.2-4
sessionInfo()
R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.5
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Australia/Melbourne
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] workflowr_1.7.2
loaded via a namespace (and not attached):
[1] vctrs_0.6.5 httr_1.4.7 cli_3.6.5 knitr_1.50
[5] rlang_1.1.6 xfun_0.53 stringi_1.8.7 processx_3.8.6
[9] promises_1.3.3 jsonlite_2.0.0 glue_1.8.0 rprojroot_2.1.1
[13] git2r_0.36.2 htmltools_0.5.8.1 httpuv_1.6.16 ps_1.9.1
[17] sass_0.4.10 rmarkdown_2.29 jquerylib_0.1.4 tibble_3.3.0
[21] evaluate_1.0.5 fastmap_1.2.0 yaml_2.3.10 lifecycle_1.0.4
[25] whisker_0.4.1 stringr_1.5.2 compiler_4.5.1 fs_1.6.6
[29] pkgconfig_2.0.3 Rcpp_1.1.0 rstudioapi_0.17.1 later_1.4.4
[33] digest_0.6.37 R6_2.6.1 pillar_1.11.0 callr_3.7.6
[37] magrittr_2.0.4 bslib_0.9.0 tools_4.5.1 cachem_1.1.0
[41] getPass_0.2-4