Last updated: 2024-08-02

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 06f7055. 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:


Untracked files:
    Untracked:  output/DLFPC-All-2-3000-300-0.4.RData
    Untracked:  output/DLFPC-All.RData
    Untracked:  output/DLFPC-Br5292-2-3000-300-0.3.RData
    Untracked:  output/DLFPC-Br5292.RData
    Untracked:  output/DLFPC-Br5595-2-3000-300-0.3.RData
    Untracked:  output/DLFPC-Br5595.RData
    Untracked:  output/DLFPC-Br8100-2-3000-300-0.3.RData
    Untracked:  output/DLFPC-Br8100.RData
    Untracked:  output/VisiumHD.RData

Unstaged changes:
    Deleted:    analysis/DLPFC-12.Rmd
    Deleted:    analysis/DLPFC-4.Rmd
    Deleted:    analysis/STARmap.Rmd
    Deleted:    analysis/figure/DLPFC-12.Rmd/unnamed-chunk-10-1.png

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/Seurat.Rmd) and HTML (docs/Seurat.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
html 82fe167 Stefano Cacciatore 2024-07-24 Build site.
html 6f7daac Stefano Cacciatore 2024-07-19 Build site.
Rmd 3f7aad6 Stefano Cacciatore 2024-07-19 Start my new project
Rmd 210dfdd GitHub 2024-07-16 Update Seurat.Rmd
html 7be8f59 tkcaccia 2024-07-15 updates
Rmd f8ca54a tkcaccia 2024-07-14 update
html f8ca54a tkcaccia 2024-07-14 update
Rmd 89a11c1 GitHub 2024-07-08 Add files via upload
html 2b5aad7 GitHub 2024-07-08 Add files via upload

Seurat is an R toolkit widely used for single-cell genomics and spatial transcriptomics, developed and maintained by the Satija Lab at New York Genome Center. In this section, we will see the steps to integrate KODAMA into the Seurat pipeline.

Loading libraries

First, we need to load the required libraries for this analysis. Make sure you have the following packages installed.

library(Seurat)
library(SeuratData)
library(KODAMA)
library(KODAMAextra)

Dataset

The data used are sagittal sections of the mouse brain generated using Visium v1 technology saved in the Seurat library. For specific details on loading and using the dataset, please take a look at the documentation by typing ?stxBrain in your R environment. Install and load the anterior region of the mouse brain dataset.

#InstallData("stxBrain")
brain <- LoadData("stxBrain", type = "anterior1")

Data processing

We will preprocess the data using Seurat’s SCTransform method and perform PCA:

brain <- SCTransform(brain, assay = "Spatial", verbose = FALSE)
brain <- RunPCA(brain, assay = "SCT", verbose = FALSE)

Run and Visualize KODAMA

Apply KODAMA to reduce dimensionality and visualize the results:

brain <- RunKODAMAmatrix(brain, reduction = "pca")
socket cluster with 1 nodes on host 'localhost'
================================================================================[1] "Finished parallel computation"

[1] "Calculation of dissimilarity matrix..."
================================================================================
brain <- RunKODAMAvisualization(brain, method = "UMAP")

Clustering

Apply clustering on the KODAMA plot.

brain <- FindNeighbors(brain, reduction = "KODAMA", dims = 1:2)
brain <- FindClusters(brain, verbose = FALSE, graph.name="RNA_snn",resolution = 0.2)

Visualize the KODAMA results with DimPlot and SpatialDimPlot:

p1 <- DimPlot(brain, reduction = "KODAMA", label = TRUE)
p2 <- SpatialDimPlot(brain, label = TRUE, label.size = 3)
p1 + p2

Version Author Date
6f7daac Stefano Cacciatore 2024-07-19

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  stats     graphics  grDevices utils     datasets  methods  
[8] 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            stxBrain.SeuratData_0.1.2
[11] SeuratData_0.2.2.9001     Seurat_5.1.0             
[13] SeuratObject_5.0.2        sp_2.1-4                 
[15] workflowr_1.7.1          

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22            splines_4.4.1              
  [3] later_1.3.2                 tibble_3.2.1               
  [5] polyclip_1.10-6             fastDummies_1.7.3          
  [7] lifecycle_1.0.4             rprojroot_2.0.4            
  [9] globals_0.16.3              processx_3.8.4             
 [11] lattice_0.22-6              MASS_7.3-61                
 [13] magrittr_2.0.3              plotly_4.10.4              
 [15] sass_0.4.9                  rmarkdown_2.27             
 [17] jquerylib_0.1.4             yaml_2.3.9                 
 [19] httpuv_1.6.15               glmGamPoi_1.16.0           
 [21] sctransform_0.4.1           spam_2.10-0                
 [23] askpass_1.2.0               spatstat.sparse_3.1-0      
 [25] reticulate_1.38.0           cowplot_1.1.3              
 [27] pbapply_1.7-2               RColorBrewer_1.1-3         
 [29] abind_1.4-5                 zlibbioc_1.50.0            
 [31] GenomicRanges_1.56.1        purrr_1.0.2                
 [33] BiocGenerics_0.50.0         rappdirs_0.3.3             
 [35] git2r_0.33.0                GenomeInfoDbData_1.2.12    
 [37] IRanges_2.38.1              S4Vectors_0.42.1           
 [39] ggrepel_0.9.5               irlba_2.3.5.1              
 [41] listenv_0.9.1               spatstat.utils_3.0-5       
 [43] goftest_1.2-3               RSpectra_0.16-1            
 [45] spatstat.random_3.3-1       fitdistrplus_1.2-1         
 [47] parallelly_1.37.1           DelayedMatrixStats_1.26.0  
 [49] leiden_0.4.3.1              codetools_0.2-20           
 [51] DelayedArray_0.30.1         tidyselect_1.2.1           
 [53] farver_2.1.2                UCSC.utils_1.0.0           
 [55] matrixStats_1.3.0           stats4_4.4.1               
 [57] spatstat.explore_3.3-1      jsonlite_1.8.8             
 [59] progressr_0.14.0            ggridges_0.5.6             
 [61] survival_3.7-0              tools_4.4.1                
 [63] snow_0.4-4                  ica_1.0-3                  
 [65] Rcpp_1.0.12                 glue_1.7.0                 
 [67] gridExtra_2.3               SparseArray_1.4.8          
 [69] xfun_0.45                   MatrixGenerics_1.16.0      
 [71] GenomeInfoDb_1.40.1         dplyr_1.1.4                
 [73] withr_3.0.0                 fastmap_1.2.0              
 [75] fansi_1.0.6                 openssl_2.2.0              
 [77] callr_3.7.6                 digest_0.6.36              
 [79] R6_2.5.1                    mime_0.12                  
 [81] colorspace_2.1-0            scattermore_1.2            
 [83] tensor_1.5                  spatstat.data_3.1-2        
 [85] utf8_1.2.4                  tidyr_1.3.1                
 [87] generics_0.1.3              data.table_1.15.4          
 [89] class_7.3-22                httr_1.4.7                 
 [91] htmlwidgets_1.6.4           S4Arrays_1.4.1             
 [93] whisker_0.4.1               uwot_0.2.2                 
 [95] pkgconfig_2.0.3             gtable_0.3.5               
 [97] lmtest_0.9-40               XVector_0.44.0             
 [99] htmltools_0.5.8.1           dotCall64_1.1-1            
[101] scales_1.3.0                Biobase_2.64.0             
[103] png_0.1-8                   doSNOW_1.0.20              
[105] spatstat.univar_3.0-0       knitr_1.48                 
[107] rstudioapi_0.16.0           reshape2_1.4.4             
[109] nlme_3.1-165                proxy_0.4-27               
[111] cachem_1.1.0                zoo_1.8-12                 
[113] stringr_1.5.1               KernSmooth_2.23-24         
[115] miniUI_0.1.1.1              pillar_1.9.0               
[117] grid_4.4.1                  vctrs_0.6.5                
[119] RANN_2.6.1                  promises_1.3.0             
[121] xtable_1.8-4                cluster_2.1.6              
[123] evaluate_0.24.0             cli_3.6.3                  
[125] compiler_4.4.1              rlang_1.1.4                
[127] crayon_1.5.3                future.apply_1.11.2        
[129] labeling_0.4.3              ps_1.7.7                   
[131] getPass_0.2-4               plyr_1.8.9                 
[133] fs_1.6.4                    stringi_1.8.4              
[135] viridisLite_0.4.2           deldir_2.0-4               
[137] munsell_0.5.1               lazyeval_0.2.2             
[139] spatstat.geom_3.3-2         Matrix_1.7-0               
[141] RcppHNSW_0.6.0              patchwork_1.2.0            
[143] sparseMatrixStats_1.16.0    future_1.33.2              
[145] ggplot2_3.5.1               shiny_1.8.1.1              
[147] highr_0.11                  SummarizedExperiment_1.34.0
[149] ROCR_1.0-11                 igraph_2.0.3               
[151] bslib_0.7.0