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

"TKA7R" in MyNeurons has cycle #8

Open
zhihaozheng opened this issue Feb 20, 2017 · 0 comments
Open

"TKA7R" in MyNeurons has cycle #8

zhihaozheng opened this issue Feb 20, 2017 · 0 comments

Comments

@zhihaozheng
Copy link

This is a not a fix. I didn't come up with a quick fix since the edges around the multiple-edge nodes are flowing in opposite directions. But at least this makes the graph acyclic (albeit not fully connected in LH) and good enough for me to do calyx operations. Most multiple edges are in LH, except 1 in mALT around StartPoint.

Just want to post it here in case there are other users.

library(igraph)
library(magrittr)
library(nat)
load("MyNeurons.rda")

n = MyNeurons[["TKA7R"]]
g = as.ngraph(n)

# return FALSE
is.dag(g)

# looks like it has multiple edges
multi = as.undirected(g, mode='each') %>%
  which_multiple %>%
  which %>%
  print

# print the duplicate edges and delete the extra ones
exclude = c()
for (node in multi) {
  inc = ego(g, order=2, nodes=node, mode='in')[[1]] %>% print
  out = ego(g, order=2, nodes=node, mode='out')[[1]] %>% print

# certainly not a good logic, but length(inc) and length(out) won't be 2 at the same time, 
# so should be fine here 
 if (length(inc)==2) eds = inc
 if (length(out)==2) eds = out
  exclude = c(exclude, paste(as_ids(eds), collapse="|"))
}

# Observed from the 3D skeleton that these 2 edges are needed to cut an internal loop
exclude = c(exclude, "745|746", "640|641")

dg = g - edges(exclude)

# This is the edge list necessary to turn the neurons into a dag
# "3|1" "486|485" "575|574" "685|684" "766|765" "822|821" "745|746" "640|641"

# return TRUE
is.dag(dg) 

MyNeurons[["TKA7R"]] = as.neuron(as.ngraph(dg))
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