The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

PRECAST: Four DLPFC Sample Analysis

Wei Liu

2024-03-19

This vignette introduces the PRECAST workflow for the analysis of four spatial transcriptomics datasets. The workflow consists of three steps

We demonstrate the use of PRECAST to four human dorsolateral prefrontal cortex Visium data. Download the data to R

suppressPackageStartupMessages(library(Seurat))
suppressPackageStartupMessages(library(SingleCellExperiment))
name_ID4 <- as.character(c(151673, 151674, 151675, 151676))

### Read data in an online manner
n_ID <- length(name_ID4)
url_brainA <- "https://github.com/feiyoung/DR-SC.Analysis/raw/main/data/DLPFC_data/"
url_brainB <- ".rds"
seuList <- list()
if (!require(ProFAST)) {
    remotes::install_github("feiyoung/ProFAST")
}
for (i in 1:n_ID) {
    # i <- 1
    cat("input brain data", i, "\n")
    # load and read data
    dlpfc <- readRDS(url(paste0(url_brainA, name_ID4[i], url_brainB)))
    count <- dlpfc@assays@data$counts
    row.names(count) <- ProFAST::transferGeneNames(row.names(count), species = "Human")
    seu1 <- CreateSeuratObject(counts = count, meta.data = as.data.frame(colData(dlpfc)), min.cells = 10,
        min.features = 10)
    seuList[[i]] <- seu1
}
# saveRDS(seuList, file='seuList4.RDS')

The package can be loaded with the command:

library(PRECAST)

Compare PRECAST with DR-SC in analyzing one sample

First, we view the the spatial transcriptomics data with Visium platform.

seuList <- readRDS("seuList4.RDS")
seuList  ## a list including  Seurat objects

check the meta data that must include the spatial coordinates named “row” and “col”, respectively. If the names are not, they are required to rename them.

metadataList <- lapply(seuList, function(x) x@meta.data)

for (r in seq_along(metadataList)) {
    meta_data <- metadataList[[r]]
    cat(all(c("row", "col") %in% colnames(meta_data)), "\n")  ## the names are correct!

}

Prepare the PRECASTObject.

Create a PRECASTObj object to prepare for PRECAST models. Here, we only show the HVGs method to select the 2000 highly variable genes, but users are able to choose more genes or also use the SPARK-X to choose the spatially variable genes.

Add the model setting

Fit PRECAST

For function 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\). Here, we use user-specified number of clusters.

Use the function SelectModel() to re-organize the fitted results in PRECASTObj.

Other options Users are also able to set multiple K, then choose the best one

Besides, user can also use different initialization method by setting int.model, for example, set int.model=NULL; see the functions AddParSetting() and model_set() for more details.

Integration and Visualization

Integrate the all samples using the IntegrateSpaData function. For computational efficiency, this function exclusively integrates the variable genes. Specifically, in cases where users do not specify the PRECASTObj@seuList or seuList argument within the IntegrateSpaData function, it automatically focuses on integrating only the variable genes. The default setting for PRECASTObj@seuList is NULL when rawData.preserve in CreatePRECASTObject is set to FALSE. For instance:

Integrating all genes There are two ways to use IntegrateSpaData integrating all genes, which will require more memory. We recommand running for all genes on server. The first one is to set value for PRECASTObj@seuList.

The second method is to set a value for the argument seuList:

First, user can choose a beautiful color schema using chooseColors().

Show the spatial scatter plot for clusters

Users can re-plot the above figures for specific need by returning a ggplot list object. For example, we plot the spatial heatmap using a common legend.

Show the spatial UMAP/tNSE RGB plot to illustrate the performance in extracting features.

Show the tSNE plot based on the extracted features from PRECAST to check the performance of integration.

Combined differential expression analysis

Plot DE genes’ heatmap for each spatial domain identified by PRECAST.

Session Info

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.