Skip to content

ValueError: Transition matrix is not row stochastic, 8216 rows do not sum to 1. #1192

@simonekats

Description

@simonekats

...

Computing transition matrix based on pseudotime
100%|████████████████████████████████| 48370/48370 [00:03<00:00, 12904.07cell/s]
WARNING: Biased k-NN graph is disconnected

ValueError Traceback (most recent call last)
Cell In[133], line 1
----> 1 pk.compute_transition_matrix()

File ~/anaconda3/lib/python3.10/site-packages/cellrank/kernels/_pseudotime_kernel.py:173, in PseudotimeKernel.compute_transition_matrix(self, threshold_scheme, frac_to_keep, b, nu, check_irreducibility, n_jobs, backend, show_progress_bar, **kwargs)
170 if check_irreducibility and not _irreducible(biased_conn):
171 logg.warning("Biased k-NN graph is not irreducible")
--> 173 self.transition_matrix = biased_conn
174 logg.info(" Finish", time=start)
176 return self

File ~/anaconda3/lib/python3.10/site-packages/cellrank/kernels/_base_kernel.py:720, in Kernel.transition_matrix(self, matrix)
718 @transition_matrix.setter
719 def transition_matrix(self, matrix: Any) -> None:
--> 720 KernelExpression.transition_matrix.fset(self, matrix)

File ~/anaconda3/lib/python3.10/site-packages/cellrank/kernels/_base_kernel.py:433, in KernelExpression.transition_matrix(self, matrix)
431 if should_norm(matrix): # some rows are all 0s/contain invalid values
432 n_inv = np.sum(~np.isclose(np.asarray(matrix.sum(1)).squeeze(), 1.0, rtol=1e-12))
--> 433 raise ValueError(f"Transition matrix is not row stochastic, {n_inv} rows do not sum to 1.")
434 # fmt: on
436 self._transition_matrix = matrix

ValueError: Transition matrix is not row stochastic, 8216 rows do not sum to 1.

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