From 021ea05ba578c68065a3530206821b6ec6980198 Mon Sep 17 00:00:00 2001 From: ningbioinfo Date: Tue, 3 Oct 2023 15:22:45 +1100 Subject: [PATCH] fix a bug of ordannots with multiple variables. --- R/utils.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/utils.R b/R/utils.R index a31a507..f8dc2be 100644 --- a/R/utils.R +++ b/R/utils.R @@ -40,11 +40,15 @@ bhuvad_theme <- function(textScale = 1.1) { orderSamples <- function(sdata, ordannots) { # add sample IDs sdata$SampleOrderID <- seq(nrow(sdata)) - - # order samples based on provided annotations - if(!is.null(ordannots)){ - sdata <- dplyr::arrange(sdata, !!rlang::sym(ordannots)) + # order samples based on provided annotations + if (!is.null(ordannots)) { + if (length(ordannots) == 1) { + sdata <- sdata[order(sdata[[ordannots]]), ] + } else { + sdata <- sdata[do.call(order, sdata[ordannots]), ] + } } + return(sdata$SampleOrderID) }