scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.92k stars 603 forks source link

Always add 'use_rep' for uns["neighbors"]["params"] #2736

Open canergen opened 1 year ago

canergen commented 1 year ago

Please describe your wishes and possible alternatives to achieve the desired result.

No key inside 'use_rep' can mean 'X' or 'X_pca' was used for nearest neighbor calculation depending on the number of vars. It's storing things correctly if 'use_rep' is called explicitly.

sc.pp.neighbors(combined_emb, n_neighbors=50)
combined_emb.uns["neighbors"]["params"]["use_rep"] -> KeyError

sc.pp.neighbors(combined_emb, n_neighbors=50, use_rep='X')
combined_emb.uns["neighbors"]["params"]["use_rep"] -> 'X'
ivirshup commented 1 year ago

Thanks for the issue!

Moving this over to scanpy, since it's more relevant there. I think this reasonable. Would you be up for adding this?