Open artxz opened 1 year ago
ah that's annoying. code looks pretty crufty
maybe it's not that bad with indentation?
data.frame(from=as.character(d[[2]][[i]][[1]]),
to=as.character(d[[2]][[i+1]][[1]]),
weight=d[[3]][[i]],
depth=i,
name.from=I(list(d[[2]][[i]][[2]])), name.to=I(list(d[[2]][[i+1]][[2]])),
type.from=I(list(d[[2]][[i]][[3]])), type.to=I(list(d[[2]][[i+1]][[3]])),
stringsAsFactors = FALSE)
Another possibility
connTable <- dplyr::bind_rows(lapply(nc$data, function(d){
l <- d[[1]]
tryCatch( dplyr::bind_rows(lapply(1:l, function(i){
d2 <- do.call(rbind, d[[2]][i:(i+1)])
data.frame(from=as.character(d2[1]),
to=as.character(d2[2]),
weight=d[[3]][[i]],
depth=i,
name.from=I(d2[3]),name.to=I(d2[4]),
type.from=I(d2[5]),type.to=I(d2[6]),
stringsAsFactors = FALSE)
})), error = function(e) NULL)
}))
also suggest add an ordinal number for each path, maybe something like this
connTable$path <- rep(seq(1,length(nc$data)), each= nc$data[[1]][[1]])
Hi I am wondering whether there is a fix or work around on this issue? Thanks!
@artxz’s suggestion was good but I didn’t get to implement. Will take a day or two to get to unless someone wants to offer a PR.
Sounds great! It would be super helpful if it is solved. Thanks!
for example, this works
neuprint_get_shortest_paths(1633411652, 1663767674)
but this does notneuprint_get_shortest_paths(1850310331, 1663767674)
the returned queries look ok but the second one bodyid = 1850310331 has no name or type. It seems to cause a problem when building the returned dataframe
connTable <- dplyr::bind_rows(lapply(nc$data, function(d){ l <- d[[1]] tryCatch( dplyr::bind_rows(lapply(1:l, function(i){ data.frame(from=as.character(d[[2]][[i]][[1]]), to=as.character(d[[2]][[i+1]][[1]]), weight=d[[3]][[i]], depth=i, name.from=d[[2]][[i]][[2]],name.to=d[[2]][[i+1]][[2]], type.from=d[[2]][[i]][[3]],type.to=d[[2]][[i+1]][[3]], stringsAsFactors = FALSE) })), error = function(e) NULL) }))
One possible solution is to use, eg.,
I(list(d[[2]][[i]][[2]]))
instead ofd[[2]][[i]][[2]]
Similar problem with
neuprint_get_paths