feiyoung / PRECAST

an efficient data integration method for multiple spatial transcriptomics data with non- cluster-relevant effects such as the complex batch effects.
GNU General Public License v3.0
10 stars 3 forks source link

3D Functionality in Precast #22

Open MoussaKassim opened 3 weeks ago

MoussaKassim commented 3 weeks ago

Hello,

I am reaching out to inquire whether Precast supports 3D functionality. This feature would be highly beneficial for our current project.

Could you please confirm if Precast can be used with 3D data? If so, any additional information or documentation on how to implement this would be greatly appreciated.

Thank you in advance for your assistance.

Best regards,

tkcaccia commented 3 weeks ago

I have the same question. PRECAST uses as input a Seurat object but I cannot create a spatial object with three-dimension (e.g., xyz) with Seurat. Can PRECAST use three-dimensional spatial information? If yes, can you provide an example?

feiyoung commented 3 weeks ago

Yes, PRECAST is indeed capable of utilizing three-dimensional spatial information. Within PRECAST, this spatial information is employed to construct an adjacency matrix, which quantifies the similarities among various spots.

In our recently developed R package, ProFAST, we offer a function named 'AddAdj' that seamlessly integrates support for three-dimensional coordinates. Below, we present an illustrative example of how to incorporate this function into PRECAST, drawing upon the tutorial found at https://feiyoung.github.io/PRECAST/articles/PRECAST.BreastCancer.html. This example demonstrates the practical application of 'AddAdj' within the PRECAST framework.

Here are the codes: install.packages(''ProFAST") library(ProFAST)

Create PRECASTObject.

set.seed(2022) PRECASTObj <- CreatePRECASTObject(bc2, project = "BC2", gene.number = 2000, selectGenesMethod = "SPARK-X", premin.spots = 20, premin.features = 20, postmin.spots = 1, postmin.features = 10)

Assume the three-dimensional cooridnates are saved in PRECASTObj@seulist[[1]]@meta.data[,c('x', 'y', 'z')]

posList <- lapply(PRECASTObj@seulist, function(x) as.matrix(@meta.data[,c('x', 'y', 'z')]))

calculate the adjacency matrix based the three-dimensional cooridnates

PRECASTObj@AdjList <- pbapply::pblapply(posList, AddAdj, neighbors=6)

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, verbose = TRUE, maxIter = 30)

Given K, run PRECAST!

PRECASTObj <- PRECAST(PRECASTObj, K = 14)

tkcaccia commented 3 weeks ago

Thank you very much