From 7d5dd11eefdd28077aba88204423c817ed529e46 Mon Sep 17 00:00:00 2001 From: zqfang Date: Wed, 28 Feb 2024 11:18:00 -0800 Subject: [PATCH] fixed duplicated IDs, #251 --- gseapy/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gseapy/base.py b/gseapy/base.py index 9622499..158dd33 100644 --- a/gseapy/base.py +++ b/gseapy/base.py @@ -240,7 +240,7 @@ def _check_data(self, exprs: pd.DataFrame) -> pd.DataFrame: def make_unique(self, rank_metric: pd.DataFrame, col_idx: int) -> pd.DataFrame: """ - make gene id column unique + make gene id column unique by adding a digit, similar to R's make.unique """ id_col = rank_metric.columns[col_idx] if rank_metric.duplicated(subset=id_col).sum() > 0: @@ -248,6 +248,7 @@ def make_unique(self, rank_metric: pd.DataFrame, col_idx: int) -> pd.DataFrame: mask = rank_metric.duplicated(subset=id_col, keep=False) dups = ( rank_metric.loc[mask, id_col] + .to_frame() .groupby(id_col) .cumcount() .map(lambda c: "_" + str(c) if c else "")