From 395f5afff996cbad674e3b23d7d3e360967041e8 Mon Sep 17 00:00:00 2001 From: Stu Field Date: Tue, 19 Sep 2023 16:47:17 -0600 Subject: [PATCH] Make `.refactorData()` less chatty when unnecessary --- R/plotPDFbyGroup.R | 3 +-- R/plotVolcanoHTML.R | 4 +--- R/utils.R | 9 +++------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/R/plotPDFbyGroup.R b/R/plotPDFbyGroup.R index 1c3fd6f..5492b08 100644 --- a/R/plotPDFbyGroup.R +++ b/R/plotPDFbyGroup.R @@ -71,8 +71,7 @@ plotPDFbyGroup <- function(data, apt, group.var, cols, xlim = NULL, p <- data |> dplyr::select(!!group.var, apt) |> .refactorData() |> # this is about ghost levels - ggplot(aes(x = !!sym(apt), - color = !!group.var)) + + ggplot(aes(x = !!sym(apt), color = !!group.var)) + geom_density(aes(fill = !!group_var), alpha = ifelse(fill, 0.2, 1), linewidth = ifelse(fill, 0.1, 0.75), diff --git a/R/plotVolcanoHTML.R b/R/plotVolcanoHTML.R index d844682..383dc3f 100644 --- a/R/plotVolcanoHTML.R +++ b/R/plotVolcanoHTML.R @@ -93,9 +93,7 @@ plotVolcanoHTML.default <- function(data, ...) { #' variable name in `data` for the Target Names. #' @importFrom SomaDataIO rn2col col2rn #' @export -plotVolcanoHTML.data.frame <- function(data, - FC = signed.log2.fold.change, - p.vec = p.value, +plotVolcanoHTML.data.frame <- function(data, FC = signed.log2.fold.change, p.vec = p.value, cutoff = 0.05 / nrow(data), fc.cutoff = 1, main = NULL, x.lab = NULL, diff --git a/R/utils.R b/R/utils.R index 7a1ff4c..4678d8f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -54,13 +54,10 @@ for ( meta in nms ) { levs <- levels(data[[meta]]) data[[meta]] <- droplevels(data[[meta]]) - if ( interactive() ) { - levs2 <- levels(data[[meta]]) + sdiff <- setdiff(levs, levels(data[[meta]])) + if ( length(sdiff) > 0L && interactive() ) { .info( - paste("Dropping levels", - value(setdiff(levs, levs2)), - "from", - value(meta)) + paste("Dropping levels", value(sdiff), "from", value(meta)) ) } }