From 543c0593f255e477742a0191e2cd73b007df0ac7 Mon Sep 17 00:00:00 2001 From: ChuanXu1 Date: Wed, 1 Nov 2023 10:55:55 +0000 Subject: [PATCH] Force idxmax result to be non-categorical #96 --- celltypist/classifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/celltypist/classifier.py b/celltypist/classifier.py index 2e353dc..1f43ada 100644 --- a/celltypist/classifier.py +++ b/celltypist/classifier.py @@ -468,7 +468,7 @@ def majority_vote(predictions: AnnotationResult, over_clustering: Union[list, tu over_clustering = np.array(over_clustering) logger.info("🗳️ Majority voting the predictions") votes = pd.crosstab(predictions.predicted_labels['predicted_labels'], over_clustering) - majority = votes.idxmax(axis=0) + majority = votes.idxmax(axis=0).astype(str) freqs = (votes / votes.sum(axis=0).values).max(axis=0) majority[freqs < min_prop] = 'Heterogeneous' majority = majority[over_clustering].reset_index()