From f27c1113249d242d88920b72bb9072c4db691d9f Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:49:00 +0100 Subject: [PATCH] Improve performance when specific intersections are requested --- R/data.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/data.R b/R/data.R index 6dcd25c..8975a63 100644 --- a/R/data.R +++ b/R/data.R @@ -510,9 +510,16 @@ upset_data = function( unique(unlist(intersections_members)), NOT_IN_KNOWN_SETS ) + provided_intersection_sizes = sapply(intersections_members, length) + provided_intersection_sizes[intersections_members == NOT_IN_KNOWN_SETS] = 0 # TODO: this is slow and memory hungry; ideally we would only get the relevant intersection straight away! - possible_intersections = all_intersections_matrix(intersect, NULL, 0, Inf) + possible_intersections = all_intersections_matrix( + intersect, + NULL, + min(provided_intersection_sizes), + max(provided_intersection_sizes) + ) relevant_intersections = rownames(possible_intersections[ rowSums(possible_intersections[, sets_from_manual_intersections]) > 0, @@ -1057,4 +1064,4 @@ create_upset_abc_example = function() { rep(F, 2) ) ) -} \ No newline at end of file +}