From 7ed9c19f9c7e0be4df40abab21470c09c65fb84b Mon Sep 17 00:00:00 2001 From: Sichao25 Date: Tue, 8 Aug 2023 22:06:38 -0400 Subject: [PATCH 1/3] debug transform --- dynamo/tools/cell_velocities.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dynamo/tools/cell_velocities.py b/dynamo/tools/cell_velocities.py index 511e4521b..870ffb279 100755 --- a/dynamo/tools/cell_velocities.py +++ b/dynamo/tools/cell_velocities.py @@ -562,7 +562,8 @@ def cell_velocities( else: transition_key = add_transition_key - adata.obsp[transition_key] = T + if method != "transform": + adata.obsp[transition_key] = T if add_velocity_key is None: velocity_key, grid_velocity_key = "velocity_" + basis, "grid_velocity_" + basis else: From 9ec6dc3c49c7a1e673f3e6731597462b4e12de4f Mon Sep 17 00:00:00 2001 From: Sichao25 Date: Wed, 9 Aug 2023 14:59:07 -0400 Subject: [PATCH 2/3] debug X_plus_V order --- dynamo/tools/cell_velocities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynamo/tools/cell_velocities.py b/dynamo/tools/cell_velocities.py index 870ffb279..5614dd35b 100755 --- a/dynamo/tools/cell_velocities.py +++ b/dynamo/tools/cell_velocities.py @@ -339,8 +339,8 @@ def cell_velocities( if method == "kmc" and n_pca_components is None: n_pca_components = 30 if n_pca_components is not None: - X = log1p_(adata, X) X_plus_V = log1p_(adata, X + V) + X = log1p_(adata, X) if "velocity_pca_fit" not in adata.uns_keys() or type(adata.uns["velocity_pca_fit"]) == str: pca_monocle = PCA( n_components=min(n_pca_components, X.shape[1] - 1), From 152a3ddba4b3f6c498369a3884abcc2b722b6a75 Mon Sep 17 00:00:00 2001 From: sichao Date: Fri, 29 Sep 2023 16:03:37 -0400 Subject: [PATCH 3/3] debug None input for transition matrix --- dynamo/tools/Markov.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dynamo/tools/Markov.py b/dynamo/tools/Markov.py index 20689fc39..16c0d6157 100755 --- a/dynamo/tools/Markov.py +++ b/dynamo/tools/Markov.py @@ -8,7 +8,7 @@ from sklearn.neighbors import NearestNeighbors from tqdm import tqdm -from ..dynamo_logger import LoggerManager +from ..dynamo_logger import LoggerManager, main_warning from ..simulation.utils import directMethod from .utils import append_iterative_neighbor_indices, flatten @@ -555,9 +555,12 @@ def is_normalized(self, P=None, tol=1e-3, sumto=1, axis=0, ignore_nan=True): 0 - check if the matrix is column normalized; 1 - check if the matrix is row normalized. """ - P = self.P if P is None else P - sumfunc = np.sum if not ignore_nan else np.nansum - return np.all(np.abs(sumfunc(P, axis=axis) - sumto) < tol) + if not P: + main_warning("No transition matrix input. Normalization check is skipped.") + return True + else: + sumfunc = np.sum if not ignore_nan else np.nansum + return np.all(np.abs(sumfunc(P, axis=axis) - sumto) < tol) def __reset__(self): self.D = None