From b9a659315885bc8814a87cd8e2647025c05cd7de Mon Sep 17 00:00:00 2001 From: gwaygenomics Date: Thu, 18 Feb 2021 14:41:18 -0500 Subject: [PATCH 1/2] add euclidean distance option availability --- cytominer_eval/transform/transform.py | 7 ++++++- cytominer_eval/transform/util.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cytominer_eval/transform/transform.py b/cytominer_eval/transform/transform.py index 5b54081..031b165 100644 --- a/cytominer_eval/transform/transform.py +++ b/cytominer_eval/transform/transform.py @@ -1,5 +1,7 @@ import numpy as np import pandas as pd +from sklearn.metrics.pairwise import euclidean_distances + from typing import List from .util import ( @@ -23,7 +25,10 @@ def get_pairwise_metric(df: pd.DataFrame, similarity_metric: str) -> pd.DataFram m=similarity_metric, avail=available_pairwise_similarity_metrics ) - pair_df = df.transpose().corr(method=similarity_metric) + if similarity_metric == "euclidean": + pair_df = pd.DataFrame(euclidean_distances(df)) + else: + pair_df = df.transpose().corr(method=similarity_metric) # Check if the metric calculation went wrong # (Current pandas version makes this check redundant) diff --git a/cytominer_eval/transform/util.py b/cytominer_eval/transform/util.py index fbf2fda..bb074e8 100644 --- a/cytominer_eval/transform/util.py +++ b/cytominer_eval/transform/util.py @@ -14,7 +14,7 @@ def get_available_similarity_metrics(): r"""Output the available metrics for calculating pairwise similarity in the cytominer_eval library """ - return ["pearson", "kendall", "spearman"] + return ["pearson", "kendall", "spearman", "euclidean"] def get_available_grit_summary_methods(): From b141f6856e92b4ca79ff1bae6abd4a9ec9c7b670 Mon Sep 17 00:00:00 2001 From: gwaygenomics Date: Wed, 19 May 2021 15:00:05 -0400 Subject: [PATCH 2/2] add euclidean as a pairwise option --- cytominer_eval/utils/availability_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cytominer_eval/utils/availability_utils.py b/cytominer_eval/utils/availability_utils.py index d8f0d7f..cf75f4f 100644 --- a/cytominer_eval/utils/availability_utils.py +++ b/cytominer_eval/utils/availability_utils.py @@ -13,7 +13,7 @@ def get_available_similarity_metrics(): r"""Output the available metrics for calculating pairwise similarity in the cytominer_eval library """ - return ["pearson", "kendall", "spearman"] + return ["pearson", "kendall", "spearman", "euclidean"] def get_available_grit_summary_methods():