• Stars
    star
    353
  • Rank 120,322 (Top 3 %)
  • Language
    R
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library for creating complex UpSet plots with ggplot2 geoms

ComplexUpset

test codecov CRAN_version Conda version DOI

Quick links: Documentation | Installation | R examples | Python examples

Showcase

Get all the goodies of UpSetR, but with full extensibility of ggplot2.

Example UpSet plot

Click here to display the source code
library(ggplot2)
library(ComplexUpset)

if(!require(ggplot2movies)) install.packages('ggplot2movies')
movies = ggplot2movies::movies
genres = c('Action', 'Animation', 'Comedy', 'Drama', 'Documentary', 'Romance')

upset(
    movies,
    genres,
    annotations = list(
        'Length'=ggplot(mapping=aes(x=intersection, y=length)) + geom_boxplot(),
        'Rating'=ggplot(mapping=aes(x=intersection, y=rating))
            # if you do not want to install ggbeeswarm, you can use geom_jitter
            + ggbeeswarm::geom_quasirandom(aes(color=log10(votes)))
            + geom_violin(width=1.1, alpha=0.5)
    ),
    queries=list(
        upset_query(
            intersect=c('Drama', 'Comedy'),
            color='red',
            fill='red',
            only_components=c('intersections_matrix', 'Intersection size')
        ),
        upset_query(
            set='Drama',
            fill='blue'
        ),
        upset_query(
            intersect=c('Romance', 'Drama'),
            fill='yellow',
            only_components=c('Length')
        )
    ),
    min_size=10,
    width_ratio=0.1
)

The full list of examples is available in the documentation; it also contains instructions for the use from Python.

Install

To get the most recent version, open R and run:

if(!require(devtools)) install.packages("devtools")
devtools::install_github("krassowski/complex-upset")

Alternatively, to get a stable CRAN release (which may be one version behind at times):

install.packages('ComplexUpset')

Or, if you use conda/mamba:

conda install -c conda-forge r-complexupset

How it compares to other packages?

  • UpSetR is a powerful tool and the pioneer in the UpSet visualisations; it was not designed to be extended with ggplot components. Unfortunately, the repository is no longer active (for two years now).
  • ggupset uses scales to convert a single plot to upsets plots, e.g. with scale_x_upset - a really nice approach, recommended for simple ggplot.
  • a cowplot-based upset was demonstrated in an online publication, however cowplot (a great tool at the time) got superseded by even greater tool: patchwork, which is what is used by ComplexUpset.
  • ComplexHeatmap also offers a way to generate UpSet plots with annotations; while not ggplot2-centered, it provides extensive customization options, with a clear API. It may be the best choice if you already use it for heatmaps.

Use whichever tool you find the most useful for your particular use. The rational of making this repository public is not only to share the code, but also to demonstrate how simple it is now to create complex visualisations with patchwork (without the need to learn the ggplot internals).

For the interactive use, check out the VCG/upset. Regardless of the tool chosen, you may want to cite (Lex et al, 2014) when using UpSet plots, especially in fields still dominated by Venn diagrams.

Get inspired

Here are example publications and preprints including figures generated with this library:

The list is not meant to be exhaustive, but representative of applications to different fields, and of different usage ideas. You are welcome to add your own publication by suggesting an edit.

Testing

The unit tests are run with testhat, and the visual "doppelganger" tests use vdiffr.

The test cases for visual tests are auto-generated from the examples in the documentation; after changing or adding an example, please run:

  • scripts/prepare_for_tests.sh to generate updated test cases, and
  • scripts/manage_visual_tests.sh to validate the generated images.

Acknowledgements

Originally developed in course of a DPhil programme in Women's & Reproductive Health at OxfordNuffieldWRH.

More Repositories

1

jupyterlab-go-to-definition

Navigate to variable's definition with a click in JupyterLab (or with a few key strokes)
TypeScript
214
star
2

jupyter-manim

manim cell magic for IPython/Jupyter to show the output video
Python
187
star
3

Anki-Night-Mode

Enabling studying at night with Anki - without eye strain
Python
72
star
4

jupyterlab-citation-manager

Citation Manager for JupyterLab using Zotero Web API
TypeScript
47
star
5

jupyter-helpers

A collection of helpers for Jupyter/IPython
Python
45
star
6

easy-entrez

Retrieve PubMed articles, text-mining annotations, or molecular data from >35 Entrez databases via easy to use Python package - built on top of Entrez E-utilities API.
Python
45
star
7

declarative-parser

Modern, declarative argument parser for Python 3.6+
Python
34
star
8

multi-omics-state-of-the-field

Analyses for "State of the field in multi-omics research: from computational needs to data mining and sharing"
Jupyter Notebook
24
star
9

Anki-TouchScreen

Touchscreen functionality for Anki
Python
22
star
10

nbpipeline

Snakemake-like pipeline manager for reproducible Jupyter Notebooks
Python
15
star
11

drug-disease-profile-matching

Multi-omics disease sub-type specific drug repositioning aided with expression signatures from ConnectivityMap
Jupyter Notebook
14
star
12

data-vault

IPython magic for simple, organized, compressed and encrypted: storage & transfer of files between notebooks.
Python
12
star
13

computational-notebooks-for-biomedical-research

NGSeminar on the use of Jupyter and R notebooks in biomedical research
Jupyter Notebook
11
star
14

anki_testing

A small utility for testing Anki 2.1 addons
Python
10
star
15

jupyterlab-dagitty

JupyterLab renderer of dagitty causal diagrams
TypeScript
10
star
16

gsea-api

Pandas API for multiple Gene Set Enrichment Analysis implementations in Python (GSEApy, cudaGSEA, GSEA)
Python
8
star
17

rpy2-complex-heatmap-grammar

Python heatmap interface using intuitive grammar of graphics, implemented as an rpy2 wrapper around ComplexHeatmap package.
Python
8
star
18

Anki-Zoom

Zoom add-on for Anki 2.1, forked from ospalh/anki-addons
Python
6
star
19

enhanced-multiprocessing

A wrapper around Python's multiprocessing, providing support for tqdm progress bars and shared arguments
Python
3
star
20

plotnine3d

3D geoms for plotnine (grammar of graphics in Python)
Python
3
star
21

jupyterlab-citation-data

Citation data for jupyterlab-citation-manager
Python
2
star
22

jupyterlab-voice-control

Voice control over JupyterLab and Jupyter notebooks
TypeScript
2
star
23

vmd-agr-parser

Simple script for plotting .agr (Grace) files created with VMD (Visual Molecular Dynamics). Allows export to csv/svg/png.
Python
1
star