Skip to content

Commit

Permalink
fix dotplot_pwys "bug" where it didn't reorder pwys
Browse files Browse the repository at this point in the history
although pathways were usually already ordered by their combined p-values
  • Loading branch information
jdreyf committed Jan 30, 2024
1 parent 8b5d934 commit 51b6303
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"),
person("Hui", "Pan", role = "aut"),
person("Grace", "Daher", role="ctb"))
Expand Down
4 changes: 2 additions & 2 deletions R/dotplot_pwys.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-dotplot_pwys.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 51b6303

Please sign in to comment.