Learn R Programming

UpSet.js as R HTMLWidget

CRAN Github Actions Open in Binder Open Docs Open example

This is a HTMLWidget and Plot.ly Dash wrapper around the JavaScript library UpSet.js and an alternative implementation of UpSetR.

This package is part of the UpSet.js ecosystem located at the main Github Monorepo.

Installation

# CRAN version
install.packages('upsetjs')
# or
devtools::install_url("https://github.com/upsetjs/upsetjs_r/releases/latest/download/upsetjs.tar.gz")

library(upsetjs)

Example

listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13), two = c(1, 2, 4, 5, 10), three = c(1, 5, 6, 7, 8, 9, 10, 12, 13))
upsetjs() %>% fromList(listInput) %>% interactiveChart()

see also UpSetJS.Rmd

Shiny Example

library(shiny)
library(upsetjs)

listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13),
                  two = c(1, 2, 4, 5, 10),
                  three = c(1, 5, 6, 7, 8, 9, 10, 12, 13))

ui <- fluidPage(
  titlePanel("UpSet.js Shiny Example"),
  upsetjsOutput("upsetjs1"),
)

server <- function(input, output, session) {
  # render upsetjs as interactive plot
  output$upsetjs1 <- renderUpsetjs({
    upsetjs() %>% fromList(listInput) %>% interactiveChart()
  })
}

# Run the application
shinyApp(ui = ui, server = server)

see also Shiny Examples

Dash Example

library(dash)
library(dashHtmlComponents)
library(upsetjs)

app <- Dash$new()

app$layout(
    htmlDiv(
        list(
            htmlH1("Hello UpSet.js + Dash"),
            upsetjsDash(id = "upset") %>% fromList(list(a = c(1, 2, 3), b = c(2, 3)))
                %>% interactiveChart(),
            htmlDiv(id = "output")
        )
    )
)
app$callback(
    output = list(id = "output", property = "children"),
    params = list(input(id = "upset", property = "selection")),
    function(selection) {
        sprintf("You selected \"%s\"", selection$name)
    }
)

app$run_server()

TODO

see also Dash Examples

Documentation

the package documentation is located at Open Docs. An introduction vignette is at Open Vignette.

Venn Diagram

Besides the main UpSet.js plot also Venn Diagrams for up to five sets are supported. It uses the same input formats and has similar functionality in terms of interaction.

listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13), two = c(1, 2, 4, 5, 10), three = c(1, 5, 6, 7, 8, 9, 10, 12, 13))
upsetjsVennDiagram() %>% fromList(listInput) %>% interactiveChart()

see also Venn.Rmd

Karnaugh Maps Diagram

Besides the main UpSet.js plot also a variant of a Karnaugh Map is supported. It uses the same input formats and has similar functionality in terms of interaction.

listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13), two = c(1, 2, 4, 5, 10), three = c(1, 5, 6, 7, 8, 9, 10, 12, 13))
upsetjsKarnaughMap() %>% fromList(listInput) %>% interactiveChart()

see also KMap.Rmd

Dev Environment

requirements:

  • R with packages: devtools, pkgdown
  • pandoc
npm i -g yarn
yarn install
yarn sdks vscode

Building

yarn lint
yarn build

R Package

yarn style:r
yarn lint:r
yarn check:r
yarn build:r

or in R

devtools::load_all()
styler::style_pkg()
lintr::lint_pkg()
devtools::check()
devtools::document()
devtools::build()

R Package Website

will be automatically updated upon push

yarn docs:r

or in R

devtools::build_site()

Release

use release-it

yarn release
Rscript -e "devtools::release()"

Privacy Policy

UpSet.js is a client only library. The library or any of its integrations doesn't track you or transfers your data to any server. The uploaded data in the app are stored in your browser only using IndexedDB. The Tableau extension can run in a sandbox environment prohibiting any server requests. However, as soon as you export your session within the app to an external service (e.g., Codepen.io) your data will be transferred.

License / Terms of Service

Commercial license

If you want to use UpSet.js for a commercial application or in a commercial environment, the commercial license is the appropriate license. Contact @sgratzl for details.

Open-source license

This library is released under the GNU AGPLv3 version to be used for private and academic purposes. In case of a commercial use, please get in touch regarding a commercial license.

Copy Link

Version

Install

install.packages('upsetjs')

Monthly Downloads

249

Version

1.11.1

License

AGPL-3 | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

July 13th, 2022

Functions in upsetjs (1.11.1)

clearQueries

clears the list of queries for incremental updates
extractSetsFromDataFrame

extract the sets from a data frame (rows = elems, columns = sets, cell = contained)
interactiveChart

make it an interactive chart
queryLegend

renders a legend for the queries
asCombination

creates a new UpSet set combination structure
addQuery

adds a new query to the plot
addCategoricalAttribute

adds a new query to the plot
chartVennLabels

specify chart labels
fromList

generates the sets from a lists object
chartTheme

specify theming options
addNumericAttribute

adds a new numeric attribute to the plot
upsetjsVennDiagram

upsetjs - factory for UpSet.js Venn Diagram HTMLWidget
upsetjsSizingPolicy

upsetjs sizing policy
chartStyleFlags

specify chart flags
generateUnions

configure the generation of the unions
generateIntersections

configure the generation of the intersections
setSelection

sets the selection of the chart
chartProps

generic set chart props
chartKarnaughMapLabels

specify chart labels
getCombinations

extract the vector of combinations
clearAttributes

clears the list of attributes for incremental updates
chartVennLayout

specify the chart venn layout
upsetjsEulerDiagram

upsetjs - factory for UpSet.js Euler Diagram HTMLWidget
setSets

set the vector of sets
chartKarnaughMapLayout

specify the chart karnaugh map layout
upsetjsEulerDiagramProxy

reactive helper to update an upsetjs euler diagram in place
reexports

Objects exported from other packages
getElements

extract the vector of elements
renderUpsetjs

Shiny render bindings for upsetjs
setAttributes

set the attributes
upsetjsOutput

Output and render functions for using UpSet.js within Shiny applications and interactive Rmd documents.
setCombinations

set the vector of combinations
upsetjsProxy

reactive helper to update an upsetjs inplace
chartLabels

specify chart labels
chartLayout

specify the chart layout
generateDistinctIntersections

configure the generation of the distinct intersections
fromDataFrame

extract the sets from a data frame (rows = elems, columns = sets, cell = contained)
fromExpression

generates the sets from a lists object that contained the cardinalities of both sets and combinations (&)
got

Games of Thrones Character dataset for UpSet.js
getSets

extract the vector of sets
setElements

set the vector of elements
setQueries

set the queries
upsetjsVennDiagramProxy

reactive helper to update an upsetjs venn diagram in place
upsetjsDash

create a new upsetjs dash adapter
upsetjsKarnaughMap

upsetjs - factory for UpSet.js Karnaugh Map HTMLWidget
upsetjs

Upset.js
upsetjsKarnaughMapProxy

reactive helper to update an upsetjs karnaugh map diagram in place
chartFontSizes

specify chart font sizes
asSet

creates a new UpSet set structure