Introduction to SRTsim

knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>"
)
## For links
library("BiocStyle")

## Track time spent on making the vignette
startTime <- Sys.time()

## Bib setup
library("RefManageR")

## Write bibliography information
bib <- c(
    R = citation(),
    BiocStyle = citation("BiocStyle")[1],
    knitr =bibentry(
     bibtype = "InCollection",
     booktitle = "Implementing Reproducible Computational Research",
     title = "knitr: A Comprehensive Tool for Reproducible Research in R",
     author = as.person("Yihui Xie [aut]"),
     editor = as.person("Victoria Stodden, Friedrich Leisch, Roger D. Peng"),
     year = "2014",
     publisher = "Chapman and Hall/CRC",
     isbn = "978-1466561595",
     url = "https://www.routledge.com/Implementing-Reproducible-Research/Stodden-Leisch-Peng/p/book/9781466561595"
   ),
    Matrix = citation("Matrix")[1],
    RefManageR = citation("RefManageR")[1],
    rmarkdown = citation("rmarkdown")[1],
    S4Vectors = citation("S4Vectors")[1],
    sessioninfo = citation("sessioninfo")[1]
)

Welcome

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.

Install SRTsim

R is an open-source statistical environment which can be easily modified to enhance its functionality via packages. r CRANpkg('SRTsim') is a R package available via CRAN. R can be installed on any operating system from CRAN after which you can install r CRANpkg('SRTsim') by using the following commands in your R session:

 install.packages("SRTsim")

Run Reference-Based Simulation

To get started, please load the r CRANpkg('SRTsim') package.

library("SRTsim")

Once you have installed the package, we can perform reference-based Tissue-wise simulation with the example data.

## explore example SRT data 
str(exampleLIBD)

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]
simcolData(simSRT1)

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]

Comparison Between Reference Data and Synthetic Data

Summarized Metrics

After data generation, we can compare metrics of reference data and synthetic data

## Compute metrics 
simSRT1   <- compareSRT(simSRT1)

## Visualize Metrics
visualize_metrics(simSRT1)

Expression Patterns For Genes of Interest

visualize_gene(simsrt=simSRT1,plotgn = "ENSG00000183036",rev_y=TRUE)
visualize_gene(simsrt=simSRT2,plotgn = "ENSG00000168314",rev_y=TRUE)

This work was done by Jiaqiang Zhu, Lulu Shang and Xiang Zhou.

Reproducibility

The r CRANpkg('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.

## Date the vignette was generated
Sys.time()

Wallclock time spent generating the vignette.

## Processing time in seconds
totalTime <- diff(c(startTime, Sys.time()))
round(totalTime, digits = 3)

R session information.

## Session info
library("sessioninfo")
original <- options("width")
options(width = 120)
session_info()
options(original)

Bibliography

This vignette was generated using r Biocpkg('BiocStyle') r Citep(bib[['BiocStyle']]), r CRANpkg('knitr') r Citep(bib[['knitr']]) and r CRANpkg('rmarkdown') r Citep(bib[['rmarkdown']]) running behind the scenes.

Citations made with r CRANpkg('RefManageR') r Citep(bib[['RefManageR']]).

## Print bibliography
PrintBibliography(bib, .opts = list(hyperlink = "to.doc", style = "html"))


Try the SRTsim package in your browser

Any scripts or data that you put into this service are public.

SRTsim documentation built on Jan. 13, 2023, 5:12 p.m.