scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
433 stars 79 forks source link

neighbors and annotation #472

Closed wangjiawen2013 closed 2 years ago

wangjiawen2013 commented 2 years ago

... Hi, we can find neighbors with both sq.gr.spatial_neighbors() of squidpy and sc.pp.neighbors() of scanpy. here's my question: 1, what's the difference between them and which one should I use for downstream analysis ? 2, If I want to use the union of the two kinds of neighbors, how to merge them ? 3, The clusters were pre-annotated in all the examples in squidpy's tutorial, then how were the annotation pefromedt ? Why can't we cluster the spots just like what we did in single cell RNAseq analysis (find neighbors, and clustering with leiden algorithm and annotate the spots with marker genes) ?

giovp commented 2 years ago

hi @wangjiawen2013 sorry for late reply and thanks for interest in squidpy. Let me try to answer your questions

1, what's the difference between them and which one should I use for downstream analysis ?

spatial neighbors compute neighbors on spatial coordinates in different fashions, check out the paper and this tutorial https://squidpy.readthedocs.io/en/latest/auto_examples/graph/compute_spatial_neighbors.html

2, If I want to use the union of the two kinds of neighbors, how to merge them ?

you'd have to aggregate the connectivities, e.g.

adata.obsp["connectivities"] + adata.obsp["spatial_connectivities"]

The clusters were pre-annotated in all the examples in squidpy's tutorial, then how were the annotation pefromedt ? Why can't we cluster the spots just like what we did in single cell RNAseq analysis (find neighbors, and clustering with leiden algorithm and annotate the spots with marker genes) ?

you can indeed, this is what we did, checkout the reproducibility repo https://github.com/theislab/squidpy_reproducibility

let me know if it helps!

giovp commented 2 years ago

340 partially address the fact that you can now build spatial graph based on library_id key. I'll close this but feel free to reopen

wangjiawen2013 commented 2 years ago

@giovp Hi, How to set n_rings and neighbors when using ST (grid) or visium (hexagon) platforms ? 屏幕快照 2022-04-20 下午9 29 45

giovp commented 2 years ago

sq.gr.spatial_neighbors(adata, coord_type="grid", n_neighs=6)

or 4 for ST

https://squidpy.readthedocs.io/en/latest/api/squidpy.gr.spatial_neighbors.html#squidpy.gr.spatial_neighbors