natverse / neuprintr

R client utilities for interacting with the neuPrint connectome analysis service
http://natverse.org/neuprintr
3 stars 3 forks source link

speed up neuprint_get_synapses #94

Closed jefferis closed 4 years ago

jefferis commented 4 years ago
jefferis commented 4 years ago

Also I see that there are currently two separate calls for pre/post

https://github.com/natverse/neuprintr/blob/b456d414ae3fbca3761d66d8231884ee9a5369e3/R/synapses.R#L66-L85

@alexanderbates / @schlegelp do you know if this is actually necessary because of the DISTINCT(ids) clause or could we fetch in one go?

jefferis commented 4 years ago

Closed by #96

jefferis commented 4 years ago

Note to self that this should do both at once:

cypher.both = sprintf(paste("WITH %s AS bodyIds UNWIND bodyIds AS bodyId",
                            "MATCH (a:`%s`)-[:Contains]->(c:SynapseSet)-[:Contains]->(s:Synapse)-[:SynapsesTo]-(:Synapse)-[:Contains]-(:SynapseSet)<-[:Contains]-(b:`%s`)",
                            "WHERE a.bodyId=bodyId %s",
                            "RETURN DISTINCT id(s) AS connector_id,",
                            "s.type AS prepost, s.location.x AS x ,s.location.y AS y, s.location.z AS z,",
                            "s.confidence AS confidence, a.bodyId AS bodyid, b.bodyId AS partner"),
                      id2json(bodyids),
                      "Segment",
                      "Segment",
                      roi)

modulo some reordering to ensure results match.