Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
Last active September 18, 2020 14:45
Show Gist options
  • Save rvanbruggen/8c3f37d039f655ee040f763b84932d00 to your computer and use it in GitHub Desktop.
Save rvanbruggen/8c3f37d039f655ee040f763b84932d00 to your computer and use it in GitHub Desktop.
Queries to run against the OpenTrials database, once imported into Neo4j
//Look at schema
call db.schema.visualization
//what is connected and how
match (n)-[r]->(m)
return distinct labels(n), type(r), labels(m)
//how many nodes of each label
match (n)
return labels(n), count(n)
//put in place some indexing
create index on :Condition(name);
create index on :Trial(publicTitle);
//how many trials have been executed for a condition?
match (c:Condition)-->(t:Trial)
return c.name, count(t) as NrOfTrials
order by NrOfTrials desc
limit 10
//how many Conditions share a trial
match (t:Trial)<-[r]-(c:Condition)
return t.publicTitle, count(c)
order by count(c) desc
limit 10
match (t:Trial)<-[r]-(c:Condition)
with t, count(c) as NrOfConditions
order by NrOfConditions desc
limit 1
match (t)<--(c:Condition)
return t,c
//finding glanzmann's disease
match (c:Condition)--(conn) where toLower(c.name) contains "glanzmann" return c,conn;
//finding more about glanzmann by expanding the graph
match (c:Condition)--(t:Trial)--(conn)
where toLower(c.name) contains "glanzmann"
return c,t, conn
//find the conditions where NovoSeven was tested
match (t:Trial)--(c:Condition)
where toLower(t.publicTitle) contains "novoseven"
return t,c;
//find conditions with nut allergy
match (c:Condition)--(conn) where toLower(c.name) = "nut allergy" return c,conn
//find conditions with SARS or MERS
match (c:Condition)--(connection)
where c.name contains "SARS"
or c.name contains "MERS"
return c, connection
//how many trials in every location
MATCH (l:Location)--(t:Trial)
return l.name, count(t)
order by count(t) desc
limit 20
//how many trials in Belgium
MATCH (l:Location {name:"Belgium"})--(t:Trial)
return l.name, count(t);
//How many trial-condition combinations in Belgium
MATCH (l:Location {name:"Belgium"})--(t:Trial)--(c:Condition)
return distinct count(t);
//for how many conditions where there trials conducted in Belgium
MATCH (l:Location {name:"Belgium"})--(t:Trial)--(c:Condition)
return count(distinct c.name);
//For which conditions was there more than 1 Belgian studies conducted
MATCH (l:Location {name:"Belgium"})--(t:Trial)-[r]-(c:Condition)
return t.publicTitle, c.name, count(r)
order by count(r) desc
limit 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment