Skip to content

Commit

Permalink
Merge pull request #117 from krassowski/fix-venn-metadata
Browse files Browse the repository at this point in the history
Fix metadata order in arrange_venn
  • Loading branch information
krassowski authored Apr 25, 2021
2 parents 9701a27 + 7f12cd0 commit 0554451
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 301 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ComplexUpset
Type: Package
Title: Create Complex UpSet Plots Using 'ggplot2' Components
Version: 1.2.0
Version: 1.2.1
Authors@R: person(
"Michał", "Krassowski", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9638-7785"))
Expand Down
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Version 1.2.1

2021-04-25

Bug fixes:
- fixed metadata order in data frame returned by `arrange_venn()` function #116

# Version 1.2.0

2021-04-03

Bux fixes:
Bug fixes:
- [critical] fixed display order of labels when using `encode_sets=TRUE` #110
- encoding of set names will now properly work around name conflicts #110

Expand Down
10 changes: 5 additions & 5 deletions R/venn.R
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ arrange_venn = function(

}
iteration = 1
prebious_ratios = c()
previous_ratios = c()

while (!large_enough) {

Expand All @@ -609,7 +609,7 @@ arrange_venn = function(
# reasonable convergence
large_enough = TRUE
# prevent infinite loops
} else if (slots_surplus_ratio < 0.01 || slots_surplus_ratio %in% prebious_ratios) {
} else if (slots_surplus_ratio < 0.01 || slots_surplus_ratio %in% previous_ratios) {
large_enough = TRUE
} else {
grid_size = new_grid_size
Expand All @@ -625,7 +625,7 @@ arrange_venn = function(
grid_size = as.integer(round(grid_size * factor))

}
prebious_ratios = c(slots_surplus_ratio, prebious_ratios)
previous_ratios = c(slots_surplus_ratio, previous_ratios)
iteration = iteration + 1
}

Expand Down Expand Up @@ -663,5 +663,5 @@ arrange_venn = function(
region_coords
}))

cbind(new_coords, data[, setdiff(colnames(data), sets)])
}
cbind(new_coords, data[match(rownames(new_coords), rownames(data)), setdiff(colnames(data), sets)])
}
2 changes: 1 addition & 1 deletion tests/figs/deps.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- vdiffr-svg-engine: 1.0
- vdiffr: 0.3.3
- freetypeharfbuzz: 0.2.5
- freetypeharfbuzz: 0.2.6
586 changes: 293 additions & 293 deletions tests/figs/examples/example-12-1-highlight-specific-elements-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions tests/testthat/test-other-visual.R
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,30 @@ test_that("Labels retain proper order when encoded", {
)
)
})


test_that("Metadata gets properly reordered for Venn diagrams", {
df = data.frame(
name = 1:20,
A = 1:20 %% 2 == 0,
B = 1:20 %% 3 == 0,
C = 1:20 %% 5 == 0
)

# this column is to track which rows have had TRUE in A
df$WasA = df$A

sets = c("A", "B", "C")
arr = arrange_venn(df, sets)

expect_doppelganger(
"Metadata gets properly reordered for Venn diagrams",
(
ggplot(arr)
+ theme_void()
+ geom_venn_circle(data=df, sets=sets, size=1)
+ geom_venn_label_set(df, sets=sets, aes(label=region), outwards_adjust=2.6)
+ geom_point(aes(x=x, y=y, color=WasA), size=3)
)
)
})

0 comments on commit 0554451

Please sign in to comment.