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

dc.get_collectri() does not work #95

Closed FADHLyemen closed 7 months ago

FADHLyemen commented 7 months ago

Describe the bug I try to obtain TF regulons using decoupler but get error. net = dc.get_collectri()

To Reproduce image

Expected behavior

ValueError                                Traceback (most recent call last)
Cell In[17], line 1
----> 1 net = dc.get_collectri()

File ~/anaconda3/envs/r_env/lib/python3.9/site-packages/decoupler/omnip.py:426, in get_collectri(organism, split_complexes, **kwargs)
    423 op = _check_if_omnipath()
    425 # Load collectri
--> 426 ct = op.interactions.CollecTRI.get(genesymbols=True, organism=_organism, loops=True, **kwargs)
    427 if _organism == 'human':
    428     mirna = op.interactions.TFmiRNA.get(genesymbols=True, databases=['CollecTRI'], strict_evidences=True)

File ~/anaconda3/envs/r_env/lib/python3.9/site-packages/omnipath/_core/requests/_utils.py:114, in _inject_api_method.<locals>.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/r_env/lib/python3.9/site-packages/omnipath/_core/requests/_utils.py:31, in _get_helper(cls, **kwargs)
     15 @d.get_full_description(base="get")
     16 @d.get_sections(base="get", sections=["Parameters", "Returns"])
     17 def _get_helper(cls: type, **kwargs) -> pd.DataFrame:
     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/r_env/lib/python3.9/site-packages/omnipath/_core/requests/_request.py:108, in OmnipathRequestABC._get(self, **kwargs)
    106 kwargs = self._inject_fields(kwargs)
    107 kwargs, callback = self._convert_params(kwargs)
--> 108 kwargs = self._validate_params(kwargs)
    109 kwargs = self._finalize_params(kwargs)
    110 self._last_param["final"] = kwargs.copy()

File ~/anaconda3/envs/r_env/lib/python3.9/site-packages/omnipath/_core/requests/_request.py:195, in OmnipathRequestABC._validate_params(self, params)
    192 res = {}
    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/r_env/lib/python3.9/site-packages/omnipath/_core/query/_query.py:136, in QueryType.__call__(self, value)
    132 def __call__(
    133     self, value: Optional[Union[str, Sequence[str]]]
    134 ) -> Optional[Set[str]]:
    135     """%(validate)s"""  # noqa: D401
--> 136     return self.value(value)

File ~/anaconda3/envs/r_env/lib/python3.9/site-packages/omnipath/constants/_constants.py:51, in FormatterMeta.__call__(cls, *args, **kw)
     46 if getattr(cls, "__error_format__", None) is None:
     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/r_env/lib/python3.9/enum.py:384, in EnumMeta.__call__(cls, value, names, module, qualname, type, start)
    359 """
    360 Either returns an existing member, or creates a new enum class.
    361 
   (...)
    381 `type`, if set, will be mixed in as the first base class.
    382 """
    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
    386 return cls._create_(
    387         value,
    388         names,
   (...)
    392         start=start,
    393         )

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

File ~/anaconda3/envs/r_env/lib/python3.9/site-packages/omnipath/constants/_constants.py:11, in _pretty_raise_enum.<locals>.wrapper(*args, **kwargs)
      8 @wraps(fun)
      9 def wrapper(*args, **kwargs) -> Enum:
     10     try:
---> 11         return fun(*args, **kwargs)
     12     except ValueError as e:
     13         _cls, value, *_ = args

File ~/anaconda3/envs/r_env/lib/python3.9/enum.py:702, in Enum.__new__(cls, value)
    700 ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
    701 if result is None and exc is None:
--> 702     raise ve_exc
    703 elif exc is None:
    704     exc = TypeError(
    705             'error in %s._missing_: returned %r instead of None or a valid member'
    706             % (cls.__name__, result)
    707             )

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']`.

System

Additional context Add any other context about the problem here.

deeenes commented 7 months ago

This issue has been fixed some time in the summer, please update the omnipath package to 1.0.8. Now it's finally updated also in PyPI:

pip install --upgrade omnipath

It's best to make sure decoupler too is up to date:

pip install 'git+https://github.com/saezlab/decoupler-py.git'
FADHLyemen commented 7 months ago

@deeenes this update fixes it, thank you