From 6225facb68256b4948cc3cb8c9709444e1aef515 Mon Sep 17 00:00:00 2001 From: Yuki SUYAMA Date: Fri, 22 Dec 2023 15:18:32 +0900 Subject: [PATCH] Fixed to run prerank without error with rnk (type(pd.Series.name) == str) --- gseapy/base.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gseapy/base.py b/gseapy/base.py index c2efa60..96312aa 100644 --- a/gseapy/base.py +++ b/gseapy/base.py @@ -183,11 +183,15 @@ def _load_data(self, exprs: Union[str, pd.Series, pd.DataFrame]) -> pd.DataFrame elif isinstance(exprs, pd.Series): # change to DataFrame self._logger.debug("Input data is a Series with gene names") - if exprs.name is None: - # rename col if name attr is none - exprs.name = "sample1" - elif exprs.name.dtype != "O": - exprs.name = exprs.name.astype(str) + if not isinstance(exprs.name, str): + if exprs.name is None: + # rename col if name attr is none + exprs.name = "sample1" + elif hasattr(exprs.name, "dtype"): + if exprs.name.dtype != "O": + exprs.name = exprs.name.astype(str) + else: + exprs.name = str(exprs.name) rank_metric = exprs.reset_index() elif os.path.isfile(exprs): rank_metric = self._read_file(exprs)