Package: SpaTopic 1.2.0
SpaTopic: Topic Inference to Identify Tissue Architecture in Multiplexed Images
A novel spatial topic model to integrate both cell type and spatial information to identify the complex spatial tissue architecture on multiplexed tissue images without human intervention. The Package implements a collapsed Gibbs sampling algorithm for inference. 'SpaTopic' is scalable to large-scale image datasets without extracting neighborhood information for every single cell. For more details on the methodology, see <https://xiyupeng.github.io/SpaTopic/>.
Authors:
SpaTopic_1.2.0.tar.gz
SpaTopic_1.2.0.tar.gz(r-4.5-noble)SpaTopic_1.2.0.tar.gz(r-4.4-noble)
SpaTopic_1.2.0.tgz(r-4.4-emscripten)SpaTopic_1.2.0.tgz(r-4.3-emscripten)
SpaTopic.pdf |SpaTopic.html✨
SpaTopic/json (API)
NEWS
# Install 'SpaTopic' in R: |
install.packages('SpaTopic', repos = 'https://cloud.r-project.org') |
Bug tracker:https://github.com/xiyupeng/spatopic/issues
- lung5 - Example input data for 'SpaTopic'
Last updated 10 days agofrom:6799f595d0. Checks:3 OK. Indexed: no.
Target | Result | Latest binary |
---|---|---|
Doc / Vignettes | OK | Mar 03 2025 |
R-4.5-linux-x86_64 | OK | Mar 03 2025 |
R-4.4-linux-x86_64 | OK | Mar 03 2025 |
Exports:Seurat5obj_to_SpaTopicSpaTopic_inferencestratified_sampling_sf
Dependencies:classclassIntcodetoolsDBIe1071foreachiteratorsKernSmoothmagrittrMASSproxyRANNRcppRcppArmadilloRcppProgresss2sfunitswk
Citation
To cite package ‘SpaTopic’ in publications use:
Peng X (2025). SpaTopic: Topic Inference to Identify Tissue Architecture in Multiplexed Images. R package version 1.2.0, https://CRAN.R-project.org/package=SpaTopic.
Corresponding BibTeX entry:
@Manual{, title = {SpaTopic: Topic Inference to Identify Tissue Architecture in Multiplexed Images}, author = {Xiyu Peng}, year = {2025}, note = {R package version 1.2.0}, url = {https://CRAN.R-project.org/package=SpaTopic}, }
Readme and manuals
SpaTopic
An R package for fast topic inference to identify tissue architecture in multiplexed images. It implements a novel spatial topic model to identify immunologic topics across multiple multiplexed images, simply given the cell location and cell type information as input.
Here we adapt an approach originally developed for image segmentation in computer vision, incorporating spatial information into the flexible design of regions (image partitions, analogous to documents in language modeling). We further refined the approach to address unique challenges in cellular images and provide an efficient C++ implementation of the algorithm in this R package.
Compared to other KNN-based methods (such as KNN-kmeans, the default neighborhood analysis in Seurat v5 R package), SpaTopic runs much faster on large-scale image dataset.
Installation
The R package SpaTopic
now is available in CRAN and can be installed with the following code.
install.packages("SpaTopic")
The development version of SpaTopic
can be installed from the GitHub repository.
# install.packages("devtools")
devtools::install_github("xiyupeng/SpaTopic")
Dependency
SpaTopic requires dependency on the following R packages:
- Rcpp for C++ codes
- RcppProgress for C++ codes
- RcppArmadillo for C++ codes
- RANN for fast KNN
- foreach for parallel computing
- sf for spatial analysis
Usage
The required input of SpaTopic is a data frame containing cells within on a single image or a list of data frames for multiple images. Each data frame consists of four columns: The image ID, X, Y cell coordinates, and cell type information.
library(SpaTopic)
packageVersion("SpaTopic")
#> [1] '1.2.0'
library(sf)
## The input can be a data frame or a list of data frames
data("lung5")
head(lung5)
# image X Y type
#1_1 image1 4215.889 158847.7 Dendritic
#2_1 image1 6092.889 158834.7 Macrophage
#3_1 image1 7214.889 158843.7 Neuroendocrine
#4_1 image1 7418.889 158813.7 Macrophage
#5_1 image1 7446.889 158845.7 Macrophage
#6_1 image1 3254.889 158838.7 CD4 T
gibbs.res<-SpaTopic_inference(lung5, ntopics = 7, sigma = 50, region_radius = 400)
For detailed usage of SpaTopic, please check the tutorial.
Example Data
The example image used in the tutorial can be downloaded from here. It is stored in a Seurat v5 object.
Example Output
The algorithm generates two key statistics for further analysis:
-
- topic content, a spatially-resolved topic distribution over cell types, and
-
- topic assignment for each cell within images.
Topic Spatial Distribution over images
Topic Content
Citation
Xiyu Peng, James W. Smithy, Mohammad Yosofvand, Caroline E. Kostrzewa, MaryLena Bleile, Fiona D. Ehrich, Jasme Lee, Michael A. Postow, Margaret K. Callahan, Katherine S. Panageas, Ronglai Shen. Decoding Spatial Tissue Architecture: A Scalable Bayesian Topic Model for Multiplexed Imaging Analysis. bioRxiv. doi: https://doi.org/10.1101/2024.10.08.617293
Contact
If you have any problems, please contact:
Xiyu Peng (pansypeng124@gmail.com, pengx@stat.tamu.edu)
Help Manual
Help page | Topics |
---|---|
Example input data for 'SpaTopic' | lung5 |
Print method for SpaTopic objects | print.SpaTopic |
Convert a Seurat v5 object as the input of 'SpaTopic' | Seurat5obj_to_SpaTopic |
'SpaTopic': fast topic inference to identify tissue architecture in multiplexed images | SpaTopic_inference |
Format messages for SpaTopic package | spatopic_message |
A class of the output from 'SpaTopic' | SpaTopic-class |
SpaTopic: Spatial Topic Modeling for Multiplexed Images | SpaTopic-package SpaTopic SpaTopic-Package |
Spatially stratified random sample points from an image. | stratified_sampling_sf |