
Working with different data objects
Source:vignettes/supported_data_structure.Rmd
supported_data_structure.Rmdimage-based SRT in SpatialExperiment
(e.g. SpatialFeatureExperiment)
tpSVG can be also used to model image-based SRT data. We
use the seqFISH data from Lohoff and
Ghazanfar et al. (2020) to demonstrate tpSVG.
Specifically, we use the curated example data in STexampleData
package. For more information, please see the vignettes of STexampleData
library(STexampleData)
spe <- seqFISH_mouseEmbryo()
spe
#> class: SpatialExperiment
#> dim: 351 11026
#> metadata(0):
#> assays(2): counts molecules
#> rownames(351): Abcc4 Acp5 ... Zfp57 Zic3
#> rowData names(1): gene_name
#> colnames(11026): embryo1_Pos0_cell10_z2 embryo1_Pos0_cell100_z2 ...
#> embryo1_Pos28_cell97_z2 embryo1_Pos28_cell98_z2
#> colData names(14): cell_id embryo ... segmentation_vertices sample_id
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
#> spatialCoords names(2) : x y
#> imgData names(0):The example data set contains 351 genes for
11026 genes. To make the demonstration computationally
feasible, we down-size the number of genes to 3. The average computation
times for 11026 cells is roughly 2 minutes.
# Calculate "library size"
spe$total <- counts(spe) |> colSums()
# Down-size genes
idx_gene <- which(
rowData(spe)$gene_name %in%
c("Sox2", "Hand1", "Gata5")
)
library(tpSVG)
# Poisson model
tp_spe <- tpSVG(
input = spe[idx_gene,],
family = poisson(),
offset = log(spe$total),
assay_name = "counts")
rowData(tp_spe)
#> DataFrame with 3 rows and 4 columns
#> gene_name test_stat raw_p runtime
#> <character> <numeric> <numeric> <numeric>
#> Gata5 Gata5 8024.84 0 0.959
#> Hand1 Hand1 8393.34 0 0.936
#> Sox2 Sox2 9588.51 0 0.931Session Information
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31)
#> os Ubuntu 22.04.3 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language en
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz UTC
#> date 2023-12-30
#> pandoc 3.1.1 @ /usr/local/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> abind 1.4-5 2016-07-21 [1] RSPM (R 4.3.0)
#> AnnotationDbi 1.64.1 2023-11-03 [1] Bioconductor
#> AnnotationHub * 3.10.0 2023-10-24 [1] Bioconductor
#> Biobase * 2.62.0 2023-10-24 [1] Bioconductor
#> BiocFileCache * 2.10.1 2023-10-26 [1] Bioconductor
#> BiocGenerics * 0.48.1 2023-11-01 [1] Bioconductor
#> BiocManager 1.30.22 2023-08-08 [2] CRAN (R 4.3.2)
#> BiocParallel 1.36.0 2023-10-24 [1] Bioconductor
#> BiocVersion 3.18.1 2023-11-15 [2] Bioconductor
#> Biostrings 2.70.1 2023-10-25 [1] Bioconductor
#> bit 4.0.5 2022-11-15 [1] RSPM (R 4.3.0)
#> bit64 4.0.5 2020-08-30 [1] RSPM (R 4.3.0)
#> bitops 1.0-7 2021-04-24 [1] RSPM (R 4.3.0)
#> blob 1.2.4 2023-03-17 [1] RSPM (R 4.3.0)
#> bslib 0.6.1 2023-11-28 [2] RSPM (R 4.3.0)
#> BumpyMatrix * 1.10.0 2023-10-24 [1] Bioconductor
#> cachem 1.0.8 2023-05-01 [2] RSPM (R 4.3.0)
#> cli 3.6.2 2023-12-11 [2] RSPM (R 4.3.0)
#> codetools 0.2-19 2023-02-01 [3] CRAN (R 4.3.2)
#> crayon 1.5.2 2022-09-29 [2] RSPM (R 4.3.0)
#> curl 5.2.0 2023-12-08 [2] RSPM (R 4.3.0)
#> DBI 1.2.0 2023-12-21 [1] RSPM (R 4.3.0)
#> dbplyr * 2.4.0 2023-10-26 [1] RSPM (R 4.3.0)
#> DelayedArray 0.28.0 2023-10-24 [1] Bioconductor
#> desc 1.4.3 2023-12-10 [2] RSPM (R 4.3.0)
#> digest 0.6.33 2023-07-07 [2] RSPM (R 4.3.0)
#> dplyr 1.1.4 2023-11-17 [1] RSPM (R 4.3.0)
#> ellipsis 0.3.2 2021-04-29 [2] RSPM (R 4.3.0)
#> evaluate 0.23 2023-11-01 [2] RSPM (R 4.3.0)
#> ExperimentHub * 2.10.0 2023-10-24 [1] Bioconductor
#> fansi 1.0.6 2023-12-08 [2] RSPM (R 4.3.0)
#> fastmap 1.1.1 2023-02-24 [2] RSPM (R 4.3.0)
#> filelock 1.0.3 2023-12-11 [1] RSPM (R 4.3.0)
#> fs 1.6.3 2023-07-20 [2] RSPM (R 4.3.0)
#> generics 0.1.3 2022-07-05 [1] RSPM (R 4.3.0)
#> GenomeInfoDb * 1.38.5 2023-12-28 [1] Bioconductor 3.18 (R 4.3.2)
#> GenomeInfoDbData 1.2.11 2023-11-15 [1] Bioconductor
#> GenomicRanges * 1.54.1 2023-10-29 [1] Bioconductor
#> glue 1.6.2 2022-02-24 [2] RSPM (R 4.3.0)
#> htmltools 0.5.7 2023-11-03 [2] RSPM (R 4.3.0)
#> httpuv 1.6.13 2023-12-06 [2] RSPM (R 4.3.0)
#> httr 1.4.7 2023-08-15 [2] RSPM (R 4.3.0)
#> interactiveDisplayBase 1.40.0 2023-10-24 [1] Bioconductor
#> IRanges * 2.36.0 2023-10-24 [1] Bioconductor
#> jquerylib 0.1.4 2021-04-26 [2] RSPM (R 4.3.0)
#> jsonlite 1.8.8 2023-12-04 [2] RSPM (R 4.3.0)
#> KEGGREST 1.42.0 2023-10-24 [1] Bioconductor
#> knitr 1.45 2023-10-30 [2] RSPM (R 4.3.0)
#> later 1.3.2 2023-12-06 [2] RSPM (R 4.3.0)
#> lattice 0.22-5 2023-10-24 [3] RSPM (R 4.3.0)
#> lifecycle 1.0.4 2023-11-07 [2] RSPM (R 4.3.0)
#> magick 2.8.2 2023-12-20 [1] RSPM (R 4.3.0)
#> magrittr 2.0.3 2022-03-30 [2] RSPM (R 4.3.0)
#> Matrix 1.6-4 2023-11-30 [3] RSPM (R 4.3.0)
#> MatrixGenerics * 1.14.0 2023-10-24 [1] Bioconductor
#> matrixStats * 1.2.0 2023-12-11 [1] RSPM (R 4.3.0)
#> memoise 2.0.1 2021-11-26 [2] RSPM (R 4.3.0)
#> mgcv * 1.9-1 2023-12-21 [3] RSPM (R 4.3.0)
#> mime 0.12 2021-09-28 [2] RSPM (R 4.3.0)
#> nlme * 3.1-164 2023-11-27 [3] RSPM (R 4.3.0)
#> pillar 1.9.0 2023-03-22 [2] RSPM (R 4.3.0)
#> pkgconfig 2.0.3 2019-09-22 [2] RSPM (R 4.3.0)
#> pkgdown 2.0.7 2022-12-14 [2] RSPM (R 4.3.0)
#> png 0.1-8 2022-11-29 [1] RSPM (R 4.3.0)
#> promises 1.2.1 2023-08-10 [2] RSPM (R 4.3.0)
#> purrr 1.0.2 2023-08-10 [2] RSPM (R 4.3.0)
#> R6 2.5.1 2021-08-19 [2] RSPM (R 4.3.0)
#> ragg 1.2.7 2023-12-11 [2] RSPM (R 4.3.0)
#> rappdirs 0.3.3 2021-01-31 [2] RSPM (R 4.3.0)
#> Rcpp 1.0.11 2023-07-06 [2] RSPM (R 4.3.0)
#> RCurl 1.98-1.13 2023-11-02 [1] RSPM (R 4.3.0)
#> rjson 0.2.21 2022-01-09 [1] RSPM (R 4.3.0)
#> rlang 1.1.2 2023-11-04 [2] RSPM (R 4.3.0)
#> rmarkdown 2.25 2023-09-18 [2] RSPM (R 4.3.0)
#> RSQLite 2.3.4 2023-12-08 [1] RSPM (R 4.3.0)
#> S4Arrays 1.2.0 2023-10-24 [1] Bioconductor
#> S4Vectors * 0.40.2 2023-11-23 [1] Bioconductor 3.18 (R 4.3.2)
#> sass 0.4.8 2023-12-06 [2] RSPM (R 4.3.0)
#> sessioninfo 1.2.2 2021-12-06 [2] RSPM (R 4.3.0)
#> shiny 1.8.0 2023-11-17 [2] RSPM (R 4.3.0)
#> SingleCellExperiment * 1.24.0 2023-10-24 [1] Bioconductor
#> SparseArray 1.2.3 2023-12-25 [1] Bioconductor 3.18 (R 4.3.2)
#> SpatialExperiment * 1.12.0 2023-10-24 [1] Bioconductor
#> STexampleData * 1.10.0 2023-10-26 [1] Bioconductor
#> stringi 1.8.3 2023-12-11 [2] RSPM (R 4.3.0)
#> stringr 1.5.1 2023-11-14 [2] RSPM (R 4.3.0)
#> SummarizedExperiment * 1.32.0 2023-10-24 [1] Bioconductor
#> systemfonts 1.0.5 2023-10-09 [2] RSPM (R 4.3.0)
#> textshaping 0.3.7 2023-10-09 [2] RSPM (R 4.3.0)
#> tibble 3.2.1 2023-03-20 [2] RSPM (R 4.3.0)
#> tidyselect 1.2.0 2022-10-10 [1] RSPM (R 4.3.0)
#> tpSVG * 0.99.1 2023-12-30 [1] Bioconductor
#> utf8 1.2.4 2023-10-22 [2] RSPM (R 4.3.0)
#> vctrs 0.6.5 2023-12-01 [2] RSPM (R 4.3.0)
#> withr 2.5.2 2023-10-30 [2] RSPM (R 4.3.0)
#> xfun 0.41 2023-11-01 [2] RSPM (R 4.3.0)
#> xtable 1.8-4 2019-04-21 [2] RSPM (R 4.3.0)
#> XVector 0.42.0 2023-10-24 [1] Bioconductor
#> yaml 2.3.8 2023-12-11 [2] RSPM (R 4.3.0)
#> zlibbioc 1.48.0 2023-10-24 [1] Bioconductor
#>
#> [1] /__w/_temp/Library
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/local/lib/R/library
#>
#> ──────────────────────────────────────────────────────────────────────────────