perf: optimize core trajectory and clustering bottlenecks#773
Open
svdrecbd wants to merge 1 commit into
Open
Conversation
- Ported `project2MST` cell-to-graph projection to C++ (~40x speedup) - Vectorized `specificity_matrix` JS divergence in C++ (~500x speedup) - Refactored graph construction to use integer-based `make_graph` (~3-9x speedup) - Eliminated `igraph` deprecation warnings - Validated numerical parity with baseline implementations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces critical performance optimizations to monocle3's most computationally intensive steps, significantly improving scalability for large datasets (e.g., 20k+ cells/genes). It replaces slow R-based loops with vectorized C++ implementations for trajectory learning and marker detection, achieving speedups of 40x to 500x.
Additionally, it integrates BPCells support and Multi-Scale Embedding updates from the development branch, ensuring the package is ready for massive, out-of-core single-cell analysis.
Benchmark Results (M-Series Mac)
Benchmarks verified correctness (Diff < 1e-10) and performance across dataset scales.
File Change Atlas
The PR affects ~49 files, broken down as follows:
project2MSTnow delegates the O(N) loop to C++.specificity_matrixnow uses the C++ implementation for Jensen-Shannon divergence.cluster_cells_make_graphnow constructs graphs directly from integer vectors (avoiding data.frame overhead).Validation