# Combination Matrix Axis for 'ggplot2' to Create 'UpSet' Plots

Replace the standard x-axis in 'ggplots' with a combination matrix to visualize complex set overlaps. 'UpSet' has introduced a new way to visualize the overlap of sets as an alternative to Venn diagrams. This package provides a simple way to produce such plots using 'ggplot2'. In addition it can convert any categorical axis into a combination matrix axis.

Plot a combination matrix instead of the standard x-axis and create UpSet plots with ggplot2.

## Installation

You can install the released version of ggupset from CRAN with:

## Example

This is a basic example which shows you how to solve a common problem:

In the following I will work with a tidy version of the movies dataset from ggplot. It contains a list of all movies in IMDB, their release data and other general information on the movie. It also includes a `list` column that contains annotation to which genre a movie belongs (Action, Drama, Romance etc.)

`ggupset` makes it easy to get an immediate impression how many movies are in each genre and their combination. For example there are slightly more than 1200 Dramas in the set, more than 1000 which don't belong to any genre and ~170 that are Comedy and Drama.

`scale_x_upset` is a neat function that does several things at once to create a useful x-axis. I will now step by step recreate the plot to demonstrate some of the underlying ideas.

The first important idea is to realize that a list column is just as good as a character vector with the list elements collapsed

We can easily make a plot using the strings as categorical axis labels

Because the process of collapsing list columns into delimited strings is fairly generic, I provide a new scale that does this automatically (`scale_x_mergelist()`).

But the problem is that it can be difficult to read those labels. Instead I provide a third function that replaces the axis labels with a combination matrix (`axis_combmatrix()`).

One thing that is only possible with the `scale_x_upset()` function is to automatically order the categories and genres by `freq` or by `degree`.

## Styling

To make publication ready plots, you often want to have complete control how each part of a plot looks. This is why I provide an easy way to style the combination matrix. Simply add a `theme_combmatrix()` to the plot.

## Alternative Packages

There is already a package called `UpSetR` (GitHub, CRAN) that provides very similar functionality and that heavily inspired me to write this package. It produces a similar plot with an additional view that shows the overall size of each genre.

The `UpSetR` package provides a lot convenient helpers around this kind of plot; the main advantage of my package is that it can be combined with any kind of ggplot that uses a categorical x-axis. This additional flexibility can be useful if you want to create non-standard plots. The following plot for example shows when movies of a certain genre were published.

#### 1. Complex experimental design

The combination matrix axis can be used to show complex experimental designs, where each sample got a combination of different treatments.

#### 2. Aggregation of information

`dplyr` currently does not support list columns as grouping variables. In that case it makes sense to collapse it manually and use the `axis_combmatrix()` function to get a good looking plot.

# v0.1.0 (Initial release)

• Implement combination matrix for x axis
• Provide convenience functions to create UpSet plots and handle list columns

# Reference manual

install.packages("ggupset")

0.3.0 by Constantin Ahlmann-Eltze, a year ago

https://github.com/const-ae/ggupset

Report a bug at https://github.com/const-ae/ggupset/issues

Browse source code at https://github.com/cran/ggupset

Authors: Constantin Ahlmann-Eltze [aut, cre]

Documentation:   PDF Manual