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

Fix/tsi unsetting #1174

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cellrank/estimators/terminal_states/_gpcca.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def tsi(
cluster_key: Optional[str] = None,
**kwargs: Any,
) -> float:
"""Compute terminal state identificiation (TSI) score.
"""Compute terminal state identification (TSI) score.

Parameters
----------
Expand Down Expand Up @@ -573,10 +573,13 @@ def tsi(
if cluster_key is None:
raise RuntimeError("`cluster_key` needs to be specified to compute TSI.")

# create a new GPCCA object to avoid unsetting attributes
# that depend on the macrostates, e.g. the terminal states
g = self.copy(deep=True)
macrostates = {}
for n_states in range(n_macrostates, 0, -1):
self.compute_macrostates(n_states=n_states, cluster_key=cluster_key, **kwargs)
macrostates[n_states] = self.macrostates.cat.categories
g = g.compute_macrostates(n_states=n_states, cluster_key=cluster_key, **kwargs)
macrostates[n_states] = g.macrostates.cat.categories

max_terminal_states = len(terminal_states)

Expand Down
1 change: 0 additions & 1 deletion tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,6 @@ def test_scvelo_transition_matrix_projection(self, mc: GPCCA, fpath: str):

@compare(kind="gpcca")
def test_plot_tsi(self, mc: GPCCA, fpath: str):
mc = mc.copy(deep=True)
terminal_states = ["Neuroblast", "Astrocyte", "Granule mature"]
cluster_key = "clusters"
_ = mc.tsi(n_macrostates=3, terminal_states=terminal_states, cluster_key=cluster_key, n_cells=10)
Expand Down
Loading