From 00ed89979117bf9c08ff1dc0fe2f30a4a9869e18 Mon Sep 17 00:00:00 2001 From: sichao Date: Mon, 1 May 2023 15:50:09 -0400 Subject: [PATCH 1/2] fix the bug of pca mean not saving --- dynamo/preprocessing/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dynamo/preprocessing/utils.py b/dynamo/preprocessing/utils.py index 5e04a5b1b..64e2d0214 100755 --- a/dynamo/preprocessing/utils.py +++ b/dynamo/preprocessing/utils.py @@ -864,6 +864,7 @@ def rmatmat(x): random_state=random_state, ) X_pca = result_dict["X_pca"] + fit.mean_ = mean.A1.flatten() fit.components_ = result_dict["components_"] fit.explained_variance_ratio_ = result_dict[ "explained_variance_ratio_"] From d6d6f9754f63f63a6f45194e573c7ac6ea38e64e Mon Sep 17 00:00:00 2001 From: sichao Date: Mon, 1 May 2023 18:37:54 -0400 Subject: [PATCH 2/2] setup pca mean for TruncatedSVD --- dynamo/preprocessing/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynamo/preprocessing/utils.py b/dynamo/preprocessing/utils.py index 64e2d0214..d5de6e718 100755 --- a/dynamo/preprocessing/utils.py +++ b/dynamo/preprocessing/utils.py @@ -1047,7 +1047,7 @@ def pca( adata.uns[pcs_key] = fit.components_.T[:, 1:] adata.uns[ "explained_variance_ratio_"] = fit.explained_variance_ratio_[1:] - adata.uns["pca_mean"] = fit.mean_ if hasattr(fit, "mean_") else None + adata.uns["pca_mean"] = fit.mean_ if hasattr(fit, "mean_") else np.zeros(X_data.shape[1]) if return_all: return adata, fit, X_pca