Skip to content

Vary rank for CP and RISE #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 39 commits into from
Closed

Vary rank for CP and RISE #30

wants to merge 39 commits into from

Conversation

Nathaniel-github
Copy link
Collaborator

No description provided.

@Nathaniel-github Nathaniel-github requested a review from Copilot July 14, 2025 03:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables specifying a separate CP decomposition rank (cp_rank) in the CC-PF2 workflow, refactors plotting and utility functions accordingly, and adds end-to-end figure generation tests.

  • Introduce and propagate the cp_rank parameter through cc_pf2, run_cc_pf2_workflow, and plotting scripts.
  • Add utility functions resample and calculateFMS for bootstrapping and factor match scoring.
  • Add tests to automatically run all figure scripts and update existing CC-PF2 tests to match the new output structure.

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Add tensorly-viz dependency for CP visualization
cellcommunicationpf2/utils.py Add resample and calculateFMS helper functions
cellcommunicationpf2/tests/test_figures.py New test to auto-run all figures (dynamic import logic)
cellcommunicationpf2/tests/test_ccpf2.py Update unpacking of cc_pf2 results to use the new cp_rank output
cellcommunicationpf2/figures/figure1.py Refactor Figure 1 generation with run_cc_pf2_workflow and new plotting helpers
cellcommunicationpf2/figures/figure2.py Update stability analysis to use resample and calculateFMS
cellcommunicationpf2/figures/figure3.py Add Figure 3 showing CP component weight vs. sample size
cellcommunicationpf2/figures/commonFuncs/plotFactors.py Improve row-color legend placement and fix hierarchical clustering
cellcommunicationpf2/figures/common.py Add run_cc_pf2_workflow, correct_conditions, and integrate CP rank logic
cellcommunicationpf2/ccc.py Simplify loops using _ and use inline conditionals
cellcommunicationpf2/cc_pf2.py Introduce cp_rank parameter, update return signature and CP logic
Comments suppressed due to low confidence (3)

cellcommunicationpf2/utils.py:31

  • [nitpick] Function name calculateFMS does not follow PEP8 snake_case conventions. Consider renaming it to calculate_fms for consistency.
def calculateFMS(A: anndata.AnnData, B: anndata.AnnData) -> float:

cellcommunicationpf2/utils.py:6

  • The new utility functions resample and calculateFMS are not covered by any unit tests. Consider adding dedicated tests to verify correct stratified resampling and factor match score calculation.
def resample(data: anndata.AnnData, random_seed: int = None) -> anndata.AnnData:

cellcommunicationpf2/tests/test_figures.py:23

  • The import_module call assumes the figures live under the cellcommunicationpf2.tests.figures package, but they are located in cellcommunicationpf2/figures. Update the import path to cellcommunicationpf2.figures.{module_name} or adjust the package argument accordingly.
            module = importlib.import_module(f"..figures.{module_name}", package="cellcommunicationpf2.tests")

@andrewram4287
Copy link
Collaborator

@Nathaniel-github I'll review this once we get your other PRs merged

Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 97.83394% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.14%. Comparing base (3be1ac3) to head (2c0b8a8).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
cellcommunicationpf2/cc_pf2.py 89.65% 3 Missing ⚠️
cellcommunicationpf2/ccc.py 66.66% 2 Missing ⚠️
...ommunicationpf2/figures/commonFuncs/plotFactors.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #30       +/-   ##
===========================================
+ Coverage   46.81%   78.14%   +31.32%     
===========================================
  Files           6       11        +5     
  Lines         361      668      +307     
===========================================
+ Hits          169      522      +353     
+ Misses        192      146       -46     
Flag Coverage Δ
unittests 78.14% <97.83%> (+31.32%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Nathaniel-github Nathaniel-github deleted the vary_rank branch July 18, 2025 21:14
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.

2 participants