From ddbd62a2eb683df49f11926d67fe9b1da6486c28 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 29 Jun 2021 13:53:28 +0200 Subject: [PATCH] Move check for matrix NaN values from matrix to tree module --- kissim/comparison/matrix.py | 7 ------- kissim/comparison/tree.py | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kissim/comparison/matrix.py b/kissim/comparison/matrix.py index 0fc83746..079ff81b 100644 --- a/kissim/comparison/matrix.py +++ b/kissim/comparison/matrix.py @@ -100,13 +100,6 @@ def kinase_distance_matrix( if fill_diagonal: np.fill_diagonal(matrix.values, 0) - # If matrix contains missing values, respective rows and columns must be dropped - column_has_missing_values = matrix.isna().any() - column_names_with_missing_values = column_has_missing_values[column_has_missing_values].index - matrix = matrix.drop(column_names_with_missing_values, axis=0).drop( - column_names_with_missing_values, axis=1 - ) - # If matrix contains number of structure pairs: NaN > 0, cast to int if by == "size": matrix = matrix.astype("int64") diff --git a/kissim/comparison/tree.py b/kissim/comparison/tree.py index 6c4ef850..b358bec8 100644 --- a/kissim/comparison/tree.py +++ b/kissim/comparison/tree.py @@ -122,6 +122,13 @@ def from_distance_matrix( # Curate diagonal - set to 0 np.fill_diagonal(distance_matrix.values, 0) + # If matrix contains missing values, respective rows and columns must be dropped + column_has_missing_values = distance_matrix.isna().any() + column_names_with_missing_values = column_has_missing_values[column_has_missing_values].index + distance_matrix = distance_matrix.drop(column_names_with_missing_values, axis=0).drop( + column_names_with_missing_values, axis=1 + ) + # Hierarchical clustering logger.info( f"Clustering (method: {clustering_method}) and "