Skip to content

Match pynndescent params and fix diffusion map reproducibility#6

Merged
maarten-devries merged 2 commits into
mainfrom
nndescent
Mar 24, 2026
Merged

Match pynndescent params and fix diffusion map reproducibility#6
maarten-devries merged 2 commits into
mainfrom
nndescent

Conversation

@maarten-devries

Copy link
Copy Markdown
Owner

Summary

  • pynndescent now accepts random_state and n_jobs, and uses the same UMAP/scanpy-matching NNDescent parameters as scib-metrics (n_trees, n_iters, max_candidates, low_memory, compressed)
  • Use deterministic v0 in eigsh for reproducible diffusion embeddings
  • Add eigenvector sign canonicalization to resolve sign ambiguity across processes

Impact

These changes fix neighbor graph discrepancies between scib-metrics and scib-rapids that caused ~1-2% differences in kbet_per_label and exact matches for all neighbor-dependent metrics (leiden, kbet, lisi).

Note: small diffs remain for kbet_per_label on clusters with degenerate eigenvalues (repeated eigenvalues in the transition matrix produce a non-unique eigenspace). This is a fundamental limitation of eigsh on small structured graphs, not an implementation bug.

🤖 Generated with Claude Code

maarten-devries and others added 2 commits March 24, 2026 00:33
- pynndescent now accepts random_state and n_jobs, and uses the same
  UMAP/scanpy-matching NNDescent parameters as scib-metrics (n_trees,
  n_iters, max_candidates, low_memory, compressed).
- Use deterministic v0 in eigsh for reproducible diffusion embeddings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Eigsh can return eigenvectors with arbitrary signs, causing
non-deterministic diffusion embeddings across processes. Canonicalize
by making the largest absolute element of each eigenvector positive.

Note: this does not fully resolve kbet_per_label diffs for small
clusters with degenerate eigenvalues (repeated eigenvalues produce
a non-unique eigenspace that sign-flipping alone cannot canonicalize).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maarten-devries maarten-devries merged commit a2db3cc into main Mar 24, 2026
1 check passed
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.

1 participant