Skip to content
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

Add TSI score code #1166

Merged
merged 20 commits into from
Mar 4, 2024
Merged

Add TSI score code #1166

merged 20 commits into from
Mar 4, 2024

Conversation

WeilerP
Copy link
Member

@WeilerP WeilerP commented Feb 22, 2024

New

  • Adds GPCCA::get_tsi to compute terminal state identification (TSI).
  • Adds GPPCA::get_tsi_score to compute TSI score.
  • Adds GPCCA::plot_tsi to visualize TSI.

Closes

Closes #1165.

@WeilerP WeilerP requested a review from michalk8 February 22, 2024 10:59
@WeilerP
Copy link
Member Author

WeilerP commented Feb 22, 2024

What do you think, @michalk8?

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 83.09859% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 80.69%. Comparing base (721c59f) to head (6b67f4c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1166      +/-   ##
==========================================
+ Coverage   80.55%   80.69%   +0.13%     
==========================================
  Files          51       51              
  Lines        8496     8566      +70     
  Branches     2221     2234      +13     
==========================================
+ Hits         6844     6912      +68     
+ Misses       1107     1102       -5     
- Partials      545      552       +7     
Files Coverage Δ
src/cellrank/estimators/terminal_states/_gpcca.py 78.76% <83.09%> (+0.54%) ⬆️

... and 2 files with indirect coverage changes

@WeilerP WeilerP mentioned this pull request Feb 23, 2024
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@michalk8 michalk8 left a comment

Choose a reason for hiding this comment

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

Also please add tests.

Adds function for computing terminal state identification.
Add class method to compute TSI score.
Add class method to plot terminal state identification.
* Iterate through macrostates in decreasing order to compute Schur
decomposition only once.
* Access macrostates via attribute `macrostates`.
* Allow passing keyword arguments to `compute_macrostates`.
* Simplify value assignment for an optimal identification.
* Update docstrings
* Update default values of `x_offset` and `y_offset` and update type
hints.
* Rename argument `fname` to `save`.
* Add arguments `figsize` and `dpi`.
* Update docstrings.
* Update figure setup.
* Fix x-axis labels caused by latest changes to `get_tsi`.
* Use `save_fig` function.
* Return matplotlib `Figure` and `Axis` instances.
@WeilerP
Copy link
Member Author

WeilerP commented Feb 29, 2024

@michalk8, can you have another look, please? Once the code is fine, I'll add unit tests.

src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
WeilerP added 7 commits March 1, 2024 08:25
Rename columns from "Number of macrostates" to
"number_of_macrostates", "Identified terminal
states" to "identified_terminal_states",
"Optimal identification" to "optimal
identification".
Update column names in plotting DataFrame from
"Method" to "method".
Rename attribute to `_tsi` and define it in `__init__`.
* Rename method to `tsi`.
* Refactor `tsi` to return TSI score.
* TSI is only computed if it has not been computed before, the number
of macrostates is larger than previously considered, a new set of
terminal states or cluster key is used.
* Add argument `n_macrostates`.
* Remove argument `tsi_df` and use class attribute directly instead.
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
src/cellrank/estimators/terminal_states/_gpcca.py Outdated Show resolved Hide resolved
WeilerP added 2 commits March 1, 2024 14:02
* Update docs.
* Update docstrings.
* Update `RuntimeError` message
* Update return statement; only `ax` is removed.
Copy link
Collaborator

@michalk8 michalk8 left a comment

Choose a reason for hiding this comment

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

Thanks a lot @WeilerP !

@WeilerP
Copy link
Member Author

WeilerP commented Mar 2, 2024

@michalk8, do you happen to know why some plotting tests fail after I've added the unit tests?

@WeilerP WeilerP merged commit f5a9566 into theislab:main Mar 4, 2024
8 of 9 checks passed
@WeilerP WeilerP deleted the feat/tsi branch March 4, 2024 08:05
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 terminal state identification score
2 participants