UpSetPlot icon indicating copy to clipboard operation
UpSetPlot copied to clipboard

Specify maximum number of intersections to display

Open fairliereese opened this issue 4 years ago • 3 comments

Hi,

Apologies if this has already been implemented, but after going through the API documentation, I'm unable to find an option that limits the number of displayed intersections, which forces me to manually truncate my dataframe I'm trying to plot from.

If you can point me to an argument that lets me do this that would be great. If this is not already implemented, it certainly would be useful!

Thanks!

fairliereese avatar Dec 14 '21 19:12 fairliereese

min_subset_size, max_subset_size, min_degree and max_degree control the number of displayed intersections, but perhaps not in the way you want it parametrised, which sounds like max_n_subsets

jnothman avatar Dec 15 '21 04:12 jnothman

Gotcha. I think there would be utility in implementing such an option that would (hopefully) not be terribly difficult to do. Thanks!

fairliereese avatar Dec 15 '21 18:12 fairliereese

For anyone that wants to filter on e.g. the 10 largest intersections:

import numpy as np
from upsetplot import from_contents, from_memberships, from_indicators, plot


content = from_contents(data)
uniques, counts = np.unique(content.index, return_counts=True)

sorted_uniques = [x for _, x in sorted(zip(counts, uniques), reverse=True)]

plot(content.loc[sorted_uniques[:10]], sort_by=None)

Maarten-vd-Sande avatar Jan 31 '22 10:01 Maarten-vd-Sande

For anyone that wants to filter on e.g. the 10 largest intersections

Note that this will get the per-category totals wrong.

Adding the max_subset_rank parameter in #253, which is inclusive in the case of ties.

jnothman avatar Dec 28 '23 13:12 jnothman