From 4fb1b6a15da4940e6937de865a9b635e5c2877c0 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:22:19 -0400 Subject: [PATCH] fix: default setting in `createNetwork()` --- NEWS.md | 3 +++ R/NN_network.R | 27 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index ba56055e..52e012cc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,9 @@ - `buffer()` for `giottoPolygon`, `giottoPoints`, `spatLocsObj`. Default is to crop by voronoi borders with `settleGeom()` - `settleGeom()` for `giottoPolygon` and `SpatVector` for finding non overlapping borders determined by voronoi +## bug fixes +- fix default method setting in `createNetwork()` for "delaunay" networks + # GiottoClass 0.4.0 (2024/10/27) diff --git a/R/NN_network.R b/R/NN_network.R index e8c1e440..c109176a 100644 --- a/R/NN_network.R +++ b/R/NN_network.R @@ -143,15 +143,28 @@ createNetwork <- function( # check params type <- match.arg(type, choices = c("sNN", "kNN", "delaunay")) + + mdef <- c("dbscan", "geometry", "RTriangle", "deldir") + if (type %in% c("sNN", "kNN")) { + mchoices <- c("dbscan") + if (identical(method, mdef)) method <- mchoices + } + if (type %in% c("delaunay")) { + mchoices <- c("geometry", "RTriangle", "deldir") + if (identical(method, mdef)) method <- mchoices + } + method <- switch(type, - "sNN" = match.arg(method, choices = c("dbscan"), several.ok = TRUE), - "kNN" = match.arg(method, choices = c("dbscan"), several.ok = TRUE), - "delaunay" = match.arg( - method, - choices = c("geometry", "RTriangle", "deldir"), - several.ok = TRUE - ) + "sNN" = match.arg(method, choices = mchoices, several.ok = TRUE), + "kNN" = match.arg(method, choices = mchoices, several.ok = TRUE), + "delaunay" = { + method <- method[[1L]] + match.arg(method, choices = mchoices, several.ok = TRUE) + } ) + + vmsg(.is_debug = TRUE, sprintf("network\n type: %s\n method: %s", + type, method)) # get common params alist <- list(