From 29b2ff983bc26e0a56a56f9e2caec7814e67a836 Mon Sep 17 00:00:00 2001 From: Dominik Krzeminski Date: Fri, 17 Jun 2022 14:29:12 +0100 Subject: [PATCH] quick fix in normalised scoring for cases where nrns/dps unnamed --- R/scoremats.r | 4 ++++ tests/testthat/test-NBLAST2.r | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/R/scoremats.r b/R/scoremats.r index f6ffe58..2f32f81 100644 --- a/R/scoremats.r +++ b/R/scoremats.r @@ -26,6 +26,8 @@ sub_score_mat <- function(query, target, scoremat=NULL, distance=FALSE, normalis if(!identical(length(dim(scoremat)),2L)) stop("scoremat must be a matrix!") # Check for missing query and target neurons + if (is.null(rownames(scoremat))) + rownames(scoremat) <- as.character(1:nrow(scoremat)) rnames <- rownames(scoremat) if(missing(target)) target <- rnames else { @@ -35,6 +37,8 @@ sub_score_mat <- function(query, target, scoremat=NULL, distance=FALSE, normalis target <- intersect(target, rnames) } } + if (is.null(colnames(scoremat))) + colnames(scoremat) <- as.character(1:ncol(scoremat)) cnames=colnames(scoremat) if(missing(query)) query <- cnames else { diff --git a/tests/testthat/test-NBLAST2.r b/tests/testthat/test-NBLAST2.r index 0b5b849..d844e9b 100644 --- a/tests/testthat/test-NBLAST2.r +++ b/tests/testthat/test-NBLAST2.r @@ -60,6 +60,10 @@ test_that("we can calculate normalised nblast v2 scores", { expect_equal(nblast(testneurons[1], testneurons[3:5], version = 2, normalised = T), baseline) + names(testneurons) <- NULL + scoresaba <- nblast_allbyall(testneurons, version=2, + normalisation = 'normalised') + expect_equal(dim(scoresaba), c(5, 5)) }) test_that("we can calculate scores for regular neurons",{