diff --git a/R/compute_multi_screen_profile.R b/R/compute_multi_screen_profile.R index 7502a22..b899ebb 100644 --- a/R/compute_multi_screen_profile.R +++ b/R/compute_multi_screen_profile.R @@ -69,7 +69,13 @@ compute_multi_screen_profile <- function(data = NULL, (direction == "up" & .data$log2FC > 0) | (direction == "down" & .data$log2FC < 0) ) %>% - arrange(if (direction == "both") desc(abs(.data$log2FC)) else desc(.data$log2FC)) %>% + arrange( + dplyr::case_when( + direction == "both" ~ -abs(.data$log2FC), + direction == "up" ~ -.data$log2FC, + direction == "down" ~ .data$log2FC + ) + ) %>% slice(seq_len(n_genes_profile)) %>% pull(.data$gene) ) %>% setNames(target)