Skip to content

Commit

Permalink
neuprint_connection_table: return same results with progress=T/F
Browse files Browse the repository at this point in the history
* closes #40
  • Loading branch information
jefferis committed Jan 27, 2020
1 parent 0f25757 commit 867dbee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/connectivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ neuprint_get_adjacency_matrix <- function(bodyids, dataset = NULL, all_segments
"WHERE n.bodyId IN input AND m.bodyId IN input",
"RETURN n.bodyId AS upstream, m.bodyId AS downstream, c.weight AS weight, n.%s AS upName, m.%s AS downName"
),
id2json(bodyids),
id2json(bodyids, uniqueids = TRUE),
all_segments.json,
namefield,
namefield
Expand Down Expand Up @@ -50,6 +50,8 @@ neuprint_connection_table <- function(bodyids, prepost = c("PRE","POST"), roi =
prepost = match.arg(prepost)
conn=neuprint_login(conn)
all_segments.json = ifelse(all_segments,"Segment","Neuron")
#
# bodyids=unique(id2bit64(bodyids))
if(!is.null(roi)){
roicheck = neuprint_check_roi(rois=roi, dataset = dataset, conn = conn, ...)
}
Expand All @@ -61,6 +63,8 @@ neuprint_connection_table <- function(bodyids, prepost = c("PRE","POST"), roi =
progress = FALSE,
dataset = dataset, conn = conn, ...),
error = function(e) NULL)))
d <- d[order(d$weight,decreasing=TRUE),]
rownames(d) <- NULL
return(d)
}
cypher = sprintf(paste("WITH %s AS bodyIds UNWIND bodyIds AS bodyId",
Expand All @@ -85,6 +89,7 @@ neuprint_connection_table <- function(bodyids, prepost = c("PRE","POST"), roi =
d$weight <- as.integer(d$weight)
d$prepost <- ifelse(prepost=="PRE",0,1)
d <- d[order(d$weight,decreasing=TRUE),]
rownames(d) <- NULL
d[,c("bodyid", "partner", "roi","weight", "prepost")]
}

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-connectivity.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
skip_if(as.logical(Sys.getenv("SKIP_NP_SERVER_TESTS")))

test_that("neuprint_connection_table works", {
expect_is(t1 <- neuprint_connection_table(c(818983130, 1796818119)),
'data.frame')
# ensure we get the same answer with progress=TRUE
expect_equal(neuprint_connection_table(c(818983130, 1796818119),
progress = TRUE),
t1)
})

0 comments on commit 867dbee

Please sign in to comment.