atarashansky / self-assembling-manifold

The Self-Assembling-Manifold (SAM) algorithm.
MIT License
41 stars 11 forks source link

KNN Information from sam object #41

Closed Sayyam-Shah closed 1 year ago

Sayyam-Shah commented 1 year ago

Hello @atarashansky,

Thank you so much for the amazing tool. :) It has been excellent at clustering our cells. I am clustering 253 signatures using SAM with the below parameters.

sam=SAM(counts=test_clip)
sam.run(max_iter=15, preprocessing="Normalizer", distance = 'correlation', k = 8, npcs=10)
sam.leiden_clustering(res=1.5)
adata= sam.adata

In a previous discussion post, you mentioned that the KNN information could be retrieved by running sc.pp.neighbors() since it relies on SAM's X_PCA and auxiliary metadata on the KNN method used. However, when looking into the metadata, I noticed it doesn't match the parameters I used, as shown below. image

I compared the distances from sc.pp.neighbors(adata) and sc.pp.neighbors(adata, n_pcs = 10, n_neighbors = 8, metric = "correlation", use_rep = 'X_pca'), and I noticed the resulting distance metrics are pretty different. Is there a better approach you recommend I use to retrieve the KNN matrix since I would like to use it for some downstream analysis, specifically to generate a similarity matrix for Cytoscape?

Thank you :), Sayyam

atarashansky commented 1 year ago

Hi Sayyam,

You can retrieve the KNN by accessing connectivities in sam.adata.obsp: sam.adata.obsp['connectivities']

Hopefully this is what you were looking for!

Best, Alec

Sayyam-Shah commented 1 year ago

Thank you so much!