Skip to content

Commit

Permalink
Fix tests issues, improve performance and fialsafes
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jan 5, 2021
1 parent 3a37f12 commit df90dc9
Show file tree
Hide file tree
Showing 11 changed files with 20,661 additions and 20,304 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.0.2
Version: 1.0.3
Authors@R: person(
"Michał", "Krassowski", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9638-7785"))
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version 1.0.3

2021-01-05

Bug fixes:
- Major performance and memory use improvements, especially when using `intersections = 'all'`
- The `max_combinations_n` fail-safe was replaced by a more useful `max_combinations_datapoints_n` with more precise error message
- The atypical use case of filtering with `max_degree = 0` is now accepted again
- Fix tests using all the data (effectively union mode) rather than chosen mode data only

# Version 1.0.2

2021-01-04
Expand Down
224 changes: 140 additions & 84 deletions R/data.R

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions R/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ NULL
#' @param tests a named list with tests for specific variables, overwriting the default test
#' @param ignore a list with names of variables to exclude from testing
#' @param ignore_mode_columns whether the membership columns and size columns for all modes should be ignored
#' @param mode region selection mode; note that modes other than `exclusive_intersection` repeat observations in different test group, introducing dependencies. See `get_size_mode()` for accepted values.
#' @param ... passed to `upset_data()`
#' @export
compare_between_intersections = function(data, intersect, test=kruskal.test, tests=list(), ignore=list(), ignore_mode_columns=TRUE, ...) {
data = upset_data(data, intersect, ...)
compare_between_intersections = function(
data, intersect, test=kruskal.test, tests=list(),
ignore=list(), ignore_mode_columns=TRUE,
mode='exclusive_intersection', ...
) {
data = upset_data(data, intersect, mode=mode, ...)

isect = data$with_sizes
isect = isect[
(isect[, paste0('in_', mode)] == 1) & (isect$intersection %in% data$plot_intersections_subset),
]

modes = c(
'exclusive_intersection',
Expand Down
36,582 changes: 18,291 additions & 18,291 deletions tests/figs/examples/example-1-1-changing-modes-in-annotations-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,526 changes: 1,763 additions & 1,763 deletions tests/figs/examples/example-6-1-substituting-themes-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
255 changes: 255 additions & 0 deletions tests/figs/other-visual/inclusive-union-filtering-works-ok.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions tests/testthat/test-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,20 @@ test_that("upset_data() filters by min_size, max_size, min_degree and max_degree
Sys.setlocale("LC_COLLATE", old_locale)
})


test_that("fail-safe protects from out of memory errors when sing observations='all'", {
set_data <- create_upset_abc_example()

expect_error(
upset_data(set_data, colnames(set_data), intersections='all', max_combinations_datapoints_n=100),
'The number of combinations with degrees between 0 and3 (8.0e+00) multiplied by the number of observations (325) and columns (4) accounts to an upper bound of 1.0e+04 datapoints; such a high number may lead to out of memory errors (depending on the available RAM size). Please adjust `min_degree` and `max_degree`, remove unused columns, or adjust `max_combinations_datapoints_n` (if you wish to proceed anyways).
Note: filtering by size (`min_size` and/or `max_size`) or setting `n_intersections` reduces the memory requirements and if you already do that it may be safe to increase `max_combinations_datapoints_n`.',
fixed=TRUE
)

})


test_that("upset_data() works with a tibble", {
# see https://github.com/krassowski/complex-upset/issues/20
df = data.frame(
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-other-visual.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,16 @@ test_that("Sets of generated intersections are ok when sets not observed alone",
)
)
})


test_that("Inclusive union filtering works ok", {
expect_doppelganger(
"Inclusive union filtering works ok",
upset(
movies, genres,
n_intersections=5,
mode='exclusive_union',
keep_empty_groups=FALSE
)
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test_that("upset throws an informative error if filtering leads to empty dataset
)
expect_error(
upset(df, c('a', 'b', 'c', 'd'), max_degree=-1),
'No intersections left after filtering: provide `max_degree` >= 1 \\(you provoided: -1\\)'
'No intersections left after filtering: provide `max_degree` >= 0 \\(you provoided: -1\\)'
)
})

Expand Down
324 changes: 162 additions & 162 deletions vignettes/Examples.ipynb

Large diffs are not rendered by default.

0 comments on commit df90dc9

Please sign in to comment.