UpSetR Documentation

repository·master·Indexed 21 days ago

https://github.com/hms-dbmi/upsetr

An R package for visualizing intersecting sets and their properties using the UpSet technique. It provides a matrix-based layout to represent set intersections, aggregates, and summary statistics, featuring the core `upset()` function and support for attribute plots and queries.

Tokens
834
Snippets
5
Records
5
Agent score
24%

What's inside UpSetR

  1. Install UpSetR

    master

    You can install the stable version of UpSetR from CRAN or the latest development version from GitHub.

    To install from CRAN:

    install.packages("UpSetR")

    To install the development version using devtools:

    devtools::install_github("hms-dbmi/UpSetR")
    install.packages("UpSetR")
  2. Use queries in UpSet plots

    master

    You can use the queries argument to highlight specific intersections or subsets within the UpSet plot. This is often used in conjunction with attribute.plots to compare specific groups (e.g., comparing 'War' movies vs 'Noir' movies).

    upset(movies, attribute.plots=list(gridrows = 100, ncols = 1, 
    plots = list(list(plot=histogram, x="AvgRating",queries=T),
    list(plot = scatter_plot, y = "AvgRating", x = "Watches", queries = T))), 
    sets = c("Action", "Adventure", "Children", "War", "Noir"),
    queries = list(list(query = intersects, params = list("War"), active = T),
    list(query = intersects, params = list("Noir"))))
  3. Load sample data from UpSetR

    master

    UpSetR includes built-in sample datasets for testing and demonstration. You can load them using system.file to locate the files within the installed package.

    Available datasets:

    • movies.csv: Movie data curated by GroupLens Lab.
    • mutations.csv: Mutation data for the 100 most mutated genes in a glioblastoma multiforme cohort.
    movies <- read.csv( system.file("extdata", "movies.csv", package = "UpSetR"), header=T, sep=";" )
    mutations <- read.csv( system.file("extdata", "mutations.csv", package = "UpSetR"), header=T, sep = "," )
  4. Generate basic UpSet plots

    master

    The core function for creating visualizations is upset(). It visualizes set intersections in a matrix layout.

    Example: Creating an UpSet plot for mutations with specific sets and ordering.

    upset(mutations, sets = c("PTEN", "TP53", "EGFR", "PIK3R1", "RB1"), sets.bar.color = "#56B4E9",
    order.by = "freq", empty.intersections = "on")
    upset(mutations, sets = c("PTEN", "TP53", "EGFR", "PIK3R1", "RB1"), sets.bar.color = "#56B4E9",
    order.by = "freq", empty.intersections = "on")
  5. Create UpSet plots with attribute plots

    master

    UpSetR allows you to add additional plots (like scatter plots or histograms) that represent attributes of the elements within the intersections using the attribute.plots argument.

    upset(movies,attribute.plots=list(gridrows=60,plots=list(list(plot=scatter_plot, x="ReleaseDate", y="AvgRating"),
    list(plot=scatter_plot, x="ReleaseDate", y="Watches"),list(plot=scatter_plot, x="Watches", y="AvgRating"),
    list(plot=histogram, x="ReleaseDate")), ncols = 2))