PRECAST: a probabilistic embedding and clustering with alignment for spatial transcriptomics data integration.

PRECAST is a package for integrating and analyzing multiple spatially resolved transcriptomics (SRT) datasets, developed by the Jin Liu’s lab. It unifies spatial factor analysis simultaneously with spatial clustering and embedding alignment, requiring only partially shared cell/domain clusters across datasets.

Check out our Nature Communications paper and our Package Website for a more complete description of the methods and analyses.

PRECAST can be used to compare and contrast experimental datasets in a variety of contexts, for instance:

Once multiple datasets are integrated, the package provides functionality for further data exploration, analysis, and visualization. Users can:


“PRECAST” depends on the ‘Rcpp’ and ‘RcppArmadillo’ package, which requires appropriate setup of computer. For the users that have set up system properly for compiling C++ files, the following installation command will work.

# Method 1: install PRECAST from CRAN

# For the newest version of PRECAST, users can use method 2 for installation.
# Method 2: Install PRECAST from Github
if (!require("remotes", quietly = TRUE))

# If some dependent packages (such as `scater`) on Bioconductor can not be installed nomrally, use following commands, then run abouve command.
if (!require("BiocManager", quietly = TRUE)) ## install BiocManager
# install the package on Bioconducter


For usage examples and guided walkthroughs, check the vignettes directory of the repo.

For the users that don’t have set up system properly, the following setup on different systems can be referred. ## Setup on Windows system First, download Rtools; second, add the Rtools directory to the environment variable.

Setup on MacOS system

First, install Xcode. Installation about Xcode can be referred here.

Second, install “gfortran” for compiling C++ and Fortran at here.

Setup on Linux system

For parallel computation on Linux, users must use the following system command to set the C_stack unlimited in case of the error R Error: C stack usage is too close to the limit.

ulimit -s unlimited

If you use conda environment on Linux system and some dependent packages (such as scater) can not normally installed, you can search R package at website. We take the scater package as example, and its search result is Then you can install it in conda environment by following command.

conda install -c bioconda bioconductor-scater

For the user not using conda environment, if dependent packages (such as scater) not normally installed are in Bioconductor, then use the following command to install the dependent packages.

# install BiocManager
if (!require("BiocManager", quietly = TRUE))
# install the package on Bioconducter

If dependent packages (such as DR.SC) not normally installed are in CRAN, then use the following command to install the dependent packages.

# install the package on CRAN


For an example of typical PRECAST usage, please see our Package Website for a demonstration and overview of the functions included in PRECAST.


PRECAST version 1.6.5 (2024-03-19) * Update the email adress of maintainer.

PRECAST version 1.6.4 (2024-01-24) * Update IntegrateSpaData() to make it able to remove unwanted variations for all genes rather than only variable genes.

PRECAST version 1.6.2 (2023-08-02) * Update the code to ensure compatibility with Seurat V5.

PRECAST version 1.6.1 (2023-05-06) * Fix the bug, reported by agelber-ucsd, in IntegrateSpaData() when adusting additional covariates.

PRECAST version 1.6 (2023-04-18)

PRECAST version 1.5 (2023-03-05)

PRECAST version 1.3 (2022-10-05)