satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.18k stars 891 forks source link

BuildNicheAssay; best practice for optimal usage #9044

Open KoichiHashikawa opened 1 week ago

KoichiHashikawa commented 1 week ago

Hello Satija group,

Thanks so much for adding many exciting functionalities in the new V5.

I have a few questions around "BuildNicheAssay". I appreciate if you can share your insights when you have a chance.

how are niches computed? Is the computation flow as the following? neighborhood graph is generated by searching for k near neighbor cells of each cell in space. Is this based on euclidean distance or delaunay network? This is stored as obj@assays$niche@counts. obj@assays$niche@counts or obj@assays$niche@scale.data is used as inputs for clustering dimensionality reduction using PCA or using all features as inputs? k-mean clustering, using the user defined number of clusters, k how to find optimal number of near neighbor, k? Default seems 30. Is this a good number to stick to or should we change it depending on the number of cell types in space (e.g. more cell types, higher k)?

how to find optimal number of clusters, k? I feel that this is the most critical point that may make significant differences in the final analytical results. If k-mean clustering is used, do you recommend silhouette method to identify optimal k? I tried silhouette method to find optimal number, but the scale of the spatial data is too large and it could easily crash the computational environment (my guess is dist(df) may be the cause). Or do you have any other ways (including empirical suggestions; XX number of niches are good for YY number of cell types) to define the number of niches?

Thank you! best, Koichi

odunola26 commented 1 week ago

Hello,

Please , i am trying to run "BuildNicheAssay" on my 10x visium data, but I am having error with the Fov, please can you guide me on how i can access this from my seurat object. here is my code :

Extract spatial coordinates from the centroids object

coords <- sample39_obj@images$slice1@boundaries$centroids@coords coords

Ensure the coordinates matrix has proper row names

rownames(coords) <- sample39_obj@images$slice1@boundaries$centroids@cells

Create the FOV list with the correct format

fov <- list(FOV = coords)

Run BuildNicheAssay

sample39_obj <- BuildNicheAssay( object = sample39_obj, fov = fov, group.by = "predicted.celltype", assay = "niche", cluster.name = "niches", neighbors.k = 30, niches.k = 5 )

Thank you. Odunola

KoichiHashikawa commented 1 week ago

@odunola26 What you are posting here is a separate issue. I have created a new issue for it where you may want to discuss your issue with Seurat folks.