upsetjs / upsetjs_r Goto Github PK
View Code? Open in Web Editor NEW๐ htmlwidget R bindings for UpSet.js for rendering UpSet plots, Euler, and Venn Diagrams
Home Page: https://upset.js.org/integrations/r
License: Other
๐ htmlwidget R bindings for UpSet.js for rendering UpSet plots, Euler, and Venn Diagrams
Home Page: https://upset.js.org/integrations/r
License: Other
Hi, I would like to know if there is a way to manually order the sets. For example in the below pic. my upset plot is ordered by cardinality (from highest to lowest, bottom to top). Can I make it where the sets in purple are on the bottom then the teal sets, yellow then red at top?
I've tried setting order.by = "degree" in fromList() but that just orders the sets alphabetically.
Thanks!
the next upsetjs version will allow to specify title and description. Thus, those options should also be available in the R version
There seems to be an issue with specifying colors for the diagrams.
To Reproduce
When I execute the following code from the vignettes/colors.Rmd):
# devtools::install_url("https://github.com/upsetjs/upsetjs_r/releases/latest/download/upsetjs.tar.gz")
library(upsetjs)
listInput <- list(s1 = c('a', 'b', 'c', 'e', 'g', 'h', 'k', 'l', 'm'),
s2 = c('a', 'b', 'd', 'e', 'j'),
s3 = c('a', 'e', 'f', 'g', 'h', 'i', 'j', 'l', 'm'))
colors <- list(s1 = '#1f77b4', s2 = '#2ca02c', s3 = '#d62728',
`s1&s2` = '#9467bd', `s1&s3` = '#8c564b', `s2&s3` = '#e377c2',
`s1&s2&s3` = '#bcbd22')
render <- function(upsetjs) {
upsetjs %>% fromList(listInput, colors=colors) %>% chartTheme(selection.color="", has.selection.opacity=0.3) %>% interactiveChart()
}
v <- upsetjs() %>%
render()
v
Notice the black bars (s3&s2
and s1&s3&s2
).
Expected behavior
If I add an exhaustive list of set combinations then I get the expected plot:
# devtools::install_url("https://github.com/upsetjs/upsetjs_r/releases/latest/download/upsetjs.tar.gz")
library(upsetjs)
listInput <- list(
s1 = c('a', 'b', 'c', 'e', 'g', 'h', 'k', 'l', 'm'),
s2 = c('a', 'b', 'd', 'e', 'j'),
s3 = c('a', 'e', 'f', 'g', 'h', 'i', 'j', 'l', 'm'))
colors <- list(
s1 = '#1f77b4', s2 = '#2ca02c', s3 = '#d62728',
`s1&s2` = '#9467bd', `s2&s1` = '#9467bd',
`s1&s3` = '#8c564b', `s3&s1` = '#8c564b',
`s2&s3` = '#e377c2', `s3&s2` = '#e377c2',
`s1&s2&s3` = '#bcbd22', `s1&s3&s2` = '#bcbd22',
`s2&s1&s3` = '#bcbd22', `s2&s3&s1` = '#bcbd22',
`s3&s1&s2` = '#bcbd22', `s3&s2&s1` = '#bcbd22')
render <- function(upsetjs) {
upsetjs %>% fromList(listInput, colors=colors) %>% chartTheme(selection.color="", has.selection.opacity=0.3) %>% interactiveChart()
}
v <- upsetjs() %>%
render()
v
The issue may have to due with how sets are named (e.g. s3&s2
is found in the plot, but the colors
list contains s2&s3
= '#e377c2' which is not equivalent to s3&s2
(but seems to be intended to be? or the sorting of the sets is not anticipated?).
I haven't tested it, but I'd assume the same issue affects the coloring for the Venn and Euler plots.
ย | upsetjs 1.1.0: WARNING Build ID: upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 Platform: Fedora Linux, R-devel, clang, gfortran Submitted: 6 minutes 58.9 seconds ago Build time: 6 minutes 29.4 seconds WARNINGS: * checking Rd cross-references ... WARNING Non-file package-anchored link(s) in documentation object 'reexports.Rd': โ[magrittr]{%>%}โ See section 'Cross-references' in the 'Writing R Extensions' manual. | upsetjs 1.1.0: WARNING | Build ID: upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 Platform: Fedora Linux, R-devel, clang, gfortran Submitted: 6 minutes 58.9 seconds ago Build time: 6 minutes 29.4 seconds WARNINGS: * checking Rd cross-references ... WARNING Non-file package-anchored link(s) in documentation object 'reexports.Rd': โ[magrittr]{%>%}โ See section 'Cross-references' in the 'Writing R Extensions' manual. | Build ID: upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 Platform: Fedora Linux, R-devel, clang, gfortran Submitted: 6 minutes 58.9 seconds ago Build time: 6 minutes 29.4 seconds | Build ID: | upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 | Platform: | Fedora Linux, R-devel, clang, gfortran | Submitted: | 6 minutes 58.9 seconds ago | Build time: | 6 minutes 29.4 seconds | WARNINGS: * checking Rd cross-references ... WARNING Non-file package-anchored link(s) in documentation object 'reexports.Rd': โ[magrittr]{%>%}โ See section 'Cross-references' in the 'Writing R Extensions' manual.
-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | --
upsetjs 1.1.0: WARNING
Build ID: upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 Platform: Fedora Linux, R-devel, clang, gfortran Submitted: 6 minutes 58.9 seconds ago Build time: 6 minutes 29.4 seconds WARNINGS: * checking Rd cross-references ... WARNING Non-file package-anchored link(s) in documentation object 'reexports.Rd': โ[magrittr]{%>%}โ See section 'Cross-references' in the 'Writing R Extensions' manual. | Build ID: upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 Platform: Fedora Linux, R-devel, clang, gfortran Submitted: 6 minutes 58.9 seconds ago Build time: 6 minutes 29.4 seconds | Build ID: | upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 | Platform: | Fedora Linux, R-devel, clang, gfortran | Submitted: | 6 minutes 58.9 seconds ago | Build time: | 6 minutes 29.4 seconds | WARNINGS: * checking Rd cross-references ... WARNING Non-file package-anchored link(s) in documentation object 'reexports.Rd': โ[magrittr]{%>%}โ See section 'Cross-references' in the 'Writing R Extensions' manual.
Build ID: upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 Platform: Fedora Linux, R-devel, clang, gfortran Submitted: 6 minutes 58.9 seconds ago Build time: 6 minutes 29.4 seconds | Build ID: | upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41 | Platform: | Fedora Linux, R-devel, clang, gfortran | Submitted: | 6 minutes 58.9 seconds ago | Build time: | 6 minutes 29.4 seconds
Build ID: | upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41
Platform: | Fedora Linux, R-devel, clang, gfortran
Submitted: | 6 minutes 58.9 seconds ago
Build time: | 6 minutes 29.4 seconds
WARNINGS: * checking Rd cross-references ... WARNING Non-file package-anchored link(s) in documentation object 'reexports.Rd': โ[magrittr]{%>%}โ See section 'Cross-references' in the 'Writing R Extensions' manual.
It would be great if there were a vignette (or other/more documentation) showing the crosstalk
functionality of this package.
User story
I made a brief Shiny example to test crosstalk
with upsetjs
out:
library(shiny)
library(upsetjs)
library(crosstalk)
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)
)
shared_listInput <- crosstalk::SharedData$new(listInput) # create `crosstalk` R6 object
ui <- fluidPage(
titlePanel("UpSet.js Shiny `crosstalk` Example"),
upsetjsOutput("upsetjs_upset"),
upsetjsOutput("upsetjs_euler"),
upsetjsOutput("upsetjs_venn"),
upsetjsOutput("upsetjs_karnaugh"),
)
server <- function(input, output, session) {
shared.mode <- "hover" # otherwise default is "click"
output$upsetjs_upset <- renderUpsetjs({
upsetjs() %>%
fromList(listInput,
shared.mode = shared.mode,
shared = shared_listInput
) %>%
interactiveChart()
})
output$upsetjs_euler <- renderUpsetjs({
upsetjsEulerDiagram() %>%
fromList(listInput,
shared.mode = shared.mode,
shared = shared_listInput
) %>%
interactiveChart()
})
output$upsetjs_venn <- renderUpsetjs({
upsetjsVennDiagram() %>%
fromList(listInput,
shared.mode = shared.mode,
shared = shared_listInput
) %>%
interactiveChart()
})
output$upsetjs_karnaugh <- renderUpsetjs({
upsetjsKarnaughMap() %>%
fromList(listInput,
shared.mode = shared.mode,
shared = shared_listInput
) %>%
interactiveChart()
})
}
# Run the application
shinyApp(ui = ui, server = server)
Including this or something similar may be helpful to users of your package. Thank you!
I'm having the following question...Is it possible that your code is mishandling "large" data?
Hi, very nice package! (also your other projects ๐๐ผ )
I was wondering if your code got some issues since I am almost unable to process a df of more than 500 lines.
To be more precise, I usually use upsetR, and there, no problems I get an upSet plot of 500'000 lines in less than 2 sec. With your package and the same data it lasts for ages...
I tried sampling 100 rows of my data, works, 200...works...300...works...400...already long...500 limit then...I have no more patience.
Since your provided example is only 21 rows long I was just wondering... or could it be because of the number of intersects growing too rapidly?
(btw I of course do not consider 500 rows "big data" ;P)
Screenshots / Sketches
None at the moment, can do some if you want
Context
Additional context
Thanks a lot!
When I try to include more than two venn diagram with the upsetjs package, only the first two are created in the rendered document. If I try to create the venn from the code chunk in RStudio, every venn are create without error.
Is there a limit on the number of venn we can include in a single document? If so, is there a way to remove it?
To Reproduce
upsetjsVennDiagram() %>%
fromList(listInput) %>%
chartVennLabels(title = "Venn diagram of the mixed batches analysis") %>%
chartFontSizes(set.label = "13px", title = "18px") %>% interactiveChart()
Expected behavior
The document should normally show all the different venn diagrams. But in my case, only the first two are created
Context
Additional context
artifacts
NAMESPACE
man
inst/htmlwidgets/upsetjs.js
It would be great if the Euler diagram functions supported ellipses (e.g.: eulerr
package) as they allow for less error in the the set area representation (link includes explanation & example(s)).
e.g. Euler plot constructed with ellipses (pasted from link):
Hello!
Thanks for this package, it's been super useful and easy to use.
Apologies if I missed this in the docs, but it was unclear to me how to modify the on hover text and rectangle element on an interactive upset chart - as shown in the linked screenshot. I want to change the colour to a darker one, and increase the font size of the label. Is this possible?
Thanks,
Stuart
A number of tools, like SURVIVOR, create binary matrix. Tools like ComplexHeatmap's UpSet plot can either accept input from A) lists of sets (like upsetjs_r
) or B) binary matrix.
It would be nice if upsetjs_r
could either accept input from binary matrices or contain a helper function to convert binary matrix data.
I don't believe ComplexHeatmap (or any other package I know of) has a function to do this at the moment: https://support.bioconductor.org/p/131616/
When I use the command in the To Reproduce part bellow to produc a venn diagram, The venn is ploted but the numbers in the different case and the interaction are not correct. For example, on the venn that I plot, I can see that there are 5 element specific to the vector named "two" while in fact there should only be one. The interactivity is also broken. When I hover a part of the venn diagram all the other show "0/n" element even if some are in common with the hovered part.
To Reproduce
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()
Expected behavior
The same venn diagram that is represented on the github should show the same values as the one on the github (https://github.com/upsetjs/upsetjs_r)
Context
The generateIntersections function generally works fine.
However, for the single-group bars, I think their unique elements should be shown instead of their total data.
These specific bars are currently redundant with the horizontal bars (Set Size).
not part of the options so far
Hi Thanks for upsetrjs_r this is an awesome library, I'd been hoping someone would make a nice interactive UpSet plot visualization package so I didn't have to have static UpSets in Shiny apps for a while! to my question:
Is it expected behaviour that input$_click does not produce an event when the same selection is clicked a 2nd time?
I'm trying to make it so that clicking on a selection in an upset plot first selects a set and on second click deselects a set.
To do this I stored the current state of input$<plot>_click$name
in a reactive value and used observeEvent
to monitor input$<plot>_click
, when clicked I was expecting this to trigger the event observer irrespective of whether or not the value changed, so I could compare the current value of input$<plot>_click$name
to the previous one I stored and check if they were the same in which case I could update the selection to NULL
Any help figuring out how to deselect on a 2nd click would be much appreciated!
Here is my example code:
library(shiny)
library(upsetjs)
ui <- fluidPage(
shiny::sidebarLayout(
shiny::sidebarPanel(
textOutput("n"),
textOutput("upset_plot_selected")
),
shiny::mainPanel(
upsetjs::upsetjsOutput("upset_plot")
)
)
)
server <- function(input, output, session) {
output$upset_plot <- upsetjs::renderUpsetjs({
upsetjs::upsetjs() %>%
upsetjs::fromList(
list("A" = c(1,2,3,4,5),"B" = c(1,2,3),"C" = c(2,6,7,8))
) %>%
upsetjs::setSelection(upset_selection_split())
})
upset_selection <- reactiveValues()
upset_selection$value <- NULL
observeEvent(input$upset_plot_click, {
if (is.null(upset_selection$value)) {
upset_selection$value <- input$upset_plot_click$name
} else if (upset_selection$value == input$upset_plot_click$name) {
upset_selection$value <- NULL
} else {
upset_selection$value <- input$upset_plot_click$name
}
})
upset_selection_split <- reactive({
if(is.null(upset_selection$value)) return(NULL)
strsplit(upset_selection$value, split = "&")[[1]]
})
output$upset_plot_selected <- renderText(upset_selection$value)
# n is not incremented when the same set is clicked a second time
upset_selection$n <- 0
observeEvent(
input$upset_plot_click, upset_selection$n <- upset_selection$n + 1
)
output$n <- renderText(upset_selection$n)
}
shinyApp(ui, server)
e.g. similar to the app using: https://upset.js.org/app/embed.html
It would be great if you can tell me how to render the data table of selected parts on the UpSet plot and Venn Plot as you show on your website.
User story
I am using R shiny to implement the upsetjs package. I can't find any sample code for this feature.
Additional context
Hello, I always get an empty plot and I can't guess what's the problem as I have limited javascript skills.
I tried both CRAN and developing versions on different platforms (Windows and Ubuntu Linux) and browsers (Chrome, Firefox, R Studio embedded browser...). The examples I try are those in your README.md (simple and Shiny examples). The result is always an empty plot, nothing is displayed.
I'll appreciate any help as I find this visualization and in particular this package very powerful.
Thank you.
The sections (vertical bars) of an upset plot that (I believe) are meant to show the number of unique elements in the set rather show the number of total elements in the set instead (ie. what is shown in the horizontal bars for the set).
To Reproduce
This data and code:
exdata <- list(
a = head(letters, 20),
b = letters[8:10],
c = letters[10:20],
d = tail(letters, -10))
upsetjs::upsetjs() %>%
upsetjs::fromList(exdata)
Shows this plot. Bars outlined in blue, red, and orange are the ones are the problematic ones:
Expected behavior
I expected a plot similar to the one produced by UpSetR using this code:
UpSetR::fromList(exdata) %>% UpSetR::upset()
Only the blue and red boxed bars are highlighted because they are the only sets that have unique elements to them.
More Context
Actually, after further inspection of the two plots, it seems upsetjs seems to be double counting in other places too. For instance, the number of elements in the b and a intersection should only be two instead of 3, because the third element being counted there belongs to the intersection of sets b, c, and a, namely the 10th letter of the alphabet ("j"
).
This looks like a very promising package so far, though. Thanks for all of your hard work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.