Skip to content

Commit

Permalink
Merge branch 'master' into drop_prefix
Browse files Browse the repository at this point in the history
# Conflicts:
#	R/name.R
  • Loading branch information
romainFr committed Jan 23, 2020
2 parents 8c4c3e2 + e101c60 commit 3d164e7
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions R/connectivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ neuprint_get_adjacency_matrix <- function(bodyids, dataset = NULL, all_segments
namefield,
namefield
)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, ...)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, ...)
m = matrix(0,nrow = length(bodyids),ncol = length(bodyids))
rownames(m) = colnames(m) = bodyids
for(i in 1:length(nc$data)){
Expand Down Expand Up @@ -86,7 +86,7 @@ neuprint_connection_table <- function(bodyids, prepost = c("PRE","POST"), roi =
ifelse(prepost=="POST","bodyid","partner"),
ifelse(prepost=="POST","partner","bodyid")
)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, ...)
## Filter out the rare cases where PSDs and tbars are in different ROIs (hence post is null)
nc$data <- nc$data[sapply(nc$data,function(x) !is.null(x[[4]]))]
d <- data.frame(do.call(rbind,lapply(nc$data,unlist)),stringsAsFactors = FALSE)
Expand Down Expand Up @@ -265,7 +265,7 @@ neuprint_get_paths <- function(body_pre,body_post,n,weightT=5,roi=NULL,dataset =
ifelse(is.null(roi),"",roi)
)

nc <- neuprint_fetch_custom(cypher=cypher, conn = conn)
nc <- neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, ...)

connTable <- dplyr::bind_rows(lapply(nc$data, function(d){
l <- d[[1]]
Expand Down Expand Up @@ -331,7 +331,7 @@ neuprint_get_shortest_paths <- function(body_pre,body_post,weightT=5,roi=NULL,da
ifelse(is.null(roi),"",roi)
)

nc <- neuprint_fetch_custom(cypher=cypher, conn = conn)
nc <- neuprint_fetch_custom(cypher=cypher, conn = conn, dataset=dataset, ...)

connTable <- dplyr::bind_rows(lapply(nc$data, function(d){
l <- d[[1]]
Expand Down
2 changes: 1 addition & 1 deletion R/dump.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @rdname neuprint_dump
#' @importFrom nat write.neurons
neuprint_dump <- function(dir, bodyids = NULL, roi = NULL, preprocess = NULL, connectivity = TRUE, volumes = TRUE,
meta = TRUE, nat = TRUE, drvid = TRUE, flow.centrality = FALSE, soma = TRUE, estimate.soma = FALSE,
meta = TRUE, nat = TRUE, drvid = FALSE, flow.centrality = FALSE, soma = TRUE, estimate.soma = FALSE,
heal = TRUE, connectors = TRUE, all_segments = TRUE, resample = FALSE,
scale = 4, voxel.thresh = 1e+07, split = c("postsynapses","presynapses","distance"),
dataset = NULL, conn=NULL, OmitFailures = TRUE, ...){
Expand Down
8 changes: 4 additions & 4 deletions R/fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ neuprint_list2df <- function(x, cols=NULL, return_empty_df=FALSE, ...) {
}

#' @importFrom memoise memoise
neuprint_name_field <- memoise(function(conn=NULL) {
neuprint_name_field <- memoise(function(conn=NULL, dataset = NULL) {
if (is.null(conn))
stop(
"You must do\n conn = neuprint_login(conn)\n",
"before using neuprint_name_field(conn) in your function!",
call. = FALSE
)
q="MATCH (n :hemibrain_Neuron) WHERE exists(n.instance) RETURN count(n)"
n=unlist(neuprint_fetch_custom(q, include_headers=F)[['data']])
n=unlist(neuprint_fetch_custom(q, dataset = dataset, include_headers=F)[['data']])
return(ifelse(n>0, "instance", "name"))
})

Expand All @@ -113,7 +113,7 @@ neuprint_dataset_prefix <- memoise(function(dataset, conn=NULL) {
call. = FALSE
)
# q=sprintf("MATCH (n:`%s_Segment`) RETURN count(n)", dataset)
# n=unlist(neuprint_fetch_custom(q, include_headers=F)[['data']])
# n=unlist(neuprint_fetch_custom(q, dataset = dataset, include_headers=F)[['data']])
#paste0(dataset, ifelse(n>0, "_", "-")) # I think we no longer need to specify the dataset. Might be good to keep this function in place though, in case situation changes
""
})
Expand All @@ -126,7 +126,7 @@ check_dataset <- function(dataset=NULL) { # Get a default dataset if none spec
warning("Please supply a dataset or set a default one using the ",
"neuprint_dataset environment variable! See ?neuprint_login for details.
For now we will use hemibrain:v1.0")
dataset = "hemibrain:1.0"
dataset = "hemibrain:v1.0"
}
}
dataset
Expand Down
9 changes: 5 additions & 4 deletions R/name.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ neuprint_get_neuron_names <- function(bodyids, dataset = NULL, all_segments = TR
cypher = sprintf("WITH %s AS bodyIds UNWIND bodyIds AS bodyId MATCH (n:`%s`) WHERE n.bodyId=bodyId RETURN n.instance AS name",
jsonlite::toJSON(as.numeric(unlist(bodyids))),
all_segments.json)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, ...)

nc = neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, ...)
d = unlist(lapply(nc$data,nullToNA))
names(d) = bodyids
d
Expand Down Expand Up @@ -47,7 +48,7 @@ neuprint_get_meta <- function(bodyids, dataset = NULL, all_segments = TRUE, conn
all_segments,
neuprint_name_field(conn)
)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, include_headers = FALSE, ...)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, include_headers = FALSE, ...)
neuprint_list2df(nc, return_empty_df = TRUE)
}

Expand All @@ -71,7 +72,7 @@ neuprint_get_roiInfo <- function(bodyids, dataset = NULL, all_segments = TRUE, c
jsonlite::toJSON(as.numeric(unlist(bodyids))),
all_segments
)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, ...)
nc = neuprint_fetch_custom(cypher=cypher, dataset = dataset, conn = conn, ...)
lc <- lapply(nc$data,function(x){cbind(bodyid=x[[1]],as.data.frame(t(unlist(jsonlite::fromJSON(x[[2]])))))})
d <- dplyr::bind_rows(lc)
d
Expand Down Expand Up @@ -103,7 +104,7 @@ neuprint_search <- function(search, meta = TRUE, all_segments = TRUE, dataset =
all_segments.cypher,
neuprint_name_field(conn),
search)
nc = neuprint_fetch_custom(cypher=cypher, ...)
nc = neuprint_fetch_custom(cypher=cypher, dataset = dataset, ...)
foundbodyids=unlist(nc$data)
if(meta && isTRUE(length(foundbodyids)>0)){
neuprint_get_meta(bodyids = foundbodyids, dataset = dataset, all_segments = all_segments, conn = conn, ...)
Expand Down
2 changes: 1 addition & 1 deletion R/neurons.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ neuprint_read_neuron <- function(bodyid,
n = drvid::read.neuron.dvid(bodyid)
d = n$d
}else{
n = neuprint_read_neuron_simple(as.numeric(bodyid),dataset=dataset,conn = conn,heal = FALSE,...)
n = neuprint_read_neuron_simple(as.numeric(bodyid),dataset=dataset,conn = conn, heal = FALSE,...)
}
if(heal|flow.centrality){
n = suppressWarnings( heal_skeleton(x = n) )
Expand Down
2 changes: 1 addition & 1 deletion R/roi.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ neuprint_bodies_in_ROI <- function(roi, dataset = NULL, all_segments = FALSE, co
roi,
roi,
roi)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, ...)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, ...)
d = data.frame(do.call(rbind,lapply(nc$data,unlist)))
colnames(d) = unlist(nc$columns)
d
Expand Down
2 changes: 1 addition & 1 deletion R/soma.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ neuprint_locate_soma <- function(bodyids, dataset = NULL, all_segments = TRUE, c
cypher = sprintf("WITH %s AS bodyIds UNWIND bodyIds AS bodyId MATCH (n:`%s`) WHERE n.bodyId=bodyId RETURN n.bodyId AS bodyId, n.somaLocation AS soma",
jsonlite::toJSON(as.numeric(unique(bodyids))),
paste0(dp, all_segments.json))
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, ...)
nc = neuprint_fetch_custom(cypher=cypher, conn = conn, dataset = dataset, ...)
if(length(nc$data)==0){
coordinates = matrix(c(NA,NA,NA),nrow=length(bodyids),ncol=3)
coordinates = cbind(data.frame(bodyid=bodyids),coordinates)
Expand Down
2 changes: 1 addition & 1 deletion R/synapses.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ neuprint_get_synapses <- function(bodyids, roi = NULL, progress = FALSE, dataset
prefixed_seg,
prefixed_seg,
roi)
nc.post = neuprint_fetch_custom(cypher=cypher.post, conn = conn, ...)
nc.post = neuprint_fetch_custom(cypher=cypher.post, conn = conn, dataset = dataset, ...)
nc.pre = neuprint_fetch_custom(cypher=cypher.pre, conn = conn, ...)
m = rbind(do.call(rbind,nc.post$data),do.call(rbind,nc.pre$data))
colnames(m) = nc.post$columns
Expand Down
2 changes: 1 addition & 1 deletion man/neuprint_dump.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3d164e7

Please sign in to comment.