Neo4j study - A Tool for Entity-Relationship (Ontology) Data Model
So when talking about data models in the context of data curation, we know there are three main types: relational model, tree model and Entity-Relationship (ER) model.
We’re all familiar with the first two models and tools to deal with them. But not for ER model. It’s easy to understand the concept but rarely you can find as many discussions about tools and applications. This also seems to be a missing part in Data Curation lecture in UIUC.
So in this note We’ll try to take a look at basic graph queries in Neo4j graph database using cypher query language.
As we know, typical graph analysis includes:
- path
- connectivity
- community
- centrality
Following hands on will cover above basic analysis.
First, Neo4j Windows installation is straightforward by following instructions on Neo4j website
After that, we’ll create a new project and database, do hands on in Neo4j GUI as following:
Load a sample gene data into Neo4j
LOAD CSV WITH HEADERS FROM “file:///C:/gene_gene_associations_50k.csv” AS line
MERGE (n:Symbol {Name:line.OFFICIAL_SYMBOL_A})
MERGE (m:Symbol {Name:line.OFFICIAL_SYMBOL_B})
MERGE (n) -[:AssociationType {Type:line.EXPERIMENTAL_SYSTEM}]-> (m)

Overview of the graph
match (n) -[r] ->(m) return m,n,r limit 100

How many genes in total?
match (n:Symbol) return count(n)

How many total associations between all genes?
match (n:Symbol)-[r]->() return count(r)

How many associations that genes point to themselves?
match (n:Symbol)-[r]->(n:Symbol) return count(n)

What is the maximum number of associations between two genes?
match (n)-[r]->(m) where m <> n
return distinct n, m, count(r) as myCount order by myCount desc limit 1

Which five genes have the most association to other genes?
match (n:Symbol) -[r:AssociationType] ->()
return n.Name, count(r) as AssociationCount order by AssociationCount desc limit 5

Find the second-neighborhood of gene named ‘BRCA1’
match p=(n {Name:’USP25’})-[:AssociationType*..2]->(m) return p

Find all shortest path between two genes
match (n:Symbol) where n.Name=’BRCA1’ or n.Name=’NBR1’
with collect(n) as nodes
unwind nodes as n
unwind nodes as m
with * WHERE id(n) < id(m)
match path = allShortestPaths( (n)-[*..4]-(m) )
return path

Create a gene degree histogram
match (n:Symbol)-[r]-()
with n as nodes, count(distinct r) as degree
return degree, count(nodes) order by degree asc

