Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-03-2020 09:17 PM
Hi community,
I used algo.unionFind in graph algorithm package for community detection, and got the community detection result.
Here is my code:
CALL algo.unionFind('HMGS', 'jaccard', {weightProperty:'jaccard_weight', defaultValue:0.0, threshold:0.03, concurrency: 1, write:true, writeProperty:'cluster'})
Here is my community detection result
My problem is I want to visulize the result in neo4j, but I fail.
I want the nodes carrying same set id gathering together.
I did try
MATCH (n:HMGS)
WHERE n.cluster
RETURN n
This gave me an clienterror
Don't know how to treat that as a predicate: Long(0)
I am just wondering am I doing right to visulize the community detection result?
Or there is another way to do it?
Thanks for advance
neo4j version: 3.5.14
graph algorithm package: neo4j-graph-algorithms-3.5.14
neo4j browser version: 3.2.26
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM 'file:///hmgs.csv' AS hmgenesets
MERGE (hmgs:HMGS{name: hmgenesets.hallmark_genesets})
WITH hmgs
MATCH (hmgs)
RETURN (hmgs)
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM 'file:///ji.csv' AS jaccard_index
WITH jaccard_index
MATCH (set1:HMGS{name:jaccard_index.Set1}), (set2:HMGS{name:jaccard_index.Set2})
MERGE (set1) -[ji:jaccard {jaccard_weight: jaccard_index.weight}]-> (set2)
SET ji.jaccard_weight=toFloat(ji.jaccard_weight)
CALL algo.unionFind('HMGS', 'jaccard', {weightProperty:'jaccard_weight', defaultValue:0.0, threshold:0.03, concurrency: 1, write:true, writeProperty:'cluster'})
Solved! Go to Solution.
03-06-2020 08:47 AM
Did you get the error that I got:
Neo.ClientError.Statement.TypeError: Can't coerce `Long(0)` to String
If so, you could try
MATCH (n:HMGS)
CALL apoc.create.addLabels( id(n), [ toString(n.cluster) ] )
YIELD node
RETURN node
03-04-2020 08:16 AM
To see a specific cluster in Browser, you probably want to specify the cluster ID in your query:
MATCH (n:HMGS)
WHERE n.cluster = 42
RETURN n
(although your screen cap shows the property as setId - whichever it is, you have to specify a specific community id).
You could also create a label for each community using apoc.create.addLabels and then manually specifying the color for each label in the browser UI:
MATCH (n:HMGS)
CALL apoc.create.addLabels( id(n), [ n.cluster ] )
That would let you see each of the communities with a different color when you queried the results.
Unfortunately, browser is a fairly simple visualization tool -- for large data sets, or anything more complicated, you would need to leverage something like Bloom or Linkurious.
03-05-2020 01:41 AM
Hi Alicia,
Thank you so much for your reply.
I did try
MATCH (n:HMGS)
CALL apoc.create.addLabels( id(n), [ n.cluster ] )
But it is not working, and give me this error message
Then I try
MATCH (n:HMGS)
CALL apoc.create.addLabels( id(n), [ n.cluster ] )
YIELD node
RETURN node
Which nothing is added.
Do you have any hint why this happened?
Thanks again for your help
03-06-2020 08:47 AM
Did you get the error that I got:
Neo.ClientError.Statement.TypeError: Can't coerce `Long(0)` to String
If so, you could try
MATCH (n:HMGS)
CALL apoc.create.addLabels( id(n), [ toString(n.cluster) ] )
YIELD node
RETURN node
03-06-2020 09:41 PM
Hi Lavanya,
Thank you so much for you reply.
I got the same error as you got, and your solution works on mine
Many thanks
All the sessions of the conference are now available online