saezlab / omnipath

Python client for the OmniPath web service
https://omnipath.readthedocs.io
MIT License
37 stars 6 forks source link

set species #23

Closed wangjiawen2013 closed 12 months ago

wangjiawen2013 commented 2 years ago

Hi, I have downloaded omnipat database with this chunk of code (https://github.com/scverse/squidpy/issues/499):

import squidpy as sq
import omnipath as op

adata = sq.datasets.visium_fluo_adata_crop()
cluster_key = 'cluster'

df = op.interactions.import_intercell_network(
    transmitter_params={"categories": "ligand"},
    receiver_params={"categories": "receptor"}
)

df['source'] = df['genesymbol_intercell_source'] #rename sources and targets
df['target'] = df['genesymbol_intercell_target']

sq.gr.ligrec(adata, cluster_key=cluster_key, interactions=df)
res = adata.uns[f"{cluster_key}_ligrec"]

Is it a human database or mouse database ? How to specify the species in function interactions.import_intercell_network() ? It seems that it can be set in omnipath R package: https://saezlab.github.io/OmnipathR/reference/get_interaction_resources.html

michalk8 commented 2 years ago

Hi @wangjiawen2013 , I believe by default it's human database. To specify, e.g., mouse, you should do:

df = op.interactions.import_intercell_network(
    interactions_params={"organism": "mouse"},
    transmitter_params={"categories": "ligand"},
    receiver_params={"categories": "receptor"},
)

However, running this returned:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [30], in <cell line: 1>()
----> 1 interactions, transmitters, receivers = op.interactions.import_intercell_network(
      2     interactions_params={"organism": "mouse"},
      3     transmitter_params={"categories": "ligand", "organism": "mouse"},
      4     receiver_params={"categories": "receptor", "organism": "mouse"}
      5 )

File /opt/projects/helmholtz/omnipath/omnipath/_core/requests/interactions/_utils.py:128, in import_intercell_network(include, interactions_params, transmitter_params, receiver_params)
    126 return interactions, transmitters, receivers
    127 res = pd.merge(interactions, transmitters, left_on="source", right_on="uniprot", how="inner")
--> 128 if res.empty:
    129     raise ValueError("No values are left after merging interactions and transmitters.")
    130 gb = res.groupby(["category", "parent", "source", "target"], as_index=False)

ValueError: No values are left after merging interactions and transmitters.

which I'm not sure is expected, @deeenes will definitely know more.

deeenes commented 2 years ago

Hi, The error above happens because the OmniPath intercell database supports only human at the moment. Even in the network, we create mouse data by homology translation. You can download the human intercell network, and use pypath.utils.homology.translate to translate it to mouse.