Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing with 1.1.5 - empty gene list not excluded #303

Open
enryH opened this issue Feb 13, 2025 · 5 comments
Open

Failing with 1.1.5 - empty gene list not excluded #303

enryH opened this issue Feb 13, 2025 · 5 comments

Comments

@enryH
Copy link

enryH commented Feb 13, 2025

Setup

I am reporting a problem with GSEApy version, Python version, and operating
system as follows:

import sys; print(sys.version)
import platform; print(platform.python_implementation()); print(platform.platform())
import gseapy; print(gseapy.__version__)

1.1.5

Expected behaviour

  • return results

Actual behaviour

somehow the gene list is empty and then a devision by zero happend. It was introduced with 1.1.5, 1.1.4 does still work.

Steps to reproduce

[/usr/local/lib/python3.11/dist-packages/gseapy/__init__.py](https://localhost:8080/#) in ssgsea(data, gene_sets, outdir, sample_norm_method, correl_norm_type, min_size, max_size, permutation_num, weight, ascending, threads, figsize, format, graph_num, no_plot, seed, verbose, *args, **kwargs)
    289         verbose=verbose,
    290     )
--> 291     ss.run()
    292     return ss
    293 

[/usr/local/lib/python3.11/dist-packages/gseapy/ssgsea.py](https://localhost:8080/#) in run(self)
    129         # filtering out gene sets and build gene sets dictionary
    130         self._gene_isupper = self.check_uppercase(gene_list=normdat.index.values)
--> 131         gmt = self.load_gmt(gene_list=normdat.index.values, gmt=self.gene_sets)
    132         self.gmt = gmt
    133         self._logger.info(

[/usr/local/lib/python3.11/dist-packages/gseapy/base.py](https://localhost:8080/#) in load_gmt(self, gene_list, gmt)
    332         ups = []
    333         for s in subsets[:20]:
--> 334             ups.append(self.check_uppercase(genesets_dict[s]))
    335 
    336         if (not self._gene_isupper) and all(ups):

[/usr/local/lib/python3.11/dist-packages/gseapy/base.py](https://localhost:8080/#) in check_uppercase(self, gene_list)
    255         """
    256         is_upper = [s.isupper() for s in gene_list]
--> 257         if sum(is_upper) / len(is_upper) >= 0.9:
    258             return True
    259         return False

ZeroDivisionError: division by zero

you can run this notebook until the error. link

zqfang pushed a commit that referenced this issue Feb 13, 2025
@zqfang
Copy link
Owner

zqfang commented Feb 13, 2025

good catch. the v1.1.5 start to try to convert gene symbols to uppercase if not matched with GMT input. now is fixed

zqfang pushed a commit that referenced this issue Feb 13, 2025
@enryH
Copy link
Author

enryH commented Feb 14, 2025

thanks. And great you keep the library alive. But then it will still throw an ValueError. So how is it possible to run into that issue? Or do you catch the ValueError upstream?

@zqfang
Copy link
Owner

zqfang commented Feb 14, 2025

Yes. Can you show me the error message? I added a sanity check for the input GMT file.Yes. can you show me the error mesasge? I added a santi check for the input GMT file

@pcahan1
Copy link

pcahan1 commented Feb 19, 2025

prerank in v1.1.5 throws an error related to this issue (I think) but rolling back to v1.1.4 fixes it:

gp.prerank(
^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/scn3/lib/python3.12/site-packages/gseapy/init.py", line 396, in prerank
pre.run()
File "/opt/homebrew/Caskroom/miniforge/base/envs/scn3/lib/python3.12/site-packages/gseapy/gsea.py", line 559, in run
self._gene_isupper = self.check_uppercase(gene_list=dat2.index.values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/scn3/lib/python3.12/site-packages/gseapy/base.py", line 256, in check_uppercase
is_upper = [s.isupper() for s in gene_list]
^^^^^^^^^
AttributeError: 'numpy.int64' object has no attribute 'isupper'

@zqfang
Copy link
Owner

zqfang commented Feb 19, 2025

I'll relase a new bug fix version soon to re-solved this. Thanks

zqfang pushed a commit that referenced this issue Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants