-1

How can I transform a CSV pairwise co-publication correlation table (165 names by the same 165 names w/ correlation values) into a file I can import as a nodes and edges table into either NEO4J or Cytoscape?

2 Answers2

0

Speaking just for loading into Neo4j:

I'm assuming the CSV has three columns, something like name1,name2,correlation?

You can just load from a CSV into Neo4j, no transformation necessary. This works best when nodes are loaded first, and relationships loaded separately.

So that would require two runs through the CSV.

The first run will be for doing a MERGE of all your nodes. You'll want an index on the label/property combination so the MERGE is fast.

Assuming for the moment that you're working with :Person nodes, you'd want an index on :Person(name) and your load would look something like this:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:///path/to/csv/relative/to/import/directory' as line
MERGE (:Person{name:line.name1})

Now that all the nodes are imported, the second run will create the relationships:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:///path/to/csv/relative/to/import/directory' as line
MATCH (p1:Person{name:line.name1}), (p2:Person{name:line.name2})
MERGE (p1)-[:CORRELATION{value:toInteger(line.correlation)}]-(p2)
InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
  • The table I want should look like that (name1,name2, correlation value). The CSV table I have is a distance matrix. X=165 names vs Y=the same 165 names, with each cell having a corelation value. – user3050520 Apr 03 '18 at 21:59
0

For Cytoscape, you can just import the table using File->Import->Network->File...

Scooter Morris
  • 1,269
  • 1
  • 7
  • 4