Skip to content

Commit

Permalink
Fix regression causing problems for non-observed sets
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jan 4, 2021
1 parent 269fc41 commit 3a37f12
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 17 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.0
Version: 1.0.2
Authors@R: person(
"Michał", "Krassowski", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9638-7785"))
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Version 1.0.2

2021-01-04

Bug fixes:
- Fixed regression of non-observed sets causing "no vector columns were selected" caused by fix addressing #90
- Reduced length of file names for some test doppelgangers

# Version 1.0.1

2021-01-04
Expand Down
17 changes: 8 additions & 9 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ upset_data = function(

if (intersections == 'observed') {
intersections_matrix = observed_intersections_matrix
colnames(intersections_matrix) = intersect
} else {
if (length(intersect) > max_combinations_n && max_degree == Inf) {
stop('Your memory is likely to explode, please adjust max_combinations_n if you wish to proceed anyways, or better set max_degree')
Expand Down Expand Up @@ -528,15 +529,13 @@ upset_data = function(
# once the unused intersections are removed, we need to decide
# if the groups not participating in any of the intersections should be kept or removed
if (!keep_empty_groups) {
data_subset = data[
data[, paste0('in_', solve_mode(mode))]
&
# intersections_by_size_trimmed is a partial misnomer, here it means "regions_by_size"
# see: https://github.com/krassowski/complex-upset/issues/90
(data$exclusive_intersection %in% names(intersections_by_size_trimmed)),
]

itersect_data = data_subset[, intersect]
# see: https://github.com/krassowski/complex-upset/issues/90
itersect_data = data.frame(
intersections_matrix[names(intersections_by_size_trimmed), ] == 1,
check.names=FALSE,
check.rows=FALSE
)

is_non_empty = sapply(itersect_data, any)
empty_groups = names(itersect_data[!is_non_empty])

Expand Down
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.
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: 23 additions & 4 deletions tests/testthat/test-other-visual.R
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ test_that("Counts are visible on top of highlighted bars", {
test_that("Filtering by degree in non-default mode with all intersections shows all observations", {
abc_data = create_upset_abc_example()
expect_doppelganger(
title='All union members are accounted for with intersections=all, mode=union, and max_degree=1',
title='Size for intersections=all, mode=union, and max_degree=1',
upset(
abc_data,
colnames(abc_data),
Expand All @@ -243,7 +243,7 @@ test_that("Filtering by degree in non-default mode with all intersections shows

test_that("Empty sets are removed during filtering with non-default mode", {
expect_doppelganger(
"Empty sets are removed during filtering with non-default mode",
"Empty sets are removed when filtering non-default mode",
(
upset(
movies, genres,
Expand Down Expand Up @@ -277,7 +277,26 @@ test_that("Missing values are converted to FALSE", {
)

expect_doppelganger(
"Degrees are filtered (min_degree=1) even if user indicated non-presence by NA",
"Degrees are filtered (min_degree=1) even if user used NA",
upset(df, colnames(df)[1:2], min_degree=1)
)
})
})


test_that("Sets of generated intersections are ok when sets not observed alone", {
expect_doppelganger(
"Sets with intersections='all' are ok when not observed",
upset(
# remove movies which belong to one set only
movies[rowSums(movies[, genres]) != 1, ],
genres,
mode='inclusive_union',
# generate all possible unions, enabling visualisation of unions with degree = 1
intersections='all',
keep_empty_groups=FALSE,
# require unions of degree 1
min_degree=1,
max_degree=1
)
)
})

0 comments on commit 3a37f12

Please sign in to comment.