Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up neuprint_get_synapses #94

Closed
jefferis opened this issue Mar 4, 2020 · 3 comments
Closed

speed up neuprint_get_synapses #94

jefferis opened this issue Mar 4, 2020 · 3 comments

Comments

@jefferis
Copy link
Contributor

jefferis commented Mar 4, 2020

  • speed up by chunking while avoid time outs
  • improve processing of the results
  • also columns are all character vector
@jefferis
Copy link
Contributor Author

jefferis commented Mar 5, 2020

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

neuprintr/R/synapses.R

Lines 66 to 85 in b456d41

cypher.post = 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 AND (s.type='post') %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)
cypher.pre = 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 AND (s.type='pre') %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)

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

@jefferis
Copy link
Contributor Author

jefferis commented Mar 9, 2020

Closed by #96

@jefferis jefferis closed this as completed Mar 9, 2020
@jefferis
Copy link
Contributor Author

jefferis commented Mar 9, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant