saezlab / decoupler-py

Python package to perform enrichment analysis from omics data.
https://decoupler-py.readthedocs.io/
GNU General Public License v3.0
145 stars 21 forks source link

Issue with omnipath and dc.translate_net(msigdb, target_organism = 'mouse', unique_by = ('geneset', 'genesymbol')) #131

Closed dantyrr closed 1 week ago

dantyrr commented 1 month ago

Describe the bug I see this: Omnipath wrappers (get_resource, get_dorothea and get_progeny) now accept any organism name. so I tried to use this: msigdb = dc.get_resource('MSigDB', organism='Mus musculus') msigdb

I'm in a Jupyter notebook, and I get this: TypeError: object of type 'NoneType' has no len()

pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git /Users/dtyrell/rosetta2/miniconda3/envs/viaenv/lib/python3.10/site-packages/decoupler/_misc.py:22: UserWarning: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git

I've ensured that omnipath is installed:

Name: pypath-omnipath Version: 0.16.15 Summary: Molecular signaling prior knowledge processing Home-page: https://omnipathdb.org/ Author: Denes Turei Author-email: turei.denes@gmail.com License: GPL-3.0-only Location: /Users/dtyrell/rosetta2/miniconda3/envs/viaenv/lib/python3.10/site-packages Requires: beautifulsoup4, certifi, cryptography, dill, future, glom, lxml, matplotlib, numpy, openpyxl, pandas, psutil, pycurl, pypath-common, pyreadr, pysftp, PyYAML, rdata, requests, scipy, sqlparse, tabulate, timeloop, toml, tornado, tqdm, typing_extensions, xlrd

"dc.get_collectri(organism='mouse')" works just fine. "msigdb = dc.get_resource('MSigDB', organism='human')" works just fine

if I download the human MSigDB and try to convert it to mouse, I get the same error: "mouse_msigdb = dc.translate_net(msigdb, target_organism = 'mouse', unique_by = ('geneset', 'genesymbol'))" TypeError: object of type 'NoneType' has no len()

pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git /Users/dtyrell/rosetta2/miniconda3/envs/viaenv/lib/python3.10/site-packages/decoupler/_misc.py:22: UserWarning: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git

Curious if this is a known issue?

When I run this code all together: import omnipath as op

Check the version of the omnipath library

print("OmniPath version:", op.version)

msigdb = dc.get_resource('MSigDB', organism='mouse') msigdb

it confirms I have omnipath v 1.0.8

I am using: AnnData version: 0.10.5.post1 Python version: 3.10.13 (main, Sep 11 2023, 08:39:02) [Clang 14.0.6 ]

thanks for any assistance! Really love the package.

deeenes commented 1 month ago

Apparently it is indeed installed in the correct path. The exception handling can cover some errors. Try to import pypath and some submodules of it and if you see an exception, share it here:

import pypath
from pypath.utils import mapping
from pypath.utils import orthology
from pypath.internals import input_formats
maltekuehl commented 3 weeks ago

I am experiencing the same issue and it seems to be related with the function _check_if_pypath. If I remove the call to _check_if_pypath and just paste the code from translate_net directly into my code, it works as expected. My theory:

PauBadiaM commented 1 week ago

Fixed in 06bae401f234e84359c959696ac9a758d55bdbfe