Skip to content

Fix ForceAtlas2 random cell ordering by sort positions by vertex in draw_graph function#621

Merged
Intron7 merged 2 commits intoscverse:mainfrom
LouisFaure:fix-fa2
Mar 21, 2026
Merged

Fix ForceAtlas2 random cell ordering by sort positions by vertex in draw_graph function#621
Intron7 merged 2 commits intoscverse:mainfrom
LouisFaure:fix-fa2

Conversation

@LouisFaure
Copy link
Contributor

Hi, I noticed that tl.draw_graph was completely scrambling the order of the cells in the FA2 embedding, it seems that this is resolved by adding this line of code!

Tested on
cugraph: 26.02.00
rapdis_singlecell: 0.15.0rc4

Cheers

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ea4fd5f8-839d-426d-8ad0-dc178a657cdf

📥 Commits

Reviewing files that changed from the base of the PR and between 67eccb7 and d6b9f58.

📒 Files selected for processing (1)
  • docs/release-notes/0.15.0.md
✅ Files skipped from review due to trivial changes (1)
  • docs/release-notes/0.15.0.md

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a non-deterministic ordering in graph layout coordinates so output positions are consistently ordered and reproducible across runs, ensuring stable layouts and reliable downstream analyses.

Walkthrough

After computing positions with force_atlas2, the code now sorts the positions dataframe by the "vertex" column and resets its index before stacking "x" and "y" into the final layout, ensuring deterministic ordering by ascending vertex id.

Changes

Cohort / File(s) Summary
Draw Graph Vertex Ordering
src/rapids_singlecell/tools/_draw_graph.py
Sort positions by "vertex" and reset index after force_atlas2 so output layout rows align with ascending vertex ids.
Release Notes
docs/release-notes/0.15.0.md
Added bug-fix note documenting deterministic ordering fix for tl.draw_graph / ForceAtlas2 output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: sorting positions by vertex to fix random cell ordering in the draw_graph function's ForceAtlas2 output.
Description check ✅ Passed The description is directly related to the changeset, explaining the observed issue with cell ordering in draw_graph and indicating the fix was tested.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

@Intron7
Copy link
Member

Intron7 commented Mar 21, 2026

Can you add a release note?

@Intron7 Intron7 enabled auto-merge (squash) March 21, 2026 22:02
@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.75%. Comparing base (51817a0) to head (d6b9f58).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #621   +/-   ##
=======================================
  Coverage   87.75%   87.75%           
=======================================
  Files          96       96           
  Lines        6996     6997    +1     
=======================================
+ Hits         6139     6140    +1     
  Misses        857      857           
Files with missing lines Coverage Δ
src/rapids_singlecell/tools/_draw_graph.py 97.29% <100.00%> (+0.07%) ⬆️

@Intron7 Intron7 merged commit 989baca into scverse:main Mar 21, 2026
21 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants