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

Expand query graph predicates based on Biolink Model hierarchy #167

Closed
andrewsu opened this issue Apr 23, 2021 · 11 comments
Closed

Expand query graph predicates based on Biolink Model hierarchy #167

andrewsu opened this issue Apr 23, 2021 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@andrewsu
Copy link
Member

In #102, we extended BTE so that it would expand general Biolink node types (e.g., biolink:NamedThing) into all of its subclasses (e.g., biolink:Disease, biolink:Gene). Along similar lines this issue proposes to expand query graph predicates in a similar manner. For example, this query uses the predicate biolink:causes (https://biolink.github.io/biolink-model/docs/causes.html), which in turn has antecedants for biolink:contributes_to (https://biolink.github.io/biolink-model/docs/contributes_to.html) and biolink:related_to (https://biolink.github.io/biolink-model/docs/related_to.html).

In the example query above, if I replace the predicate biolink:causes with biolink:related_to, I expect that the BTE response for the latter will be a superset of the former, but that is not currently the case.

@newgene
Copy link
Member

newgene commented May 20, 2021

Implemented and merged here: biothings/bte_trapi_query_graph_handler#10

@colleenXu
Copy link
Collaborator

It's hard to tell if the predicate expansion is working properly or not, since now the predicate in the query seems to be ignored (#185). This happens even when only 1 predicate is specified.

My tentative guess is that the "predicate expansion" work or some other work on the query-making module may have broken the predicate restriction/filtering ability that BTE previously did have.

I recall that the "predicate restriction/filtering" used to work - like February, or a month or two ago.

  • I could run a query with MolecularActivity GO:0032451 -(subclass_of)-> MolecularActivity, and expect only edges back that had subclass_of in the predicate. I remember doing queries like this, since I was checking every operation in x-bte for whether BTE could correctly execute the sub-queries to other APIs at the time.
  • Back then, BTE wasn't doing predicate expansion. So querying with related_to would ONLY give you results with related_to in it.
  • Unfortunately I don't think I saved any of the responses from BTE TRAPI from that time
  • I don't remember if BTE TRAPI only queried other APIs with the exact predicate, or whether it queried everything (based on ID namespaces and semantic types) and then filtered out non-matching predicates from the edges/results. This would have been visible in the logs

@andrewsu
Copy link
Member Author

Great, let's put this issue on hold pending resolution of #185

@andrewsu
Copy link
Member Author

andrewsu commented Jun 8, 2021

Now that #185 is closed but this issue was not magically fixed, reassigning this to @marcodarko to look into more.

@colleenXu
Copy link
Collaborator

This is still not working.

For example, the following query should return answers where the edge's predicates are children of the related_to - aka any predicate is fine. Instead, the only answers returned are ones where the edge's predicate is EXACTLY related_to.

{
    "message": {
        "query_graph": {
            "nodes": {
                "n0": {
                    "categories": [
                        "biolink:ChemicalSubstance"
                    ],
                    "name": "Chemical Substance"
                },
                "n1": {
                    "name": "EGFR",
                    "ids": [
                        "NCBIGene:1956"
                    ],
		    "categories":["biolink:Gene"]
                }
            },
            "edges": {
                "e0": {
                    "subject": "n0",
                    "object": "n1",
                    "predicates": [
                        "biolink:related_to"
                    ]
                }
            }
        }
    }
}

@marcodarko
Copy link
Contributor

I think we can use the existing expand predicates functionality of the edge class to include children in the filters, I will try it and see how it goes.

@marcodarko
Copy link
Contributor

marcodarko commented Jun 9, 2021

@colleenXu given the query above, do these results look like what you would expect? Instead I used the expanded predicates of "biolink:related_to" as the post query filters. Sorry about the lengthy response... *EDIT see below for correct query, I made a mistake, the nodes are a little different.

[{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:35860"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:35860"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:23115"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:23115"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:28534"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:28534"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:3903"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:3903"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D001335"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D001335"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:4738"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:4738"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:49325"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:49325"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D053260"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D053260"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:83569"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:83569"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:33848"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:33848"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:32888"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:32888"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:27563"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:27563"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D004391"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D004391"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:82790"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:82790"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D052638"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D052638"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D012906"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D012906"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D000393"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D000393"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:34758"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:34758"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:141474"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:141474"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:18422"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:18422"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:25812"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:25812"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D008383"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D008383"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D004731"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D004731"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:38764"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:38764"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:34623"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:34623"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:3390"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:3390"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:28851"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:28851"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:27385"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:27385"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:23012"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:23012"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:25195"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:25195"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:16130"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:16130"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:16136"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:16136"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:23003"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:23003"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:27928"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:27928"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:34594"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:34594"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:28793"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:28793"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D006533"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D006533"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D014028"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D014028"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:24527"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:24527"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:39106"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:39106"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:34682"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:34682"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:28854"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:28854"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:16480"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:16480"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:25944"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:25944"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:2555"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:2555"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:17245"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:17245"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"MESH:D026023"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-MESH:D026023"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"PUBCHEM.COMPOUND:18594026"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-PUBCHEM.COMPOUND:18594026"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:33101"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:33101"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:37734"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:positively_correlated_with-CHEBI:37734"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:38069"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:negatively_correlated_with-CHEBI:38069"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:34846"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:negatively_correlated_with-CHEBI:34846"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:27744"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:negatively_correlated_with-CHEBI:27744"}]}},{"node_bindings":{"n0":[{"id":"MONDO:0004979"}],"n1":[{"id":"CHEBI:34905"}]},"edge_bindings":{"e01":[{"id":"MONDO:0004979-biolink:negatively_correlated_with-CHEBI:34905"}]}}]

@colleenXu
Copy link
Collaborator

@marcodarko I can't tell where this is from, so I'm not sure how to answer. It looks like a Disease MONDO:0004979 -> ChemicalSubstance query, but I just ran that and didn't find those CHEBI IDs.

It looks right in that the predicates are descendants of related_to, so I do want those returned.

@marcodarko
Copy link
Contributor

marcodarko commented Jun 10, 2021

@colleenXu my bad, it is Disease MONDO:0004979 > ChemicalSubstance with predicate "correlated_with", sorry! but that's the query I'm running to test this expansion.
So basically the expanded predicates for this query give me:
["positively_correlated_with","negatively_correlated_with","coexpressed_with","has_biomarker","biomarker_for","correlated_with"]
And I'm taking those into consideration when filtering the final results.

*EDIT will work further on this, this might not be the results I'm looking for

@colleenXu
Copy link
Collaborator

colleenXu commented Jun 10, 2021

@marcodarko That kind of expansion looks correct.

However, I would try using some different queries for your testing, because that one seems to depend on clinical risk kp api (which doesn't have positively_correlated_with right now and also has some other issues that I'm dealing with).

You could use the query that I gave above (#167 (comment)), or I can give you some other queries that involve predicate expansion...

@colleenXu
Copy link
Collaborator

This looks resolved now.

This query (predicate restriction to "interacts_with" and its children) correctly returns edges with "interacts_with" AND child predicates like "physically_interacts_with" and "directly_interacts_with".

{
    "message": {
        "query_graph": {
            "nodes": {
                "n0": {
                    "ids": ["HGNC:6284"],
                    "categories":["biolink:Gene"]
                },
                "n1":{
                    "categories": ["biolink:ChemicalSubstance"]
                }
            },
            "edges": {
                "e0": {
                    "subject": "n0",
                    "object": "n1",
                    "predicates": ["biolink:interacts_with"]
                }
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants