Skip to content

Commit

Permalink
Fix #90 (hide empty sets with non-default mode filtering)
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jan 4, 2021
1 parent e405c02 commit de0f165
Show file tree
Hide file tree
Showing 5 changed files with 871 additions and 398 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Bug fixes:
- Filtering by degree when using non-default mode and `intersections='all'` now correctly accounts for all observations (#89)
- Empty sets/groups are now correctly removed when filtering with a non-default mode (#90)

# Version 1.0.0

Expand Down
15 changes: 9 additions & 6 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,21 @@ upset_data = function(
n_intersections=n_intersections
)

data_subset = data[
data[, paste0('in_', solve_mode(mode))]
&
(data$intersection %in% names(intersections_by_size_trimmed)),
]

# 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]
is_non_empty = sapply(itersect_data, any)
empty_groups = names(itersect_data[!is_non_empty])

if (length(empty_groups) != 0 && warn_when_dropping_groups) {
to_display = ifelse(
length(empty_groups) <= 5,
Expand Down
Loading

0 comments on commit de0f165

Please sign in to comment.