Welcome to the SRTsim
project! It is composed of:
The web application allows you to design spatial pattern and generate SRT data with patterns of interest.
SRTsim
R
is an open-source statistical environment which can be
easily modified to enhance its functionality via packages. SRTsim is a
R
package available via CRAN. R
can be
installed on any operating system from CRAN after which you can install
SRTsim
by using the following commands in your R
session:
To get started, please load the SRTsim package.
Once you have installed the package, we can perform reference-based Tissue-wise simulation with the example data.
## explore example SRT data
str(exampleLIBD)
#> List of 2
#> $ count:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
#> .. ..@ i : int [1:241030] 1 2 8 9 10 11 13 14 15 16 ...
#> .. ..@ p : int [1:3612] 0 67 122 182 252 322 392 462 534 609 ...
#> .. ..@ Dim : int [1:2] 80 3611
#> .. ..@ Dimnames:List of 2
#> .. .. ..$ : chr [1:80] "ENSG00000175130" "ENSG00000159176" "ENSG00000168314" "ENSG00000080822" ...
#> .. .. ..$ : chr [1:3611] "AAACAAGTATCTCCCA-1" "AAACAATCTACTAGCA-1" "AAACACCAATAACTGC-1" "AAACAGAGCGACTCCT-1" ...
#> .. ..@ x : num [1:241030] 1 1 1 7 10 1 5 2 1 1 ...
#> .. ..@ factors : list()
#> $ info :'data.frame': 3611 obs. of 6 variables:
#> ..$ row : int [1:3611] 50 3 59 14 43 47 73 61 45 42 ...
#> ..$ col : int [1:3611] 102 43 19 94 9 13 43 97 115 28 ...
#> ..$ imagerow: num [1:3611] 381 126 428 187 341 ...
#> ..$ imagecol: num [1:3611] 441 260 183 417 153 ...
#> ..$ tissue : Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2 2 ...
#> ..$ layer : chr [1:3611] "Layer3" "Layer1" "WM" "Layer3" ...
example_count <- exampleLIBD$count
example_loc <- exampleLIBD$info[,c("imagecol","imagerow","layer")]
colnames(example_loc) <- c("x","y","label")
## create a SRT object
simSRT <- createSRT(count_in=example_count,loc_in =example_loc)
## Set a seed for reproducible simulation
set.seed(1)
## Estimate model parameters for data generation
simSRT1 <- srtsim_fit(simSRT,sim_schem="tissue")
## Generate synthetic data with estimated parameters
simSRT1 <- srtsim_count(simSRT1)
## Explore the synthetic data
simCounts(simSRT1)[1:5,1:5]
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#> AAACAAGTATCTCCCA-1 AAACAATCTACTAGCA-1 AAACACCAATAACTGC-1
#> ENSG00000175130 . . 10
#> ENSG00000159176 1 3 5
#> ENSG00000168314 1 . 6
#> ENSG00000080822 . . 3
#> ENSG00000091513 . . 5
#> AAACAGAGCGACTCCT-1 AAACAGCTTTCAGAAG-1
#> ENSG00000175130 . 2
#> ENSG00000159176 . 1
#> ENSG00000168314 2 1
#> ENSG00000080822 1 .
#> ENSG00000091513 1 3
simcolData(simSRT1)
#> DataFrame with 3611 rows and 3 columns
#> x y label
#> <numeric> <numeric> <character>
#> AAACAAGTATCTCCCA-1 440.639 381.098 Layer3
#> AAACAATCTACTAGCA-1 259.631 126.328 Layer1
#> AAACACCAATAACTGC-1 183.078 427.768 WM
#> AAACAGAGCGACTCCT-1 417.237 186.814 Layer3
#> AAACAGCTTTCAGAAG-1 152.700 341.269 Layer5
#> ... ... ... ...
#> TTGTTTCACATCCAGG-1 254.410 422.862 WM
#> TTGTTTCATTAGTCTA-1 217.147 433.393 WM
#> TTGTTTCCATACAACT-1 208.416 352.430 Layer6
#> TTGTTTGTATTACACG-1 250.720 503.735 WM
#> TTGTTTGTGTAAATTC-1 284.293 148.110 Layer2
We can perform reference-based Domain-specific simulation with the example data.
## Set a seed for reproducible simulation
set.seed(1)
## Estimate model parameters for data generation
simSRT2 <- srtsim_fit(simSRT,sim_scheme='domain')
## Generate synthetic data with estimated parameters
simSRT2 <- srtsim_count(simSRT2)
## Explore the synthetic data
simCounts(simSRT2)[1:5,1:5]
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#> AAACAAGTATCTCCCA-1 AAACAATCTACTAGCA-1 AAACACCAATAACTGC-1
#> ENSG00000175130 . . 11
#> ENSG00000159176 1 2 7
#> ENSG00000168314 1 . 7
#> ENSG00000080822 . . 3
#> ENSG00000091513 . . 6
#> AAACAGAGCGACTCCT-1 AAACAGCTTTCAGAAG-1
#> ENSG00000175130 . 2
#> ENSG00000159176 . 1
#> ENSG00000168314 2 1
#> ENSG00000080822 1 .
#> ENSG00000091513 2 3
After data generation, we can compare metrics of reference data and synthetic data
The SRTsim package was made possible thanks to:
Code for creating the vignette
## Create the vignette
library("rmarkdown")
system.time(render("SRTsim.Rmd"))
## Extract the R code
library("knitr")
knit("SRTsim.Rmd", tangle = TRUE)
Date the vignette was generated.
#> [1] "2024-11-20 06:38:48 UTC"
Wallclock time spent generating the vignette.
#> Time difference of 13.598 secs
R
session information.
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.4.2 (2024-10-31)
#> os Ubuntu 24.04.1 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate C
#> ctype en_US.UTF-8
#> tz Etc/UTC
#> date 2024-11-20
#> pandoc 3.2.1 @ /usr/local/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> abind 1.4-8 2024-09-12 [2] RSPM (R 4.4.0)
#> backports 1.5.0 2024-05-23 [2] RSPM (R 4.4.0)
#> base64enc 0.1-3 2015-07-28 [2] RSPM (R 4.4.0)
#> bezier 1.1.2 2018-12-14 [2] RSPM (R 4.4.0)
#> bibtex 0.5.1 2023-01-26 [2] RSPM (R 4.4.0)
#> BiocGenerics 0.53.3 2024-11-15 [2] https://bioc.r-universe.dev (R 4.4.2)
#> BiocManager 1.30.25 2024-08-28 [2] RSPM (R 4.4.0)
#> BiocStyle * 2.35.0 2024-11-19 [2] https://bioc.r-universe.dev (R 4.4.2)
#> broom 1.0.7 2024-09-26 [2] RSPM (R 4.4.0)
#> bslib 0.8.0 2024-07-29 [2] RSPM (R 4.4.0)
#> buildtools 1.0.0 2024-11-19 [3] local (/pkg)
#> cachem 1.1.0 2024-05-16 [2] RSPM (R 4.4.0)
#> car 3.1-3 2024-09-27 [2] RSPM (R 4.4.0)
#> carData 3.0-5 2022-01-06 [2] RSPM (R 4.4.0)
#> class 7.3-22 2023-05-03 [2] RSPM (R 4.4.0)
#> classInt 0.4-10 2023-09-05 [2] RSPM (R 4.4.0)
#> cli 3.6.3 2024-06-21 [2] RSPM (R 4.4.0)
#> codetools 0.2-20 2024-03-31 [2] RSPM (R 4.4.0)
#> colorRamps 2.3.4 2024-03-07 [2] RSPM (R 4.4.0)
#> colorspace 2.1-1 2024-07-26 [2] RSPM (R 4.4.0)
#> concaveman 1.1.0 2020-05-11 [2] RSPM (R 4.4.0)
#> cowplot 1.1.3 2024-01-22 [2] RSPM (R 4.4.0)
#> dashboardthemes 1.1.6 2022-07-13 [2] RSPM (R 4.4.0)
#> data.table 1.16.2 2024-10-10 [2] RSPM (R 4.4.0)
#> DBI 1.2.3 2024-06-02 [2] RSPM (R 4.4.0)
#> deldir 2.0-4 2024-02-28 [2] RSPM (R 4.4.0)
#> digest 0.6.37 2024-08-19 [2] RSPM (R 4.4.0)
#> doParallel 1.0.17 2022-02-07 [2] RSPM (R 4.4.0)
#> dplyr 1.1.4 2023-11-17 [2] RSPM (R 4.4.0)
#> DT 0.33 2024-04-04 [2] RSPM (R 4.4.0)
#> e1071 1.7-16 2024-09-16 [2] RSPM (R 4.4.0)
#> evaluate 1.0.1 2024-10-10 [2] RSPM (R 4.4.0)
#> fansi 1.0.6 2023-12-08 [2] RSPM (R 4.4.0)
#> farver 2.1.2 2024-05-13 [2] RSPM (R 4.4.0)
#> fastmap 1.2.0 2024-05-15 [2] RSPM (R 4.4.0)
#> FNN 1.1.4.1 2024-09-22 [2] RSPM (R 4.4.0)
#> foreach 1.5.2 2022-02-02 [2] RSPM (R 4.4.0)
#> Formula 1.2-5 2023-02-24 [2] RSPM (R 4.4.0)
#> generics 0.1.3 2022-07-05 [2] RSPM (R 4.4.0)
#> ggplot2 3.5.1 2024-04-23 [2] RSPM (R 4.4.0)
#> ggpubr 0.6.0 2023-02-10 [2] RSPM (R 4.4.0)
#> ggsignif 0.6.4 2022-10-13 [2] RSPM (R 4.4.0)
#> glue 1.8.0 2024-09-30 [2] RSPM (R 4.4.0)
#> gridExtra 2.3 2017-09-09 [2] RSPM (R 4.4.0)
#> gtable 0.3.6 2024-10-25 [2] RSPM (R 4.4.0)
#> htmltools 0.5.8.1 2024-04-04 [2] RSPM (R 4.4.0)
#> htmlwidgets 1.6.4 2023-12-06 [2] RSPM (R 4.4.0)
#> httpuv 1.6.15 2024-03-26 [2] RSPM (R 4.4.0)
#> httr 1.4.7 2023-08-15 [2] RSPM (R 4.4.0)
#> iterators 1.0.14 2022-02-05 [2] RSPM (R 4.4.0)
#> jquerylib 0.1.4 2021-04-26 [2] RSPM (R 4.4.0)
#> jsonlite 1.8.9 2024-09-20 [2] RSPM (R 4.4.0)
#> KernSmooth 2.23-24 2024-05-17 [2] RSPM (R 4.4.0)
#> knitr 1.49 2024-11-08 [2] RSPM (R 4.4.0)
#> labeling 0.4.3 2023-08-29 [2] RSPM (R 4.4.0)
#> later 1.3.2 2023-12-06 [2] RSPM (R 4.4.0)
#> lattice 0.22-6 2024-03-20 [2] RSPM (R 4.4.0)
#> lazyeval 0.2.2 2019-03-15 [2] RSPM (R 4.4.0)
#> lifecycle 1.0.4 2023-11-07 [2] RSPM (R 4.4.0)
#> lubridate 1.9.3 2023-09-27 [2] RSPM (R 4.4.0)
#> magick 2.8.5 2024-09-20 [2] RSPM (R 4.4.0)
#> magrittr 2.0.3 2022-03-30 [2] RSPM (R 4.4.0)
#> maketools 1.3.1 2024-10-04 [3] RSPM (R 4.4.0)
#> MASS 7.3-61 2024-06-13 [2] RSPM (R 4.4.0)
#> Matrix 1.7-1 2024-10-18 [2] RSPM (R 4.4.0)
#> matrixStats 1.4.1 2024-09-08 [2] RSPM (R 4.4.0)
#> mime 0.12 2021-09-28 [2] RSPM (R 4.4.0)
#> Morpho 2.12 2023-12-06 [2] RSPM (R 4.4.0)
#> munsell 0.5.1 2024-04-01 [2] RSPM (R 4.4.0)
#> pdist 1.2.1 2022-05-02 [2] RSPM (R 4.4.0)
#> pillar 1.9.0 2023-03-22 [2] RSPM (R 4.4.0)
#> pkgconfig 2.0.3 2019-09-22 [2] RSPM (R 4.4.0)
#> plotly 4.10.4 2024-01-13 [2] RSPM (R 4.4.0)
#> plyr 1.8.9 2023-10-02 [2] RSPM (R 4.4.0)
#> polyclip 1.10-7 2024-07-23 [2] RSPM (R 4.4.0)
#> promises 1.3.0 2024-04-05 [2] RSPM (R 4.4.0)
#> proxy 0.4-27 2022-06-09 [2] RSPM (R 4.4.0)
#> purrr 1.0.2 2023-08-10 [2] RSPM (R 4.4.0)
#> R6 2.5.1 2021-08-19 [2] RSPM (R 4.4.0)
#> RColorBrewer 1.1-3 2022-04-03 [2] RSPM (R 4.4.0)
#> Rcpp 1.0.13-1 2024-11-02 [2] RSPM (R 4.4.0)
#> RefManageR * 1.4.0 2022-09-30 [2] RSPM (R 4.4.0)
#> rgl 1.3.14 2024-11-16 [2] RSPM (R 4.4.0)
#> rlang 1.1.4 2024-06-04 [2] RSPM (R 4.4.0)
#> rmarkdown 2.29 2024-11-04 [2] RSPM (R 4.4.0)
#> rstatix 0.7.2 2023-02-01 [2] RSPM (R 4.4.0)
#> Rvcg 0.24 2024-09-20 [2] RSPM (R 4.4.0)
#> S4Vectors 0.45.2 2024-11-16 [2] https://bioc.r-universe.dev (R 4.4.2)
#> sass 0.4.9 2024-03-15 [2] RSPM (R 4.4.0)
#> scales 1.3.0 2023-11-28 [2] RSPM (R 4.4.0)
#> sessioninfo * 1.2.2 2021-12-06 [2] RSPM (R 4.4.0)
#> sf 1.0-19 2024-11-05 [2] RSPM (R 4.4.0)
#> shiny 1.9.1 2024-08-01 [2] RSPM (R 4.4.0)
#> shinyBS 0.61.1 2022-04-17 [2] RSPM (R 4.4.0)
#> shinydashboard 0.7.2 2021-09-30 [2] RSPM (R 4.4.0)
#> sp 2.1-4 2024-04-30 [2] RSPM (R 4.4.0)
#> spatstat.data 3.1-4 2024-11-15 [2] RSPM (R 4.4.0)
#> spatstat.geom 3.3-4 2024-11-18 [2] RSPM (R 4.4.0)
#> spatstat.random 3.3-2 2024-09-18 [2] RSPM (R 4.4.0)
#> spatstat.univar 3.1-1 2024-11-05 [2] RSPM (R 4.4.0)
#> spatstat.utils 3.1-1 2024-11-03 [2] RSPM (R 4.4.0)
#> SRTsim * 0.99.7 2024-08-21 [1] CRAN (R 4.4.2)
#> stringi 1.8.4 2024-05-06 [2] RSPM (R 4.4.0)
#> stringr 1.5.1 2023-11-14 [2] RSPM (R 4.4.0)
#> sys 3.4.3 2024-10-04 [2] RSPM (R 4.4.0)
#> tibble 3.2.1 2023-03-20 [2] RSPM (R 4.4.0)
#> tidyr 1.3.1 2024-01-24 [2] RSPM (R 4.4.0)
#> tidyselect 1.2.1 2024-03-11 [2] RSPM (R 4.4.0)
#> timechange 0.3.0 2024-01-18 [2] RSPM (R 4.4.0)
#> units 0.8-5 2023-11-28 [2] RSPM (R 4.4.0)
#> utf8 1.2.4 2023-10-22 [2] RSPM (R 4.4.0)
#> vctrs 0.6.5 2023-12-01 [2] RSPM (R 4.4.0)
#> viridis 0.6.5 2024-01-29 [2] RSPM (R 4.4.0)
#> viridisLite 0.4.2 2023-05-02 [2] RSPM (R 4.4.0)
#> withr 3.0.2 2024-10-28 [2] RSPM (R 4.4.0)
#> xfun 0.49 2024-10-31 [2] RSPM (R 4.4.0)
#> xml2 1.3.6 2023-12-04 [2] RSPM (R 4.4.0)
#> xtable 1.8-4 2019-04-21 [2] RSPM (R 4.4.0)
#> yaml 2.3.10 2024-07-26 [2] RSPM (R 4.4.0)
#>
#> [1] /tmp/RtmpkrzQm5/Rinst1a2917d97841
#> [2] /github/workspace/pkglib
#> [3] /usr/local/lib/R/site-library
#> [4] /usr/lib/R/site-library
#> [5] /usr/lib/R/library
#>
#> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
This vignette was generated using BiocStyle (Oleś, 2024), knitr (Xie, 2014) and rmarkdown (Allaire, Xie, Dervieux et al., 2024) running behind the scenes.
Citations made with RefManageR (McLean, 2017).
[1] J. Allaire, Y. Xie, C. Dervieux, et al. rmarkdown: Dynamic Documents for R. R package version 2.29. 2024. URL: https://github.com/rstudio/rmarkdown.
[2] D. Bates, M. Maechler, and M. Jagan. Matrix: Sparse and Dense Matrix Classes and Methods. R package version 1.7-1. 2024. URL: https://Matrix.R-forge.R-project.org.
[3] M. W. McLean. “RefManageR: Import and Manage BibTeX and BibLaTeX References in R”. In: The Journal of Open Source Software (2017). DOI: 10.21105/joss.00338.
[4] A. Oleś. BiocStyle: Standard styles for vignettes and other Bioconductor documents. R package version 2.35.0. 2024. URL: https://github.com/Bioconductor/BiocStyle.
[5] H. Pagès, M. Lawrence, and P. Aboyoun. S4Vectors: Foundation of vector-like and list-like containers in Bioconductor. R package version 0.45.2. 2024. URL: https://bioconductor.org/packages/S4Vectors.
[6] R Core Team. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing. Vienna, Austria, 2024. URL: https://www.R-project.org/.
[7] H. Wickham, W. Chang, R. Flight, et al. sessioninfo: R Session Information. R package version 1.2.2, https://r-lib.github.io/sessioninfo/. 2021. URL: https://github.com/r-lib/sessioninfo#readme.
[8] Y. Xie. “knitr: A Comprehensive Tool for Reproducible Research in R”. In: Implementing Reproducible Computational Research. Ed. by V. Stodden, F. Leisch and R. D. Peng. Chapman and Hall/CRC, 2014. ISBN: 978-1466561595. URL: https://www.routledge.com/Implementing-Reproducible-Research/Stodden-Leisch-Peng/p/book/9781466561595.