In this tutorial we showcase how to use SSpMosaic for spot
deconvolution of spatial data. Before SSpMosaic spatial
deconvolution, the generate_module
step should be executed
on the single-cell reference data. If the reference single-cell data has
multiple batches, the generate_module
step needs to be run
on each batch separately, followed by running the
network-propagation
step as a whole.
library(SSpMosaic)
Users can replace this directory with an appropriate path when using
setwd('./')
current_dir <- getwd()
result_dir <- paste0(current_dir,'/result/')
data_dir <- paste0(current_dir,'/data/')
The input data for SSpMosaic deconvolution should be a Seurat object containing spatial information. The example data required to run this tutorial can be downloaded from https://drive.google.com/drive/folders/1paQ8P2QjfGuThDf2DIEGzAzMHy1ChP_0.
seurat_object <- readRDS(paste0(data_dir,'/MOB10.rds'))
Load SSpMosaic programs generated by filter_module
on a
single reference dataset or follow the tutorial
network-propagation
to generate the gene sets corresponding
to the SSpMosaic metaprograms. Here we load SSpMosaic programs generated
from a single dataset.The example programs required to run this tutorial
can be downloaded from https://drive.google.com/drive/folders/1paQ8P2QjfGuThDf2DIEGzAzMHy1ChP_0.
The function SSpMosaic_decon
is used to load SSpMosaic
programs.The parameter of SSpMosaic_decon
is as
follows:
sspmosaic_program <- gene_list(paste0(data_dir,'scMOB_program_chosen.txt'))
The function SSpMosaic_decon
is used to run non-negative
least squares(NNLS) algorithm on spatial data,based on the provided
SSpMosaic program.
The parameters of SSpMosaic_decon
are as follows:
object: A seurat object of spatial transcriptomics data.
meta_moudule_genes: A list where each item is a character array storing the gene set corresponding to the SSpMosaic (meta)programs
normalize_method: A string representing the normalization method, which should be selected from ‘none’, ‘zscore’, or ‘min-max’
assay: A string indicating the name of assay to pull the gene expressiong data from
layer: A string indicating the name of layer to fetch data from,for Seurat v5 only.
slot: A string indicating the name of slot to fetch data from,for Seurat v4 only.
#Run SSpMosaic deconvolution
seurat_object <- SSpMosaic_decon(seurat_object = seurat_object,meta_moudule_genes = sspmosaic_program,normalize_method = 'zscore',assay = 'SCT',slot = 'data',layer = 'data')
Draw spatial plot to show SSpMosaic deconvolution result
#Specify the color for each celltype
ctn <- c('GC','PGC','M.TC','OSNs','EPL.IN')
cellCols <- c("#ea4065",'#58c48e','#e9a17b','#9986f9','#ffc425')
names(cellCols) <- ctn
#Extract spatial coordinates
coords <- as.data.frame(seurat_object@images[["image"]]@coordinates)
#Prepare the data.frame to plot SSpMosaic result
meta_data <- seurat_object@meta.data
meta_data$decon <- gsub('scMOB_','',meta_data$decon)
data <- data.frame(coords, group = meta_data$decon)
#Draw spatial plot
p <- ggplot(data, aes(x = x, y = y, color = group)) +
geom_point(size = 6, shape = 16) +
coord_equal() +
theme_void()+
scale_color_manual(values = cellCols)+
theme(
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5)
) +
ggtitle(paste('SSpMosaic',sep = '')) + labs(color = "Cell Type")
p