Skip to main content

UpSetPlotly

Generate UpSetPlot-style plots with Plotly.

Why another UpSet package for Python?

UpSetPlot is a fine package and is well maintained. I have used it before and haven't had any complaints. The reason I decided to make another package to generate UpSet plots is because another project I'm working on, MhcVizPipe, uses Plotly to generate plots as part of an HTML report. UpSetPlot only uses matplotlib. I wanted to have an UpSet plot in the reports, but I wanted it to match the style and format of the other figures in the report. I also didn't want to have matplotlib as a requirement when it was only being used for one of the many plots.

Usage

$ pip install UpSetPlotly
from upsetplotly import UpSetPlotly

samples = [[1, 2, 3, 4], [2, 3, 4], [2, 5, 6]]
names = ["sample 1", "sample 2", "sample 3"]

usp = UpSetPlotly(samples=samples, sample_names=names)
usp.plot()

The intersections can be ordered by passing order_by={'increasing', 'decreasing'}

usp.plot(order_by='decreasing')

Larger sets are okay too.

import random

names = [f'sample_{i}' for i in range(1, 6)]
samples = [[''.join(random.choices('abcdefghijk', k=3)) for x in range(random.randint(1000, 3000))] for i in range(5)]

usp = UpSetPlotly(samples, names)
usp.plot()

But there would soon be too many possible intersections to realistically visualize them all. We can pass intersection_limit='by_total 0.05' to filter out any intersections which are smaller that 5% of the total number of unique elements. Any float between 0 and 1 is acceptable.

usp.plot(order_by='increasing', intersection_limit='by_total 0.05')

Similarly, we can pass intersection_limit='by_sample 0.05 to filter out any intersections which do not comprise at least 5% of any sample.

usp.plot(order_by='increasing', intersection_limit='by_sample 0.05')

Additional data describing the elements can be passed to generate secondary plots above the UpSet plot.

all_elements = set()
all_elements.update(*[set(x) for x in samples])
additional_data = {element: random.normalvariate(0, 1) for element in all_elements}
usp.add_secondary_plot(data=additional_data, label='Random stuff', plot_type='box')

We can also do violin or swarm plots, or all three. Note that, annoyingly, we have to use html tags to create line breaks in the labels. This will keep them from colliding in this case.

usp = UpSetPlotly(samples, names)
usp.add_secondary_plot(data=additional_data, label='Random<br>stuff', plot_type='box')
usp.add_secondary_plot(data=additional_data, label='Random<br>stuff', plot_type='violin')
usp.add_secondary_plot(data=additional_data, label='Random<br>stuff', plot_type='swarm')
usp.plot()

Finally, you can change the color scheme (a bit). By passing the color argument to UpSetPlotly.plot, you set the base color for the image. Unfortunately you have to pass in either HEX values or an RGB string (e.g. 'rgb(..., ..., ...)')

usp.plot(color='#fcba03')
usp.plot(color='rgb(212, 87, 185)')

Metadata

Release files for UpSetPlotly 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for UpSetPlotly 0.1.7
File Size Uploaded
UpSetPlotly-0.1.7.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for UpSetPlotly 0.1.7
File Interpreter ABI Platform
UpSetPlotly-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / UpSetPlotly-0.1.7.tar.gz

Download URL UpSetPlotly-0.1.7.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7d95f18d668b1eeef15efc42981d28f53d65d909006463b32066b460b0d4e33f
BLAKE2b-256 checksum
How to use checksums
5b4819d5eaa1a7e9c9aedc13c182b928e294d39e9cd79915d112120b3bd5c17e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

Release files / UpSetPlotly-0.1.7-py3-none-any.whl

Download URL UpSetPlotly-0.1.7-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c1b5b82ddbcc7be6c0c0a71cae569202bf37991d4379d102800d48afad66e35
BLAKE2b-256 checksum
How to use checksums
6351236d2bfeb2220679b4efaaeeb6f5081a2853ad5774dbd8f888c999ae4c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page