From 92f93acedb08aa52c63ddc17996387b8f1fcca1b Mon Sep 17 00:00:00 2001 From: ESCRI11 Date: Wed, 16 Oct 2024 13:48:21 +0200 Subject: [PATCH] feat: handle single k case sapply returns a numeric vector, make it a single row matrix so downstream code works as expected --- components/board.clustering/R/clustering_plot_genemodule.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/board.clustering/R/clustering_plot_genemodule.R b/components/board.clustering/R/clustering_plot_genemodule.R index d2d6f63e1..82c64e0f4 100644 --- a/components/board.clustering/R/clustering_plot_genemodule.R +++ b/components/board.clustering/R/clustering_plot_genemodule.R @@ -66,6 +66,10 @@ clustering_plot_genemodule_server <- function(id, mat <- res$mat idx <- res$idx modx <- sapply(1:ncol(mat), function(i) tapply(mat[, i], idx, mean)) + if (is.null(dim(modx))) { + modx <- matrix(modx, nrow = 1) + rownames(modx) <- unique(idx) + } colnames(modx) <- colnames(mat) return(list(