GithubHelp home page GithubHelp logo

upsetjs / upsetjs_r Goto Github PK

View Code? Open in Web Editor NEW
35.0 4.0 1.0 4.26 MB

๐Ÿ˜  htmlwidget R bindings for UpSet.js for rendering UpSet plots, Euler, and Venn Diagrams

Home Page: https://upset.js.org/integrations/r

License: Other

R 80.72% JavaScript 2.72% TypeScript 16.43% Shell 0.13%
htmlwidget r upset upsetr interactive upsetjs shiny euler venn venn-diagram

upsetjs_r's People

Contributors

halhen avatar sgratzl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

halhen

upsetjs_r's Issues

Accept binary matrix input or create helper function for conversion

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/

The vertical bars for the unique elements of a set show the total elements of the set instead

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:

upsetjsplot

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.

UpSetRplot

  • Version: upsetjs R package v1.6.0
  • Browser: Not sure its relevant because its the same for static and interactive plots, but this is from within RStudio IDE v1.3.959

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!

fix CRAN submission

  • Please add \value to .Rd files regarding exported methods and explain the functions results in the documentation. Please write about the structure of the output (class) and also what the output means. (If a function does not return a value, please document that too, e.g. \value{No return value, called for side effects} or similar)
  • Please add small executable examples in your Rd-files to illustrate the use of the exported function.
  • You are using installed.packages() in your code. As mentioned in the notes of installed.packages() help page, this can be very slow. Therefore do not use installed.packages(). regarding: utils.R

Get the information of selected part

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

fix rhub building warning

ย  | 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.

upsetjs_1.1.0.tar.gz-40ed94320ec746fb8917bea066332c41.txt

Is it expected behaviour that input$<plot>_click does not produce an event when the same selection is clicked a 2nd time?

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)

Getting empty plots

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.

Ellipses in Euler diagrams

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):

image

upsetjs and rmarkdown

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

  1. Create a Rmarkdown document, I use the latest version of R and RStudio (with Quarto enabled)
  2. Add 3 or more venn diagrams in one or different code chunk
upsetjsVennDiagram() %>%
  fromList(listInput) %>%
  chartVennLabels(title = "Venn diagram of the mixed batches analysis") %>%
  chartFontSizes(set.label = "13px", title = "18px") %>% interactiveChart()
  1. Render the document to the html format.

Expected behavior

The document should normally show all the different venn diagrams. But in my case, only the first two are created

Screenshots
2022-05-23_095125

Context

  • Version: R 4.2 RStudio 2022.02.2+485
  • Browser:

Additional context

big matrices?

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

  • Version: R 4.0.3
  • Browser: does not apply

Additional context

Thanks a lot!

"Coloring Diagrams" vignette example (vignettes/colors.Rmd) unexpected plot output

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

I see:
image

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

image

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.

Is it possible to change the hoverBar text colour and rectangle on an interactive chart?

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?
Screen Shot 2021-10-28 at 8 20 22 pm

Thanks,
Stuart

Problem with upsetjsVennDiagram()

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

  • Version: 1.9.0
  • Browser: RStudio

generateIntersections improvement

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).

Crosstalk example(s)/vignette

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)

image

Including this or something similar may be helpful to users of your package. Thank you!

order set names

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?

Capture

I've tried setting order.by = "degree" in fromList() but that just orders the sets alphabetically.

  • Version:
    • R version 4.2.1
    • upsetjs_1.11.1
  • Browser: Chrome

Thanks!

add title / desc to upsetjs_r

the next upsetjs version will allow to specify title and description. Thus, those options should also be available in the R version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.