SSpMosaic spatial deconvolution

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.

Package loading

library(SSpMosaic)

Set the working directory

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/')

Data loading

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'))

SSpMosaic program loading

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'))

SSpMosaic deconvolution

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:

#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')

Show SSpMosaic deconvolution result

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