Skip to content

Commit e8bfa9c

Browse files
authored
Merge pull request #208 from nf-core/176-image-rendering-bug
Limit upset plot number of combinations
2 parents fa9075c + f1b9d21 commit e8bfa9c

File tree

1 file changed

+9
-3
lines changed
  • modules/local/combinebeds/filter/templates

1 file changed

+9
-3
lines changed

modules/local/combinebeds/filter/templates/filter.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,20 @@ def format_yaml_like(data: dict, indent: int = 0) -> str:
9898
continue
9999
memberships = series.to_list()
100100
dataset = upsetplot.from_memberships(memberships)
101+
102+
n_combinations = 50
103+
104+
# Limit to top n_combinations largest combinations if there are more than n_combinations
105+
if len(dataset) > n_combinations:
106+
dataset = dataset.nlargest(n_combinations)
107+
101108
upsetplot.plot(dataset,
102109
orientation='horizontal',
103110
show_counts=True,
104-
subset_size="count",
105-
min_degree=2,
106-
min_subset_size=min(50, int(n_bsjs * 0.02)))
111+
subset_size="count")
107112
plot_file = f"{prefix}_{col}.upset.png"
108113
plt.savefig(plot_file)
114+
plt.close()
109115

110116
image_string = base64.b64encode(open(plot_file, "rb").read()).decode("utf-8")
111117
image_html = f'<div class="mqc-custom-content-image"><img src="data:image/png;base64,{image_string}" /></div>'

0 commit comments

Comments
 (0)