From 5ecbd6c419990e5d937b9aa2e0f69750324bfaad Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Tue, 11 Feb 2025 13:37:35 +0000 Subject: [PATCH] Add tests --- R/plotHighestExprs.R | 3 ++- tests/testthat/test-plot-dimred.R | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/R/plotHighestExprs.R b/R/plotHighestExprs.R index 36d8be53..d29f8ea4 100644 --- a/R/plotHighestExprs.R +++ b/R/plotHighestExprs.R @@ -110,7 +110,8 @@ plotHighestExprs <- function(object, n = 50, colour_cells_by = color_cells_by, ## Create the plot and annotations. plot_most_expressed <- ggplot(df_exprs_by_cell_long, aes_to_use) + geom_point(alpha = 0.6, shape = 124) plot_most_expressed <- plot_most_expressed + labs(x=assay.type, y="Feature") + theme_bw(8) + - theme(legend.position = c(1, 0), legend.justification = c(1, 0), + theme(legend.position.inside = c(1, 0), + legend.justification = c(1, 0), axis.text.x = element_text(colour = "gray35"), axis.text.y = element_text(colour = "gray35"), axis.title.x = element_text(colour = "gray35"), diff --git a/tests/testthat/test-plot-dimred.R b/tests/testthat/test-plot-dimred.R index a10fe1be..bc2ba368 100644 --- a/tests/testthat/test-plot-dimred.R +++ b/tests/testthat/test-plot-dimred.R @@ -48,6 +48,19 @@ test_that("we can produce PCA scatterplots", { expect_ggplot(plotPCA(example_sce, bins = 10, colour_by = "Gene_0001")) expect_ggplot(plotPCA(example_sce, bins = 10, colour_by = "Gene_0001", hex = TRUE)) + + # truncating color scale + expect_ggplot(plotPCA(example_sce, min.value = 1)) + expect_ggplot(plotPCA(example_sce, min.value = "1")) + expect_ggplot(plotPCA(example_sce, min.value = factor(1))) + expect_ggplot(plotPCA(example_sce, min.value = factor("q1"))) + expect_ggplot(plotPCA(example_sce, min.value = "q1")) + + expect_ggplot(plotPCA(example_sce, max.value = 2)) + expect_ggplot(plotPCA(example_sce, max.value = "2")) + expect_ggplot(plotPCA(example_sce, max.value = factor(2))) + expect_ggplot(plotPCA(example_sce, max.value = factor("q90"))) + expect_ggplot(plotPCA(example_sce, max.value = "q90")) }) test_that("we can produce PCA pairplots", {