Skip to content

Conversation

@jpintar
Copy link
Contributor

@jpintar jpintar commented Oct 7, 2025

Adds jaccard as a method in sc.pp.neighbors alongside umap and gauss. The method performs a weighting of the kNN adjacency graph using Jaccard coefficients between pairs of connected vertices. This is the weighting used in the PhenoGraph package and in Seurat, and it is especially useful to include it here in light of PhenoGraph no longer being actively maintained and the sc.external API being slated for removal, as mentioned in #3828.

N.b., the present implementation of the weighting is notably faster than that in PhenoGraph, since it avoids looping over set intersections in favour of sparse matrix operations, but it returns identical results for identical input matrices of kNN indices.

@flying-sheep
Copy link
Member

Hi! Sorry we didn’t react for so long! This looks very nice! Great addition and implementation!

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.79%. Comparing base (800c0b0) to head (7ccbc63).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3831      +/-   ##
==========================================
+ Coverage   76.77%   76.79%   +0.02%     
==========================================
  Files         115      115              
  Lines       12369    12383      +14     
==========================================
+ Hits         9496     9510      +14     
  Misses       2873     2873              
Flag Coverage Δ
hatch-test.pre 76.79% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/neighbors/__init__.py 80.05% <100.00%> (+0.10%) ⬆️
src/scanpy/neighbors/_connectivity.py 88.23% <100.00%> (+2.52%) ⬆️
src/scanpy/neighbors/_types.py 100.00% <100.00%> (ø)

@flying-sheep flying-sheep added this to the 1.12.0 milestone Nov 10, 2025
@flying-sheep flying-sheep changed the title Add jaccard as an additional method in sc.pp.neighbors feat: add jaccard as an additional method in sc.pp.neighbors Nov 10, 2025
@flying-sheep flying-sheep merged commit 6e7fe21 into scverse:main Nov 10, 2025
14 checks passed
@jpintar
Copy link
Contributor Author

jpintar commented Nov 10, 2025

Thank you for looking over it and fixing it up! And no worries about the delayed response - I know how busy things get!

@jpintar jpintar deleted the jaccard_connectivities branch November 10, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add jaccard as an additional method in sc.pp.neighbors

2 participants