From b0e564e037a3652860ac28763f2fc5dc84402f56 Mon Sep 17 00:00:00 2001 From: dtm2451 Date: Mon, 16 Sep 2024 14:09:16 -0400 Subject: [PATCH 1/2] remove 'aes_string()' and clean warnings from tests --- R/plotDeltaDistribution.R | 4 ++-- R/plotScoreDistribution.R | 2 +- tests/testthat/test-heatmap.R | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/R/plotDeltaDistribution.R b/R/plotDeltaDistribution.R index 0e4355a..d5ac457 100644 --- a/R/plotDeltaDistribution.R +++ b/R/plotDeltaDistribution.R @@ -168,7 +168,7 @@ plotDeltaDistribution <- function( aes.jit <- NULL if (!is.null(pruned)) { df$pruned <- pruned - aes.jit <- ggplot2::aes_string(color = "pruned") + aes.jit <- ggplot2::aes(color = .data$pruned) } # Trim dataframe by labels: @@ -180,7 +180,7 @@ plotDeltaDistribution <- function( } # Making the violin plots. - p <- ggplot2::ggplot(data = df, ggplot2::aes_string(x="x", y="values")) + + p <- ggplot2::ggplot(data = df, ggplot2::aes(x=.data$x, y=.data$values)) + ggplot2::xlab("") if (!is.null(pruned)) { diff --git a/R/plotScoreDistribution.R b/R/plotScoreDistribution.R index cf92ee4..b47d087 100644 --- a/R/plotScoreDistribution.R +++ b/R/plotScoreDistribution.R @@ -206,7 +206,7 @@ plotScoreDistribution <- function( # Making the violin plots. p <- ggplot2::ggplot(data = df, - ggplot2::aes_string(x = "cell.calls", y = "values", fill = "cell.calls")) + + ggplot2::aes(x = .data$cell.calls, y = .data$values, fill = .data$cell.calls)) + ggplot2::scale_fill_manual( name = labels.title, breaks = c("assigned", "pruned", "other"), diff --git a/tests/testthat/test-heatmap.R b/tests/testthat/test-heatmap.R index cd626d3..481d711 100644 --- a/tests/testthat/test-heatmap.R +++ b/tests/testthat/test-heatmap.R @@ -112,7 +112,7 @@ test_that("heatmap is adjusted properly when 'labels.use' yields 1 or 0 labels", paste0("disabling normalization")) expect_equal( - suppressMessages(plotScoreHeatmap(results = pred, silent = TRUE, + suppressWarnings(plotScoreHeatmap(results = pred, silent = TRUE, labels.use = c("A"), color = colorRampPalette(c("red", "blue"))(33), # proximal to normalization being turned off return.data = TRUE)$color), @@ -124,7 +124,7 @@ test_that("heatmap is adjusted properly when 'labels.use' yields 1 or 0 labels", paste0("ignoring 'labels.use'")) expect_equal( - nrow(suppressMessages(plotScoreHeatmap(results = pred, silent = TRUE, + nrow(suppressWarnings(plotScoreHeatmap(results = pred, silent = TRUE, labels.use = c("a"), return.data = TRUE)$mat)), 5) @@ -349,8 +349,10 @@ test_that("heatmap multi-ref - Other typical adjustments throw no unexpected err expect_s3_class(plotScoreHeatmap(results = combined, normalize = FALSE), "gtable") - expect_s3_class(plotScoreHeatmap(results = combined, + expect_warning(out <- plotScoreHeatmap(results = combined, labels.use = c("A", "a")), + "disabling normalization") + expect_s3_class(out, "gtable") expect_s3_class(plotScoreHeatmap(results = combined, max.labels = 3), From 8bcbf58b480f871ac4ad7115233fe751d3705b64 Mon Sep 17 00:00:00 2001 From: dtm2451 Date: Mon, 16 Sep 2024 14:47:06 -0400 Subject: [PATCH 2/2] declare .data globalVariable --- R/utils.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/utils.R b/R/utils.R index 80bfdec..9ae0a49 100644 --- a/R/utils.R +++ b/R/utils.R @@ -84,3 +84,5 @@ as.matrix(x) } } + +utils::globalVariables(".data")