saezlab / decoupler-py

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

Failed to download `CollecTRI` from OmniPath. Invalid value `loops` for `InteractionsQuery`. AttributeError: module 'omnipath' has no attribute 'static' #108

Closed clg12 closed 5 months ago

clg12 commented 6 months ago

Hello. When I run this line of code, I get the following error:

# Retrieve CollecTRI gene regulatory network
collectri = dc.get_collectri(organism='human', split_complexes=False)
collectri

WARNING:root:Traceback (most recent call last): File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py", line 523, in get_collectri ct = op.interactions.CollecTRI.get( File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_utils.py", line 114, in wrapper return wrapped(args, kwargs) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_utils.py", line 31, in _get_helper return cls()._get(kwargs) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_request.py", line 108, in _get kwargs = self._validate_params(kwargs) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_request.py", line 195, in _validate_params res[self._query_type(k).param] = self._query_type(k)(v) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/query/_query.py", line 136, in call return self.value(value) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/constants/_constants.py", line 51, in call return super().call(args, *kw) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/enum.py", line 384, in call return cls.new(cls, value) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/constants/_constants.py", line 15, in wrapper raise e File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/constants/_constants.py", line 11, in wrapper return fun(args, **kwargs) File "/home/lyt/anaconda3/envs/decoupler/lib/python3.9/enum.py", line 702, in new raise ve_exc ValueError: Invalid value loops for InteractionsQuery. Valid options are: ['database', 'databases', 'dataset', 'datasets', 'directed', 'directeds', 'dorothea_level', 'dorothea_levels', 'dorothea_method', 'dorothea_methods', 'entity_type', 'entity_types', 'field', 'fields', 'format', 'formats', 'genesymbol', 'genesymbols', 'header', 'headers', 'license', 'licenses', 'limit', 'limits', 'organism', 'organisms', 'partner', 'partners', 'password', 'passwords', 'resource', 'resources', 'signed', 'signeds', 'source_target', 'source_targets', 'source', 'sources', 'target', 'targets', 'tfregulons_level', 'tfregulons_levels', 'tfregulons_method', 'tfregulons_methods', 'type', 'types'].

WARNING:root:Failed to download CollecTRI from OmniPath. Falling back to static tables. This is not the recommended way to access OmniPath; it is only a backup plan for situations when our server or your computer is experiencing issues.See the below traceback and the omnipath log for details. /home/lyt/anaconda3/envs/decoupler/lib/python3.9/site-packages/decoupler/_misc.py:22: UserWarning: Failed to download CollecTRI from OmniPath. Falling back to static tables. This is not the recommended way to access OmniPath; it is only a backup plan for situations when our server or your computer is experiencing issues.See the below traceback and the omnipath log for details. warnings.warn(msg)

ValueError Traceback (most recent call last) File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py:523, in get_collectri(organism, split_complexes, kwargs) 522 try: --> 523 ct = op.interactions.CollecTRI.get( 524 genesymbols=True, 525 organism=_organism, 526 loops=True, 527 kwargs 528 ) 529 except Exception:

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_utils.py:114, in _inject_api_method..wrapper(wrapped, _instance, args, kwargs) 112 @wrapt.decorator(adapter=wrapt.adapter_factory(argspec_factory)) 113 def wrapper(wrapped, _instance, args, kwargs): --> 114 return wrapped(*args, **kwargs)

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_utils.py:31, in _get_helper(cls, kwargs) 18 """ 19 Perform a request to the [OmniPath]_ web service. 20 (...) 29 The result which depends the type of the request and the supplied parameters. 30 """ ---> 31 return cls()._get(kwargs)

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_request.py:108, in OmnipathRequestABC._get(self, **kwargs) 107 kwargs, callback = self._convert_params(kwargs) --> 108 kwargs = self._validate_params(kwargs) 109 kwargs = self._finalize_params(kwargs)

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/requests/_request.py:195, in OmnipathRequestABC._validate_params(self, params) 193 for k, v in params.items(): 194 # first get the validator for the parameter, then validate --> 195 res[self._query_type(k).param] = self._query_type(k)(v) 196 return res

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/_core/query/_query.py:136, in QueryType.call(self, value) 135 """%(validate)s""" # noqa: D401 --> 136 return self.value(value)

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/constants/_constants.py:51, in FormatterMeta.call(cls, *args, *kw) 47 raise TypeError( 48 f"Can't instantiate class {cls.__name__} " 49 f"without __error_format__ class attribute." 50 ) ---> 51 return super().call(args, **kw)

File ~/anaconda3/envs/decoupler/lib/python3.9/enum.py:384, in EnumMeta.call(cls, value, names, module, qualname, type, start) 383 if names is None: # simple value lookup --> 384 return cls.new(cls, value) 385 # otherwise, functional API: we're creating a new Enum type

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/constants/_constants.py:15, in _pretty_raise_enum..wrapper(*args, **kwargs) 14 e.args = (cls._format(value),) ---> 15 raise e

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/omnipath/constants/_constants.py:11, in _pretty_raise_enum..wrapper(*args, *kwargs) 10 try: ---> 11 return fun(args, **kwargs) 12 except ValueError as e:

File ~/anaconda3/envs/decoupler/lib/python3.9/enum.py:702, in Enum.new(cls, value) 701 if result is None and exc is None: --> 702 raise ve_exc 703 elif exc is None:

ValueError: Invalid value loops for InteractionsQuery. Valid options are: ['database', 'databases', 'dataset', 'datasets', 'directed', 'directeds', 'dorothea_level', 'dorothea_levels', 'dorothea_method', 'dorothea_methods', 'entity_type', 'entity_types', 'field', 'fields', 'format', 'formats', 'genesymbol', 'genesymbols', 'header', 'headers', 'license', 'licenses', 'limit', 'limits', 'organism', 'organisms', 'partner', 'partners', 'password', 'passwords', 'resource', 'resources', 'signed', 'signeds', 'source_target', 'source_targets', 'source', 'sources', 'target', 'targets', 'tfregulons_level', 'tfregulons_levels', 'tfregulons_method', 'tfregulons_methods', 'type', 'types'].

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) Cell In[3], line 2 1 # Retrieve CollecTRI gene regulatory network ----> 2 collectri = dc.get_collectri(organism='human', split_complexes=False) 3 collectri

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py:530, in get_collectri(organism, split_complexes, kwargs) 523 ct = op.interactions.CollecTRI.get( 524 genesymbols=True, 525 organism=_organism, 526 loops=True, 527 kwargs 528 ) 529 except Exception: --> 530 ct = _static_fallback( 531 query='interactions', 532 resource='CollecTRI', 533 organism=TAXIDS[_organism], 534 ) 536 if _organism == 'human': 537 try:

File ~/anaconda3/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py:121, in _static_fallback(query, resource, organism, kwargs) 117 _warn_failure(resource) 119 op = _check_if_omnipath() --> 121 return op.static.static_table( 122 query=query, 123 resource=resource, 124 organism=organism, 125 kwargs 126 )

AttributeError: module 'omnipath' has no attribute 'static'

Thanks for your answer!

PauBadiaM commented 6 months ago

Hi @clg12,

It looks like you are using an older version of omnipath, could you install the latest one and try again?

pip install --upgrade omnipath

Hope this is helpful!