diff --git a/modules/local/combinebeds/filter/templates/filter.py b/modules/local/combinebeds/filter/templates/filter.py index 911792ef..a9c5953d 100644 --- a/modules/local/combinebeds/filter/templates/filter.py +++ b/modules/local/combinebeds/filter/templates/filter.py @@ -98,14 +98,20 @@ def format_yaml_like(data: dict, indent: int = 0) -> str: continue memberships = series.to_list() dataset = upsetplot.from_memberships(memberships) + + n_combinations = 50 + + # Limit to top n_combinations largest combinations if there are more than n_combinations + if len(dataset) > n_combinations: + dataset = dataset.nlargest(n_combinations) + upsetplot.plot(dataset, orientation='horizontal', show_counts=True, - subset_size="count", - min_degree=2, - min_subset_size=min(50, int(n_bsjs * 0.02))) + subset_size="count") plot_file = f"{prefix}_{col}.upset.png" plt.savefig(plot_file) + plt.close() image_string = base64.b64encode(open(plot_file, "rb").read()).decode("utf-8") image_html = f'