Skip to content

Commit

Permalink
fix a bug of ordannots with multiple variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
ningbioinfo committed Oct 3, 2023
1 parent fd48c40 commit 021ea05
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 021ea05

Please sign in to comment.