This vignette introduces the PRECAST workflow for the analysis of integrating multiple spatial transcriptomics dataset. The workflow consists of three steps
We demonstrate the use of PRECAST to three simulated Visium data that are here, which can be downloaded to the current working path by the following command:
Then load to R
The package can be loaded with the command:
First, we view the the three simulated spatial transcriptomics data with Visium platform.
Check the content in
In this simulate dataset, we don’t require to select genes, thus, we set
## check the number of genes/features after filtering step PRECASTObj@seulist ## Add adjacency matrix list for a PRECASTObj object to prepare for PRECAST model fitting. PRECASTObj <- AddAdjList(PRECASTObj, platform = "Visium") ## Add a model setting in advance for a PRECASTObj object. verbose =TRUE helps outputing the information in the algorithm. PRECASTObj <- AddParSetting(PRECASTObj, Sigma_equal=FALSE, maxIter=30, verbose=TRUE)
PRECAST, users can specify the number of clusters \(K\) or set
K to be an integer vector by using modified BIC(MBIC) to determine \(K\). For convenience, we give a single K here.
Select a best model and use ARI to check the performance of clustering
## backup the fitting results in resList resList <- PRECASTObj@resList # PRECASTObj@resList <- resList PRECASTObj <- selectModel(PRECASTObj) true_cluster <- lapply(data_simu, function(x) x$true_cluster) str(true_cluster) mclust::adjustedRandIndex(unlist(PRECASTObj@resList$cluster), unlist(true_cluster))
Integrate the two samples by the function
Show the spatial scatter plot for clusters
Show the spatial UMAP/tNSE RGB plot
Show the tSNE plot based on the extracted features from PRECAST to check the performance of integration.
seuInt <- AddTSNE(seuInt, n_comp = 2) library(patchwork) cols_cluster <- c("#E04D50", "#4374A5", "#F08A21","#2AB673", "#FCDDDE", "#70B5B0", "#DFE0EE" ,"#D0B14C") p1 <- dimPlot(seuInt, font_family='serif', cols=cols_cluster) # Times New Roman p2 <- dimPlot(seuInt, item='batch', point_size = 1, font_family='serif') p1 + p2 # It is noted that only sample batch 1 has cluster 4, and only sample batch 2 has cluster 7.
Show the UMAP plot based on the extracted features from PRECAST.
Users can also use the visualization functions in Seurat package:
Combined differential expression analysis