Skip to content

Commit 5e1c056

Browse files
authored
Merge pull request #4 from pawelqs/fix-ggevidence-plot-bug
Fix ggevidence plot bug
2 parents 2f7990b + e813d95 commit 5e1c056

File tree

5 files changed

+124
-3
lines changed

5 files changed

+124
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ user_manual/cache
44
*.swp
55
.Rhistory
66
.RData
7+
.Rproj.user/
78
/doc/
89
/Meta/

DESCRIPTION

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ VignetteBuilder: knitr
2222
Imports:
2323
beeswarm,tagcloud,XML,methods,plotwidgets,RColorBrewer,gplots,tibble,pheatmap,ggplot2,tidyr,purrr,rlang,tidyselect,ggrepel
2424
Suggests:
25-
testthat,knitr,rmarkdown,dplyr,pander,cowplot
25+
testthat,
26+
knitr,
27+
rmarkdown,
28+
dplyr,
29+
pander,
30+
cowplot,
31+
vdiffr
2632
RoxygenNote: 7.3.2
2733
Encoding: UTF-8

R/visualizations.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ ggEvidencePlot <- function(l, m, mset=NULL, filter=FALSE, unique=TRUE,
523523
mm <- map(mm, ~ .x[ .x %in% l_orig ])
524524

525525
coords <- imap_dfr(mm, ~ {
526-
pos <- sort(match(.x, l_orig)) - 1:length(.x)
526+
pos <- sort(match(.x, l_orig))
527527
pos <- rep(pos, each=2)
528528
pos <- c(1, pos, length(l_orig))
529529
y <- rep(c(0:length(.x)), each=2) / length(.x)
@@ -533,7 +533,7 @@ ggEvidencePlot <- function(l, m, mset=NULL, filter=FALSE, unique=TRUE,
533533
coords_segm <- imap_dfr(mm, ~ {
534534
.match <- match(.x, l_orig)
535535
.ord <- order(.match)
536-
x <- sort(.match) - 1:length(.x)
536+
x <- sort(.match)
537537
ret <- data.frame(x=x, y=-.1, xend=x, yend=0, "mod"=.y, label=.x[.ord], gene=.x[.ord])
538538
if(!is.null(gene.labels) && !gene.labels) {
539539
ret$label <- ""
Lines changed: 94 additions & 0 deletions
Loading

tests/testthat/test_visualisations.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,23 @@ data(tmod)
44
context("Visualisations")
55

66

7+
test_that("ggEvidencePlot works", {
8+
skip_if_not_installed("vdiffr")
9+
10+
genesets <- data.frame(
11+
gene_symbol = paste0("gene", 1:10),
12+
geneset = c(rep("diseaseA", 3), rep("diseaseB", 3), rep("diseaseC", 4))
13+
)
14+
ranked_genes <- paste0("gene", 1:10)
15+
16+
tmod_db <- makeTmodFromDataFrame(genesets)
17+
18+
p <- ggEvidencePlot(
19+
ranked_genes,
20+
m = c("diseaseA", "diseaseB"),
21+
mset = tmod_db,
22+
gene.labels = FALSE
23+
)
24+
25+
vdiffr::expect_doppelganger("ggEvidencePlot", p)
26+
})

0 commit comments

Comments
 (0)