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

Cannot retrieve progeny weights for mouse: url for homologene needs to be updated #278

Open
ruhisayana opened this issue Feb 5, 2024 · 4 comments
Assignees
Labels
bug Problem in the code

Comments

@ruhisayana
Copy link

ruhisayana commented Feb 5, 2024

Describe the bug
UPDATE:
The main issue seems to be that the url for homologene is inactive - would it be possible for this to be updated?
Original:
I'm trying to run progeny = dc.get_progeny(organism = 'Mus musculus', top=500) in Python 3.9 with decoupler-py 1.5 and pypath-omnipath version 0.16.4. I'm getting a modulenotfound error for pypath-omnipath even though I've installed via pip install git+https://github.com/saezlab/pypath.git and it shows up when I run pip show pypath-omnipath. The command works fine when I don't use organism='Mus musculus' or organism='mouse' and seems to be related to both not being able to import homology and the translate_net function.

To Reproduce
Steps to reproduce the behavior:

  1. Run progeny = dc.get_progeny(organism = 'Mus musculus', top=500) or progeny = dc.get_progeny(organism = 'mouse', top=500)

Expected behavior
Expected to get progeny annotation. Command works when I run progeny = dc.get_progeny(top=500), so for human.

Traceback (UPDATED)
TypeError Traceback (most recent call last)
Cell In[2], line 5
3 sys.path.insert(0, "~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath")
4 print(sys.path)
----> 5 progeny = dc.get_progeny(organism='mouse',top=500)

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/decoupler/omnip.py:160, in get_progeny(organism, top, **kwargs)
156 p.columns = ['source', 'target', 'weight', 'p_value']
158 if not _is_human(organism):
--> 160 p = translate_net(
161 p,
162 columns='target',
163 source_organism=9606,
164 target_organism=organism,
165 )
167 return p.reset_index(drop=True)

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/decoupler/omnip.py:587, in translate_net(net, columns, source_organism, target_organism, id_type, unique_by, **kwargs)
584 hom_net = net.copy()
586 # Translate
--> 587 hom_net = homology.translate_df(
588 df=hom_net,
589 target=_target_organism,
590 cols=columns,
591 source=_source_organism,
592 )
594 unique_by = common.to_list(unique_by)
596 if unique_by and all(c in hom_net.columns for c in unique_by):
597
598 # Remove duplicated based on source and target

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:1904, in translate_df(df, target, cols, source, homologene, ensembl, ensembl_hc, ensembl_types, **kwargs)
1901 args.pop('manager')
1902 kwargs = args.pop('kwargs')
-> 1904 return manager.translate_df(**args, **kwargs)

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:483, in HomologyManager.translate_df(self, df, target, cols, source, homologene, ensembl, ensembl_hc, ensembl_types, **kwargs)
480 source = taxonomy.ensure_ncbi_tax_id(source)
481 target = taxonomy.ensure_ncbi_tax_id(target)
--> 483 table = self.which_table(
484 target = target,
485 source = source,
486 )
488 param = self._translation_param(locals())
490 return table.translate_df(
491 df = df,
492 cols = cols,
(...)
495 **kwargs
496 )

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:184, in HomologyManager.which_table(self, target, source, only_swissprot)
180 self.expiry[key] = time.time()
182 if key not in self.tables:
--> 184 self.load(key)
186 if key in self.tables:
188 return self.tables[key]

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:215, in HomologyManager.load(self, key)
208 self._log(
209 'Homology table from taxon %u to %u (only SwissProt: %s) '
210 'has been loaded from %s.' % (key + (cachefile,))
211 )
213 else:
--> 215 self.tables[key] = self._load(key)
216 pickle.dump(self.tables[key], open(cachefile, 'wb'))
217 self._log(
218 'Homology table from taxon %u to %u (only SwissProt: %s) '
219 'has been saved to %s.' % (key + (cachefile,))
220 )

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:225, in HomologyManager._load(self, key)
223 def _load(self, key):
--> 225 return ProteinHomology(
226 target = key[1],
227 source = key[0],
228 only_swissprot = key[2],
229 homologene = self.homologene,
230 ensembl = self.ensembl,
231 ensembl_hc = self.ensembl_hc,
232 ensembl_types = self.ensembl_types,
233 )

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:718, in ProteinHomology.init(self, target, source, only_swissprot, homologene, ensembl, ensembl_hc, ensembl_types)
714 self.load_proteome(self.target, self.only_swissprot)
716 if source is not None:
--> 718 self.load(source)

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:734, in ProteinHomology.load(self, source)
730 def load(self, source = None):
732 if self.homologene:
--> 734 self.load_homologene(source)
736 if self.ensembl:
738 self.load_ensembl(source)

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/utils/homology.py:1175, in ProteinHomology.load_homologene(self, source)
1171 if source not in self.orthologs:
1173 self.orthologs[source] = collections.defaultdict(set)
-> 1175 hge = homologene_input.homologene_dict(source, self.target, 'entrez')
1176 hgr = homologene_input.homologene_dict(source, self.target, 'refseq')
1178 self.load_proteome(source, self.only_swissprot)

File ~/opt/miniconda3/envs/py39/lib/python3.9/site-packages/pypath/inputs/homologene.py:95, in homologene_dict(source, target, id_type)
92 hgroup = None
93 result = collections.defaultdict(set)
---> 95 for l in hg:
97 l = l.strip().split('\t')
98 this_hgroup = l[0].strip()

TypeError: 'NoneType' object is not iterable
Log file
n/a

Desktop (please complete the following information):

  • OS: Mac0S
  • Python version: 3.9
  • Version or commit hash: 0.15.4 (changed from pypath-omnipath v0.16.4 since simple homology import did not work)
@ruhisayana ruhisayana added the bug Problem in the code label Feb 5, 2024
@ruhisayana ruhisayana changed the title Cannot retrieve progeny weights for mouse with dc.get_progeny Cannot retrieve progeny weights for mouse: url for homologene needs to be updated Feb 5, 2024
@deeenes deeenes self-assigned this Feb 5, 2024
@deeenes
Copy link
Member

deeenes commented Feb 5, 2024

Hello @ruhisayana ,

Thanks for reporting this! I'll check the HomoloGene URL soon, however, we've recently transitioned to OMA (orthologous Matrix) as the default resource for orthology data. And I think since then, using the release that I've just published today, it should work fine. I've just tested PROGENy access (by decoupler.get_progeny(organism = 'mouse')) right now, and it worked. Let me know if you still experience issues.

Best,

Denes

@haleymac
Copy link

haleymac commented Feb 26, 2024

Hi,

I'm having a similar issue when trying to run progeny = dc.get_progeny(organism = 'mouse', top=500) with pypath-omnipath version 0.16.9 and decoupler version 1.6.0. I have also installed via pip install git+https://github.com/saezlab/pypath.git and it shows up when I run pip show pypath-omnipath, but am getting an import error when I try to run dc.get_progeny with mouse (it works fine with human). Any help you can provide would be much appreciated.

Traceback: ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File [~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:648](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:648), in translate_net(net, columns, source_organism, target_organism, id_type, unique_by, **kwargs)
    [647](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:647) import pypath
--> [648](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:648) from pypath.utils import orthology
    [649](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:649) from pypath.share import common

File [~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/orthology.py:45](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/orthology.py:45)
     [43](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/orthology.py:43) import pandas as pd
---> [45](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/orthology.py:45) import pypath.utils.mapping as mapping
     [46](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/orthology.py:46) import pypath.share.common as common

File [~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/mapping.py:65](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/mapping.py:65)
     [64](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/mapping.py:64) import pypath.share.cache as cache_mod
---> [65](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/mapping.py:65) import pypath.internals.maps as maps
     [66](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/utils/mapping.py:66) import pypath.resources.urls as urls

File [~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/maps.py:24](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/maps.py:24)
     [23](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/maps.py:23) import pypath_common._constants as _const
---> [24](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/maps.py:24) import pypath.internals.input_formats as input_formats
     [26](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/maps.py:26) __all__ = ['uniprot', 'mirbase', 'basic']

File [~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/input_formats.py:27](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/input_formats.py:27)
     [26](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/input_formats.py:26) import pypath_common._constants as _const
---> [27](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/pypath/internals/input_formats.py:27) import pypath.inputs.uniprot as uniprot_input
...
--> [671](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:671)     raise ImportError(msg)
    [673](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:673) _source_organism = taxonomy.ensure_ncbi_tax_id(source_organism)
    [674](https://file+.vscode-resource.vscode-cdn.net/Users/haleymacdonald/Desktop/msc/scanpy/RamDA/~/miniconda3/envs/countanal/lib/python3.10/site-packages/decoupler/omnip.py:674) _target_organism = taxonomy.ensure_ncbi_tax_id(target_organism)

ImportError: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git

@deeenes
Copy link
Member

deeenes commented Feb 26, 2024

Hi @haleymac,

Yours looks like a different issue. I was unable to reproduce it with the latest versions of decoupler-py and pypath-omnipath. Can you show us the pypath log after this error happens?

import decoupler as dc

pr_mouse = dc.get_progeny(organism = 'mouse')

The error happens here, then check the log:

import pypath
pypath.log()
# or to open the log elsewhere:
pypath.session._logger.fname

Also, you can check directly if any of these fail with error:

import pypath
from pypath.utils import orthology
from pypath.share import common
from pypath.utils import taxonomy

Best,

Denes

@deeenes
Copy link
Member

deeenes commented Feb 26, 2024

Btw, since c257159 HomoloGene access should be fine too (though it shouldn't affect decoupler any more)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Problem in the code
Projects
None yet
Development

No branches or pull requests

3 participants