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

How to get lead genes from ssGSEA object #229

Open
Num0Programmer opened this issue Oct 24, 2023 · 1 comment
Open

How to get lead genes from ssGSEA object #229

Num0Programmer opened this issue Oct 24, 2023 · 1 comment

Comments

@Num0Programmer
Copy link

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__)
3.8.17 | packaged by conda-forge | (default, Jun 16 2023, 07:11:34)
[Clang 14.0.6 ]
CPython
macOS-10.16-x86_64-i386-64bit
1.0.6

Expected behaviour

import gseapy as gp

res = gp.ssgsea(...)

print(f"Lead genes:\n{res.res2d['Lead_genes']}")
Lead genes:
<lead_genes>

I should be able to see a the lead genes printed to my console, or in a file if I did something like the following:

import gseapy as gp

res = gp.ssgsea(...)

res.res2d["Lead_genes"].to_csv("lead_genes.tsv", sep="\t", index=False)

Actual behaviour

Python throws a KeyError:

Traceback (most recent call last):
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3802, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Lead_genes'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/q2cli/commands.py", line 478, in __call__
    results = self._execute_action(
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/q2cli/commands.py", line 544, in _execute_action
    results = action(**arguments)
  File "<decorator-gen-810>", line 2, in make_psea_table
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/qiime2/sdk/action.py", line 342, in bound_callable
    outputs = self._callable_executor_(
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/qiime2/sdk/action.py", line 647, in _callable_executor_
    outputs = self._callable(scope.ctx, **view_args)
  File "/Users/myare-large/Work/F22.047/qiime2/repos/q2-PSEA/q2_PSEA/actions/psea.py", line 80, in make_psea_table
    print(f"Lead genes: {table.res2d['Lead_genes']}")
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/pandas/core/frame.py", line 3807, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/Users/myare-large/miniconda3/envs/qiime2-2023.7/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3804, in get_loc
    raise KeyError(key) from err
KeyError: 'Lead_genes'

Steps to reproduce

With any example data, call ssgsea() and try to access the "Lead_genes" column in one of the ways I described for expected behaviour.

@zqfang
Copy link
Owner

zqfang commented Oct 24, 2023

Since the ssGSEA method will sum all values in the random walk statistic, there are no leading genes you can get.

while leading genes fit the GSEA algorithm because it takes the peak of the random walk statistic.

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

2 participants