From 51b6303ecdadf70567fd7cfcdfc48930f7bc0e50 Mon Sep 17 00:00:00 2001 From: jonathan dreyfuss Date: Mon, 29 Jan 2024 19:44:01 -0500 Subject: [PATCH] fix dotplot_pwys "bug" where it didn't reorder pwys although pathways were usually already ordered by their combined p-values --- DESCRIPTION | 2 +- R/dotplot_pwys.R | 4 ++-- tests/testthat/test-dotplot_pwys.R | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2ebfaec..ccab093 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ezlimmaplot Title: Bioinformatics plots using limma and ggplot2, some from output of ezlimma -Version: 0.0.2.9004 +Version: 0.0.3.9000 Authors@R: c(person("Jonathan", "Dreyfuss", role = c("aut", "cre"), email = "jdreyf@bu.edu"), person("Hui", "Pan", role = "aut"), person("Grace", "Daher", role="ctb")) diff --git a/R/dotplot_pwys.R b/R/dotplot_pwys.R index 2a11595..255444b 100644 --- a/R/dotplot_pwys.R +++ b/R/dotplot_pwys.R @@ -53,8 +53,8 @@ dotplot_pwys <- function(tab, prefix.v=NULL, name = NA, type.sig=c("p", "FDR"), # could do this in for loop separately for Mixed and not Mixed, but here I only need to do it once # then subset to 1st ntop rows: this does not cause error or warning even if ntop > nrow(ds) ds <- ds |> dplyr::arrange(!!rlang::sym(type.sig)) |> - dplyr::filter(!!rlang::sym(type.sig) < cut.sig) |> - dplyr::filter(Pwy %in% (ds |> dplyr::slice(1:ntop) |> dplyr::pull(Pwy))) + dplyr::filter(!!rlang::sym(type.sig) < cut.sig) + ds <- ds |> dplyr::filter(Pwy %in% (ds |> dplyr::slice(1:ntop) |> dplyr::pull(Pwy))) if (nrow(ds) == 0) stop("No pathways had ", type.sig, " < ", cut.sig, ".") pwy.max.nchar <- ds |> dplyr::pull(Pwy) |> nchar() |> max() diff --git a/tests/testthat/test-dotplot_pwys.R b/tests/testthat/test-dotplot_pwys.R index 2be40a6..df84b0f 100644 --- a/tests/testthat/test-dotplot_pwys.R +++ b/tests/testthat/test-dotplot_pwys.R @@ -4,6 +4,10 @@ test_that("dotplot_pwy works", { expect_silent(dotplot_pwys(rc2, mixed="only", name="pwy")) rc.nomix <- rc2 |> dplyr::select(!contains("Mixed")) expect_silent(dotplot_pwys(rc.nomix, mixed="exclude", name="pwy")) + # make sure dotplot_pwys properly orders by p + res <- rc2 |> dplyr::arrange(desc(First3.p)) |> + dotplot_pwys(ntop=1) + expect_equal(unique(res$data$Pwy), "pwy1") unlink(x = "pwy_dotplot.pdf") expect_error(dotplot_pwys(rc2, name = NA, cut.sig = 10**-6))