From 86b3ce67eab05d9808bf9b4e7c242b82ef8b2337 Mon Sep 17 00:00:00 2001 From: Dominik Krzeminski Date: Thu, 3 Jun 2021 13:21:19 +0100 Subject: [PATCH 1/3] reroot method added --- R/catmaid_nat.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/catmaid_nat.R b/R/catmaid_nat.R index 64b4f16..6cfc115 100644 --- a/R/catmaid_nat.R +++ b/R/catmaid_nat.R @@ -441,6 +441,12 @@ summary.catmaidneuron<-function(object, ...) { df } +#' @export +reroot.catmaidneuron<-function(object, ...) { + n = NextMethod() + copy_tags_connectors(n, object) +} + #' Copy the tag / connector info from a catmaid neuron to a new neuron #' @description This function is intended primarily for developer use as a way #' to copy over connector/tag information typically contained in CATMAID From f1ef6f8e5ef5423f5a1c244f6c0a7aa2011d67a6 Mon Sep 17 00:00:00 2001 From: Dominik Krzeminski Date: Thu, 3 Jun 2021 14:01:19 +0100 Subject: [PATCH 2/3] [upd] namespace reroot --- NAMESPACE | 1 + 1 file changed, 1 insertion(+) diff --git a/NAMESPACE b/NAMESPACE index 5740219..edd560b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,6 +12,7 @@ S3method(nsoma,neuron) S3method(nsoma,neuronlist) S3method(plot3d,catmaidneuron) S3method(print,catmaid_connection) +S3method(reroot,catmaidneuron) S3method(soma,neuron) S3method(soma,neuronlist) S3method(somaid,neuron) From 7f0919b64624d56f492105bd5afaf30ebbe56ee1 Mon Sep 17 00:00:00 2001 From: Dominik Krzeminski Date: Thu, 3 Jun 2021 14:46:10 +0100 Subject: [PATCH 3/3] [add] test of reroot added --- tests/testthat/test-nat.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testthat/test-nat.R b/tests/testthat/test-nat.R index 89b5e26..ee26627 100644 --- a/tests/testthat/test-nat.R +++ b/tests/testthat/test-nat.R @@ -34,3 +34,13 @@ test_that("Ops.catmaidneuron behaves", { t(t(xyzmatrix(connectors(AV4b1)))*c(2,3,4))) expect_equal((AV4b1*2)/2, AV4b1) }) + +test_that("reroot.catmaidneuron works", { + data(AV4b1) + soma <- list(id=2712463, idx=126) + rAV4b1 <- reroot(AV4b1, pointno = soma$id) + # check if new soma has correct index + expect_equal(rAV4b1$StartPoint, soma$idx) + # old soma is no longer without parent + expect_true(rAV4b1$d[AV4b1$StartPoint, "Parent"] != -1) +})