Skip to content

RealTimeKernel does not recompute transition matrix #1271

@WeilerP

Description

@WeilerP

After computing the transition matrix with the RealTimeKernel, the kernel does not recompute it when changing conn_weight. I suspect the issue is that tmk._params only contains self_transitions and threshold, so the kernel uses the already computed/cached transition matrix automatically.

# Compute transition matrix with different values for the `conn_weight` parameter
tmk = RealTimeKernel.from_moscot(tp)
tmk.compute_transition_matrix(self_transitions="all", conn_weight=0.2, threshold="auto")
old = tmk.transition_matrix.data.copy()

tmk.compute_transition_matrix(self_transitions="all", conn_weight=0.5, threshold="auto")

# Incorrectly asserts to True
np.testing.assert_almost_equal(old, tmk.transition_matrix.data)

# Compute transition matrix with different value for `conn_weight` using a separate kernel
tmk = RealTimeKernel.from_moscot(tp)
tmk.compute_transition_matrix(self_transitions="all", conn_weight=0.2, threshold="auto")

tmk_2 = RealTimeKernel.from_moscot(tp)
tmk_2.compute_transition_matrix(self_transitions="all", conn_weight=0.5, threshold="auto")

# Correctly asserts false
np.testing.assert_almost_equal(tmk.transition_matrix.data, tmk_2.transition_matrix.data)

# Compute transition matrix with same kernel object, but different values for the `conn_weight` parameter and set `conn_weight` in `_params` attribute
tmk = RealTimeKernel.from_moscot(tp)
tmk.compute_transition_matrix(self_transitions="all", conn_weight=0.2, threshold="auto")
tmk._params["conn_weight"] = 0.2
old = tmk.transition_matrix.data.copy()

tmk.compute_transition_matrix(self_transitions="all", conn_weight=0.5, threshold="auto")
#  Correctly asserts false
np.testing.assert_almost_equal(old, tmk.transition_matrix.data)

Versions:

cellrank==2.0.7 scanpy==1.11.4 anndata==0.12.2 numpy==2.2.6 numba==0.61.2 scipy==1.16.2 pandas==2.3.2 pygpcca==1.0.4 scikit-learn==1.7.2 statsmodels==0.14.5 scvelo==0.3.3 pygam==0.9.1 matplotlib==3.10.6 seaborn==0.13.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions