Skip to content

Commit 667e0a9

Browse files
authored
Merge pull request #123 from krassowski/fix-aesthetics-assignment-for-query
Fix assignment of aesthetics by `upset_query`, release 1.3.0
2 parents 112a2e0 + 8ccdb19 commit 667e0a9

File tree

7 files changed

+5606
-18
lines changed

7 files changed

+5606
-18
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
os: [ubuntu, macos]
17-
r: [3.6, 4.0]
17+
r: ['3.6', '4.0']
1818

1919
steps:
2020
- uses: actions/checkout@v2

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ComplexUpset
22
Type: Package
33
Title: Create Complex UpSet Plots Using 'ggplot2' Components
4-
Version: 1.2.1.9000
4+
Version: 1.3.0
55
Authors@R: person(
66
"Michał", "Krassowski", email = "[email protected]", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0002-9638-7785"))

NEWS.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Version 1.3.0
22

3-
unreleased
3+
2021-06-06
44

55
Changes:
66
- sets on intersection matrix can now be highlighted using `upset_query()` #115
77

88
Bug fixes:
99
- alleviate visual glitch of `geom_segment` in intersections matrix showing up with an outline #113
10+
- fixed aesthetics assigned by `upset_query()` which was sometimes not behaving as expected #123
1011

1112
# Version 1.2.1
1213

@@ -26,8 +27,8 @@ Bug fixes:
2627
Major improvements:
2728
- manually specified intersections will now display empty intersections and non-exclusive intersections correctly #109
2829
- manually specified intersections do not require modifying the `intersect` argument to obtain the intended result any longer #109
29-
- stripes size and other attributes of underlying `geom_segment()` can now be customized with new function: `upset_stripes()` #111
30-
- stripes color and other attributes can now be mapped to data #111
30+
- stripes size and other attributes of underlying `geom_segment()` can now be customised with new function: `upset_stripes()` #111
31+
- stripes colour and other attributes can now be mapped to data #111
3132

3233
Minor improvements:
3334
- data.table can be passed instead of data.frame (the conversion will be performed automatically) #105
@@ -76,7 +77,7 @@ Bug fixes:
7677

7778
Changes:
7879
- Lists with computed sizes are now returned in a single list called `sizes` by `upset_data()`
79-
- Set sizes are now **not** filtered by default when selecting intersections by `min_*` or `max_*` criteria. Pass `filter_intersections=TRUE` to `upset_set_sizes()` to restore the previous behavior
80+
- Set sizes are now **not** filtered by default when selecting intersections by `min_*` or `max_*` criteria. Pass `filter_intersections=TRUE` to `upset_set_sizes()` to restore the previous behaviour
8081
- Union sizes are now calculated before data trimming which provides more accurate ratio estimates
8182
- Added examples for Venn diagrams which are now covered by automated tests to protect against regressions
8283
- Removed `upset_data()` `intersected` member to avoid needless duplication of the data frames; access `with_sizes` instead
@@ -91,7 +92,7 @@ New features:
9192

9293
Bug fixes:
9394
- Modes passed to `upset()` are now also used for sorting and trimming
94-
- Size calculation for modes was optimized for better performance
95+
- Size calculation for modes was optimised for better performance
9596
- User-added layers are now shown on top of `intersection_size()` and `intersection_union()`
9697
- Column names are no longer modified when supplying to `ggplot2` allowing to easily use them in annotations (#82)
9798

@@ -107,7 +108,7 @@ Changes:
107108
2020-12-20
108109

109110
New features:
110-
- Intersection modes were formalized with the default remaining `exclusive_intersection` (alias `distinct`); additional modes are: `inclusive_intersection` (alias `intersect`), `inclusive_union` and `exclusive_union`; please read the [relevant part of the documentation](https://krassowski.github.io/complex-upset/articles/Examples_R.html#0-2-region-selection-modes) for details (#78).
111+
- Intersection modes were formalised with the default remaining `exclusive_intersection` (alias `distinct`); additional modes are: `inclusive_intersection` (alias `intersect`), `inclusive_union` and `exclusive_union`; please read the [relevant part of the documentation](https://krassowski.github.io/complex-upset/articles/Examples_R.html#0-2-region-selection-modes) for details (#78).
111112
- Simple Venn diagrams (for two or three sets) can now be constructed using same input (binary presence data frame) using pseudo geoms: `geom_venn_circle()`, `geom_venn_label_region()`, `geom_venn_label_set()`, `geom_venn_region()` and scales `scale_color_venn_mix()` and `scale_fill_venn_mix()`; while developed mostly for the documentation needs, it provides unique capability of highlighting relevant regions of the Venn diagram and placing observations within appropriate regions (which allows to demonstrate their attributes with appropriate aesthetics mapping).
112113

113114
Changes:
@@ -129,7 +130,7 @@ Bug fixes:
129130
- `upset_set_size(geom=geom_bar(aes(fill=mpaa, x=group)))`
130131
- Intersections can now be sorted by multiple criteria, e.g. first by degree and then by cardinality: `sort_intersections_by=c('degree', 'cardinality')` (#47)
131132
- Breaking: `dot_size` argument was removed. Use `matrix=intersection_matrix(geom=geom_point(size=5))` instead
132-
- Intersection matrix can now be customized, including the points (e.g. changing shape to squares), segments (e.g. using dotted line) and outlines (changing color) allowing to create [Example 5.4](https://krassowski.github.io/complex-upset/articles/Examples_R.html):
133+
- Intersection matrix can now be customised, including the points (e.g. changing shape to squares), segments (e.g. using dotted line) and outlines (changing color) allowing to create [Example 5.4](https://krassowski.github.io/complex-upset/articles/Examples_R.html):
133134
> ![](https://raw.githubusercontent.com/krassowski/complex-upset/master/tests/figs/examples/example-5-4-adjusting-the-intersection-matrix-1.svg)
134135
135136
# Version 0.7.4

R/upset.R

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,15 @@ add_highlights_to_geoms = function(geoms, highlight_geoms, highlight_data, annot
817817
}
818818

819819
# reorder to match the data order:
820+
821+
# fix for the bug https://github.com/krassowski/complex-upset/issues/122
822+
if (!is.factor(highlight_data[[kind]])) {
823+
highlight_data[[kind]] = as.factor(highlight_data[[kind]])
824+
}
825+
data_order = levels(highlight_data[, kind])
826+
820827
params = params[
821-
match(unique(highlight_data[, kind]), params$query),
828+
match(data_order, params$query),
822829
colnames(params) != 'query',
823830
drop=FALSE
824831
]
@@ -1216,14 +1223,20 @@ upset = function(
12161223
}
12171224

12181225
if (show_overall_sizes) {
1219-
overall_sizes_queries = set_queries(queries_for(queries, 'overall_sizes'), data$sanitized_labels)
1220-
overall_sizes_highlights_data = get_highlights_data(data$presence, 'group', overall_sizes_queries)
1226+
set_sizes_data = data$presence[data$presence$group %in% data$plot_sets_subset, ]
1227+
1228+
if (set_sizes$filter_intersections) {
1229+
set_sizes_data = set_sizes_data[set_sizes_data$intersection %in% data$plot_intersections_subset, ]
1230+
}
12211231

1232+
overall_sizes_queries = set_queries(queries_for(queries, 'overall_sizes'), data$sanitized_labels)
1233+
overall_sizes_highlights_data = get_highlights_data(set_sizes_data, 'group', overall_sizes_queries)
12221234
if (nrow(overall_sizes_queries) != 0) {
12231235
highlight_geom = set_sizes$highlight_geom
12241236
if (!inherits(highlight_geom, 'list')) {
12251237
highlight_geom = list(highlight_geom)
12261238
}
1239+
overall_sizes_highlights_data$group = factor(overall_sizes_highlights_data$group)
12271240
geom = add_highlights_to_geoms(
12281241
set_sizes$geom,
12291242
highlight_geom,
@@ -1241,12 +1254,6 @@ upset = function(
12411254
default_scale = scale_y_reverse()
12421255
}
12431256

1244-
set_sizes_data = data$presence[data$presence$group %in% data$plot_sets_subset, ]
1245-
1246-
if (set_sizes$filter_intersections) {
1247-
set_sizes_data = set_sizes_data[set_sizes_data$intersection %in% data$plot_intersections_subset, ]
1248-
}
1249-
12501257
set_sizes$layers = c(
12511258
matrix_background_stripes(data, stripes, 'vertical'),
12521259
geom,

0 commit comments

Comments
 (0)