cellrank: Terminal states D-orthogonality error
We have briefly discussed this error before and from what I got, this should be about to be fixed anyways. I just wanted to leave this here for tracking and maybe to get a time estimate from you guys when you think this would be fixed? Thanks a lot!
cr.tl.terminal_states(adata, cluster_key='louvain_separate_fine', n_states=None, weight_connectivities=0.2)
[[ 1.00000000e+00 -2.04305480e-03 1.71689486e-13]
[-2.04305480e-03 1.00000000e+00 1.76311602e-16]
[ 1.71687968e-13 1.76555548e-16 1.00000000e+00]]
WARNING: Using `3` components would split a block of complex conjugates. Increasing `n_components` to `4`
[[ 1.00000000e+00 -2.04305480e-03 1.01769287e-13 3.91856686e-14]
[-2.04305480e-03 1.00000000e+00 -3.79125171e-16 3.71041088e-16]
[ 1.01772757e-13 -3.79064185e-16 1.00000000e+00 -4.63171168e-16]
[ 3.91856686e-14 3.70986878e-16 -4.61436445e-16 1.00000000e+00]]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/opt/python/lib/python3.8/site-packages/cellrank/tl/estimators/_decomposition.py in compute_schur(self, n_components, initial_distribution, method, which, alpha)
447 try:
--> 448 self._gpcca._do_schur_helper(n_components)
449 except ValueError:
/opt/python/lib/python3.8/site-packages/cellrank/_vendor/msmtools/analysis/dense/gpcca.py in _do_schur_helper(self, m)
1080 else:
-> 1081 self.X, self.R, self.eigenvalues = _do_schur(self.P.copy(), self.eta, m, self.z, self.method)
1082
/opt/python/lib/python3.8/site-packages/cellrank/_vendor/msmtools/analysis/dense/gpcca.py in _do_schur(P, eta, m, z, method, tol_krylov)
257 print(X.T.dot(X*eta[:, None]))
--> 258 raise ValueError("Schur vectors appear to not be D-orthogonal.")
259
ValueError: Schur vectors appear to not be D-orthogonal.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-18-e6c35a0187c4> in <module>
----> 1 cr.tl.terminal_states(adata, cluster_key='louvain_separate_fine', n_states=None, weight_connectivities=0.2)
2 cr.pl.terminal_states(adata, discrete=True)
/opt/python/lib/python3.8/site-packages/cellrank/tl/_init_term_states.py in terminal_states(adata, estimator, mode, n_states, cluster_key, key, show_plots, copy, return_estimator, fit_kwargs, **kwargs)
216 ) -> Optional[AnnData]: # noqa
217
--> 218 return _initial_terminal(
219 adata,
220 estimator=estimator,
/opt/python/lib/python3.8/site-packages/cellrank/tl/_init_term_states.py in _initial_terminal(adata, estimator, backward, mode, backward_mode, n_states, cluster_key, key, show_plots, copy, return_estimator, fit_kwargs, **kwargs)
127 )
128
--> 129 mc.fit(
130 n_lineages=n_states,
131 cluster_key=cluster_key,
/opt/python/lib/python3.8/site-packages/cellrank/tl/estimators/_gppca.py in fit(self, n_lineages, cluster_key, keys, method, compute_absorption_probabilities, **kwargs)
1081 """
1082
-> 1083 super().fit(
1084 n_lineages=n_lineages,
1085 cluster_key=cluster_key,
/opt/python/lib/python3.8/site-packages/cellrank/tl/estimators/_base_estimator.py in fit(self, keys, compute_absorption_probabilities, **kwargs)
983 - :paramref:`{dp}`
984 """
--> 985 self._fit_terminal_states(**kwargs)
986 if compute_absorption_probabilities:
987 self.compute_absorption_probabilities(keys=keys)
/opt/python/lib/python3.8/site-packages/cellrank/tl/estimators/_gppca.py in _fit_terminal_states(self, n_lineages, cluster_key, method, **kwargs)
996
997 if n_lineages > 1:
--> 998 self.compute_schur(n_lineages + 1, method=method)
999
1000 try:
/opt/python/lib/python3.8/site-packages/cellrank/tl/estimators/_decomposition.py in compute_schur(self, n_components, initial_distribution, method, which, alpha)
452 f"Increasing `n_components` to `{n_components + 1}`"
453 )
--> 454 self._gpcca._do_schur_helper(n_components + 1)
455
456 # make it available for pl
/opt/python/lib/python3.8/site-packages/cellrank/_vendor/msmtools/analysis/dense/gpcca.py in _do_schur_helper(self, m)
1079 print('INFO: Using pre-computed schur decomposition')
1080 else:
-> 1081 self.X, self.R, self.eigenvalues = _do_schur(self.P.copy(), self.eta, m, self.z, self.method)
1082
1083 def minChi(self, m_min, m_max):
/opt/python/lib/python3.8/site-packages/cellrank/_vendor/msmtools/analysis/dense/gpcca.py in _do_schur(P, eta, m, z, method, tol_krylov)
256 if not np.allclose(X.T.dot(X*eta[:, None]), np.eye(X.shape[1]), atol=1e-6, rtol=1e-5):
257 print(X.T.dot(X*eta[:, None]))
--> 258 raise ValueError("Schur vectors appear to not be D-orthogonal.")
259
260 # Raise, if X doesn't fullfill the invariant subspace condition!
ValueError: Schur vectors appear to not be D-orthogonal.
Versions:
cellrank==1.1.0 scanpy==1.6.0 anndata==0.7.5 numpy==1.19.4 numba==0.51.2 scipy==1.5.4 pandas==1.1.4 scikit-learn==0.23.2 statsmodels==0.12.1 python-igraph==0.8.3 scvelo==0.2.2 pygam==0.8.0 matplotlib==3.3.3 seaborn==0.11.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (4 by maintainers)
@le-ander, this is finally fixed! We completely refactored one of the “engines” of CellRank, the GPCCA method and included it in a new packaged called pyGPCCA. In this context, we also resolved the
D-orthogonalitybug.