JEFworks-Lab / STdeconvolve

Reference-free cell-type deconvolution of multi-cellular spatially resolved transcriptomics data
http://jef.works/STdeconvolve/
102 stars 11 forks source link

STdeconvolve and Seurat #14

Closed nsdelablancac closed 2 years ago

nsdelablancac commented 2 years ago

Hi all!

I performed my ST analysis from 10X using Seurat framework. Then I discovered this amazing tool to deepen in my data without using Single Cell. Would have any option to combine Seurat objects with STdeconvolve?

Thanks in advance.

bmill3r commented 2 years ago

Hi @nsbc6,

Thanks for using STdeconvolve!

In order to visualize deconvolved cell types you will need the matrix of gene counts for the pixels of your ST dataset and their spatial coordinates, both of which you can extract from a Seurat object if they are available.

For example, you can obtain the counts matrix, filter the features, and fit LDA models by doing something like:

## extract the counts matrix
mat <- Matrix(GetAssayData(object = seuratObject, slot = "counts"), sparse = TRUE)
## remove poor genes and pixels
mat <- cleanCounts(mat, min.lib.size = 100)
## filter for features in less than 100% of pixels but more than 5% of pixels
mat <- restrictCorpus(mat, removeAbove = 1.0, removeBelow = 0.05)
## fit LDA models using the filtered counts matrix 
ldas <- fitLDA(t(mat), Ks = seq(2, 9, by=1))

you can obtain the spatial coordinates of the pixels (if available) by doing something like:

pos <- GetTissueCoordinates(seuratObject)
colnames(pos) <- c('x','y')

It may be worth writing a wrapper function to extract the counts matrix and pixels positions from Seurat objects in the future given that a lot of users seem to access ST datasets this way.

Hope this helps and feel free to reach back out if you have more questions! Brendan