GithubHelp home page GithubHelp logo

Comments (11)

sgratzl avatar sgratzl commented on June 1, 2024

can you provide a sample dataset, please?

from upsetjs_r.

moldach avatar moldach commented on June 1, 2024

Sure:

library(tibble)
mat <- tribble(
  ~set1, ~set2, ~set3,
   1,   1,   0,
   0,   0,   1,
   0,   1,   1,
   0,   0,   1,
   0,   0,   1,
   0,   1,   1,
   1,   0,   1,
   0,   1,   1,
   0,   0,   1,
   0,   0,   1,
   1,   1,   1,
   1,   0,   0,
   0,   0,   1,
   0,   1,   0,
   1,   1,   1,
   0,   1,   0,
   0,   1,   1,
   0,   1,   0,
   0,   0,   1,
   0,   0,   1
)

So either accept that type of data or a helper function to convert it into a format that upsetjs accepts, e.g.:

set.seed(123)
listInput = list(a = sample(letters, 5),
          b = sample(letters, 10),
          c = sample(letters, 15))
upsetjs() %>% fromList(listInput) %>% interactiveChart()

from upsetjs_r.

sgratzl avatar sgratzl commented on June 1, 2024

https://upset.js.org/integrations/r/articles/basic.html#data-frame-input doesn't work?

from upsetjs_r.

moldach avatar moldach commented on June 1, 2024

Sorry I never saw that documentation - I still cannot find a link for it on the README on the github repo.

One more thing, I've noticed the following discrepancy.

library(tibble)
t <- tribble(
  ~set1, ~set2, ~set3,
   1,   1,   0,
   0,   0,   1,
   0,   1,   1,
   0,   0,   1,
   0,   0,   1,
   0,   1,   1,
   1,   0,   1,
   0,   1,   1,
   0,   0,   1,
   0,   0,   1,
   1,   1,   1,
   1,   0,   0,
   0,   0,   1,
   0,   1,   0,
   1,   1,   1,
   0,   1,   0,
   0,   1,   1,
   0,   1,   0,
   0,   0,   1,
   0,   0,   1
)

Both VennDiagram and ComplexHeatmap produce the same result but upsetjs was producing a different image.

VennDiagram

library(VennDiagram)
venn.diagram(list(Set1=which(t[,1]==1), 
                  Set2=which(t[,2]==1), 
                  Set3=which(t[,3]==1)), 
             fill = c("#DDAA33", "#BB5566" ,"#004488"), 
             alpha = c(0.5, 0.5, 0.5), cex = 2, lty =2, 
             filename = "VennDiagram.tiff")

venn

ComplexHeatmap

m = make_comb_mat(t)
ss = set_size(m)
UpSet(m, set_order = order(ss), comb_order = order(-comb_size(m)))

Rplot01

UpSetJS

upsetjs() %>% fromDataFrame(t)

Rplot03

According to ComplexHeatmap's documentation:

intersect mode: 1 means in that set and 0 is not taken into account, then, 1 1 0 means a set of elements in set A and B, and they can also in C or not in C (intersect(A, B)). Under this mode, the seven combination sets can overlap.

so,

m = make_comb_mat(t, mode="intersect")
ss = set_size(m)
UpSet(m, 
           set_order = order(ss),
           #comb_order = order(comb_degree(m), -cs),
           comb_order = order(-comb_size(m)))

Rplot03

So for ComplexHeatmap the default is distinct

distinct mode: 1 means in that set and 0 means not in that set, then 1 1 0 means a set of elements both in set A and B, while not in C (setdiff(intersect(A, B), C)). Under this mode, the seven combination sets are the seven partitions in the Venn diagram and they are mutually exclusive.

How can you mimic the distinct output produced by VennDiagram and ComplexHeatmap with UpSetJS?

from upsetjs_r.

sgratzl avatar sgratzl commented on June 1, 2024

so to understand it correctly

m = make_comb_mat(t)
ss = set_size(m)
UpSet(m, set_order = order(ss), comb_order = order(-comb_size(m)))

if you label the vertical bars in this chart it would read the following:

  • setdiff(set3, union(set1, set2))
  • setdiff(intersect(set3,set3), set1)
  • setdiff(set2, union(set1, set3))
  • intersect(set3, set2, set3)
  • setdiff(intersect(set2, set1), set3)
  • setdiff(intersect(set3, set1), set2)
  • setdiff(set1, union(set3,set2))

right?

from upsetjs_r.

jokergoo avatar jokergoo commented on June 1, 2024

E.g., in ComplexHeatmap, for a pattern

A B C
x x -

the "distinct" mode corresponds to setdiff(intersect(A, B), C) and the "intersect" mode corresponds to intersect(A, B),

and similar for the pattern:

A B C
x - -

the "distinct" mode corresponds to setdiff(setdiff(A, B), C), or setdiff(A, union(B, C)), the "intersect" mode corresponds to intersect(A) which is A.

You can find the graphical explanations here:

image

from upsetjs_r.

moldach avatar moldach commented on June 1, 2024

Thank you for clarification @jokergoo

from upsetjs_r.

sgratzl avatar sgratzl commented on June 1, 2024

thx. I just implemented a generateDistinctIntersections() function.

can you verify that https://upset.js.org/next/integrations/r/articles/combinationModes.html is now showing the values you would expect in the different modes?

from upsetjs_r.

moldach avatar moldach commented on June 1, 2024

That's awesome @sgratzl , thanks for being so quick with this enhancement!

The function may not have been included in the most recent build though.

I deleted the folder from R/win-library/4.0 and tried to reinstall via: devtools::install_url("https://github.com/upsetjs/upsetjs_r/releases/latest/download/upsetjs.tar.gz")

but I get an error:

t <- read.csv("data/survivor_comparison_matrix.csv")
library(upsetjs)
upsetjs() %>% 
  fromDataFrame(t) %>% 
  generateDistinctIntersections() %>%   
  interactiveChart()

Error in generateDistinctIntersections(.) :
could not find function "generateDistinctIntersections"

from upsetjs_r.

sgratzl avatar sgratzl commented on June 1, 2024

yeah it is not released yet but in the develop branch. You can download a current build e.g. from https://github.com/upsetjs/upsetjs.github.io/raw/master/next/integrations/r/upsetjs.tar.gz

from upsetjs_r.

sgratzl avatar sgratzl commented on June 1, 2024

version 1.1.0 has been released containing the generateDistinctIntersections function

from upsetjs_r.

Related Issues (20)

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.