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

Query Depot: Cool Cypher queries for Hetontology #2

Open
dhimmel opened this issue Jul 29, 2016 · 2 comments
Open

Query Depot: Cool Cypher queries for Hetontology #2

dhimmel opened this issue Jul 29, 2016 · 2 comments

Comments

@dhimmel
Copy link
Collaborator

dhimmel commented Jul 29, 2016

This issue is for posting example Cypher queries for the Hetontology Neo4j database.

@dhimmel
Copy link
Collaborator Author

dhimmel commented Jul 29, 2016

Gene Ontology subterms

Here are queries for finding all nodes that descend from a specified node in the Gene Ontology. I originally posted these queries at EBISPOT/OLS#104 and am migrating them to this issue.

Here's a query to find all subterms of regulation of protein transport (GO:0051223):

MATCH path = (n:GO)<-[:SUBCLASSOF*..]-()
WHERE n.obo_id = 'GO:0051223'
WITH nodes(path) AS nodes
UNWIND nodes AS node
RETURN DISTINCT node.obo_id, node.label

The following query extends the above query to also compute:

  1. the (minimum) number of relationships (min_paths) and
  2. the total number of paths (n_paths)
MATCH path = (n:GO)<-[:SUBCLASSOF*..]-()
WHERE n.obo_id = 'GO:0051223'
WITH nodes(path) AS nodes, n
UNWIND nodes AS node
WITH DISTINCT node AS node, n
RETURN 
  node.obo_id AS identifier,
  node.label AS name,
  length(shortestPath((n)<-[:SUBCLASSOF*..]-(node))) AS min_depth,
  size((n)<-[:SUBCLASSOF*..]-(node)) AS n_paths
ORDER BY min_depth, name

@dhimmel
Copy link
Collaborator Author

dhimmel commented Jul 29, 2016

Disease Ontology superterms

Find all superterms of multiple sclerosis (DOID:2377) in the Disease Ontology:

MATCH path = (n:DO)-[:SUBCLASSOF*..]->()
WHERE n.obo_id = 'DOID:2377'
RETURN path

Find all superterms of all non-obsolete nodes whose name contains "diabetes".

MATCH path = (n:DO)-[:SUBCLASSOF*..]->()
WHERE n.label CONTAINS 'diabetes'
AND NOT 'Obsolete' IN labels(n)
RETURN path

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

No branches or pull requests

1 participant