Last updated: 2024-07-19
Checks: 7 0
Knit directory: KODAMA-Analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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(20240618)
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 3f7aad6. 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:
Unstaged changes:
Deleted: analysis/figure/DLPFC-12.Rmd/unnamed-chunk-10-1.png
Modified: analysis/index.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/SpatialExperiment.Rmd
) and
HTML (docs/SpatialExperiment.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 | 3f7aad6 | Stefano Cacciatore | 2024-07-19 | Start my new project |
Rmd | 0e75f7b | GitHub | 2024-07-16 | Create SpatialExperiment.Rmd |
Spatial Transcriptomics has revolutionized the study of tissue architecture by integrating spatial information with transcriptomic data. This tutorial demonstrates how to perform spatial data analysis and visualize the results. We will use a dataset from the mouse olfactory bulb (OB), acquired via the Spatial Transcriptomics platform (Stahl et al. 2016) link to the article. This dataset includes annotations for five cellular layers as provided by the original authors.
Spatial Transcriptomics enables researchers to explore the spatial organization of gene expression within tissues, offering insights into cellular interactions and tissue microenvironments. By combining spatial coordinates with gene expression profiles, analyses such as Principal Component Analysis (PCA) and visualization techniques like KODAMA provide powerful tools to uncover spatial patterns and relationships in biological data. # Tutorial Steps
library(SpatialExperiment)
library(STexampleData)
library(scran)
library(scater)
library(KODAMA)
library(KODAMAextra)
# Loading spatial data from the mouse olfactory bulb
spe = ST_mouseOB()
# Extracting cell metadata
metaData = SingleCellExperiment::colData(spe)
# Calculating library factors
spe <- computeLibraryFactors(spe)
# Summarizing size factors
summary(sizeFactors(spe))
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0001259 0.6490732 0.9197538 1.0000000 1.3239172 2.3464869
spe <- logNormCounts(spe)
# Selecting highly variable genes
top_hvgs <- getTopHVGs(spe, prop = 0.1)
# Performing PCA
spe <- runPCA(spe, 50, subset_row = top_hvgs, scale = TRUE)
# Defining colors for PCA plot based on "layer" metadata
colors = c("#11111199", "#111ee199", "#aa111199", "#1111cc99", "#11cccc99")
plot(reducedDim(spe, type = "PCA"), bg = colors[as.factor(metaData[,"layer"])], pch = 21, cex = 2)
# Running KODAMA on the reduced PCA matrix
spe = RunKODAMAmatrix(spe, reduction = "PCA")
socket cluster with 1 nodes on host 'localhost'
================================================================================[1] "Finished parallel computation"
[1] "Calculation of dissimilarity matrix..."
================================================================================
# Visualizing KODAMA using UMAP method
spe = RunKODAMAvisualization(spe, method = "UMAP")
# Retrieving spatial coordinates
xy = spatialCoords(spe)
# Plotting reduced data with KODAMA, based on "layer" metadata
plot(reducedDim(spe, type = "KODAMA"), bg = colors[as.factor(metaData[,"layer"])], pch = 21, cex = 2)
# Plotting spatial coordinates, based on "layer" metadata
plot(xy, bg = colors[as.factor(metaData[,"layer"])], pch = 21, cex = 2)
sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.6 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
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=en_US.UTF-8
[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
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] KODAMAextra_1.0 e1071_1.7-14
[3] doParallel_1.0.17 iterators_1.0.14
[5] foreach_1.5.2 KODAMA_3.1
[7] umap_0.2.10.0 Rtsne_0.17
[9] minerva_1.5.10 scater_1.32.0
[11] ggplot2_3.5.1 scran_1.32.0
[13] scuttle_1.14.0 STexampleData_1.12.3
[15] ExperimentHub_2.12.0 AnnotationHub_3.12.0
[17] BiocFileCache_2.12.0 dbplyr_2.5.0
[19] SpatialExperiment_1.14.0 SingleCellExperiment_1.26.0
[21] SummarizedExperiment_1.34.0 Biobase_2.64.0
[23] GenomicRanges_1.56.1 GenomeInfoDb_1.40.1
[25] IRanges_2.38.1 S4Vectors_0.42.1
[27] BiocGenerics_0.50.0 MatrixGenerics_1.16.0
[29] matrixStats_1.3.0 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] rstudioapi_0.16.0 jsonlite_1.8.8
[3] magrittr_2.0.3 ggbeeswarm_0.7.2
[5] magick_2.8.4 rmarkdown_2.27
[7] fs_1.6.4 zlibbioc_1.50.0
[9] vctrs_0.6.5 memoise_2.0.1
[11] DelayedMatrixStats_1.26.0 askpass_1.2.0
[13] htmltools_0.5.8.1 S4Arrays_1.4.1
[15] curl_5.2.1 BiocNeighbors_1.22.0
[17] SparseArray_1.4.8 sass_0.4.9
[19] bslib_0.7.0 cachem_1.1.0
[21] whisker_0.4.1 igraph_2.0.3
[23] mime_0.12 lifecycle_1.0.4
[25] pkgconfig_2.0.3 rsvd_1.0.5
[27] Matrix_1.7-0 R6_2.5.1
[29] fastmap_1.2.0 GenomeInfoDbData_1.2.12
[31] digest_0.6.36 colorspace_2.1-0
[33] AnnotationDbi_1.66.0 ps_1.7.7
[35] rprojroot_2.0.4 RSpectra_0.16-1
[37] dqrng_0.4.1 irlba_2.3.5.1
[39] RSQLite_2.3.7 beachmat_2.20.0
[41] filelock_1.0.3 fansi_1.0.6
[43] httr_1.4.7 abind_1.4-5
[45] compiler_4.4.1 proxy_0.4-27
[47] bit64_4.0.5 withr_3.0.0
[49] BiocParallel_1.38.0 viridis_0.6.5
[51] DBI_1.2.3 highr_0.11
[53] openssl_2.2.0 rappdirs_0.3.3
[55] DelayedArray_0.30.1 rjson_0.2.21
[57] bluster_1.14.0 tools_4.4.1
[59] vipor_0.4.7 beeswarm_0.4.0
[61] httpuv_1.6.15 glue_1.7.0
[63] callr_3.7.6 promises_1.3.0
[65] grid_4.4.1 getPass_0.2-4
[67] cluster_2.1.6 snow_0.4-4
[69] generics_0.1.3 gtable_0.3.5
[71] class_7.3-22 BiocSingular_1.20.0
[73] ScaledMatrix_1.12.0 metapod_1.12.0
[75] utf8_1.2.4 XVector_0.44.0
[77] ggrepel_0.9.5 BiocVersion_3.19.1
[79] pillar_1.9.0 stringr_1.5.1
[81] limma_3.60.3 later_1.3.2
[83] dplyr_1.1.4 lattice_0.22-6
[85] bit_4.0.5 tidyselect_1.2.1
[87] locfit_1.5-9.10 Biostrings_2.72.1
[89] knitr_1.48 git2r_0.33.0
[91] gridExtra_2.3 edgeR_4.2.1
[93] xfun_0.45 statmod_1.5.0
[95] stringi_1.8.4 UCSC.utils_1.0.0
[97] yaml_2.3.9 evaluate_0.24.0
[99] codetools_0.2-20 tibble_3.2.1
[101] BiocManager_1.30.23 cli_3.6.3
[103] reticulate_1.38.0 munsell_0.5.1
[105] processx_3.8.4 jquerylib_0.1.4
[107] Rcpp_1.0.12 doSNOW_1.0.20
[109] png_0.1-8 blob_1.2.4
[111] sparseMatrixStats_1.16.0 viridisLite_0.4.2
[113] scales_1.3.0 purrr_1.0.2
[115] crayon_1.5.3 rlang_1.1.4
[117] KEGGREST_1.44.1