Comments (11)
can you provide a sample dataset, please?
from upsetjs_r.
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.
https://upset.js.org/integrations/r/articles/basic.html#data-frame-input doesn't work?
from upsetjs_r.
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")
ComplexHeatmap
m = make_comb_mat(t)
ss = set_size(m)
UpSet(m, set_order = order(ss), comb_order = order(-comb_size(m)))
UpSetJS
upsetjs() %>% fromDataFrame(t)
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)))
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.
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.
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:
from upsetjs_r.
Thank you for clarification @jokergoo
from upsetjs_r.
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.
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.
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.
version 1.1.0 has been released containing the generateDistinctIntersections
function
from upsetjs_r.
Related Issues (20)
- create venn diagram component HOT 1
- fix rhub building warning HOT 1
- The vertical bars for the unique elements of a set show the total elements of the set instead HOT 3
- big matrices? HOT 9
- Get the information of selected part HOT 3
- add missing new layout flags: setLabelAlignment
- Is it possible to change the hoverBar text colour and rectangle on an interactive chart? HOT 2
- Problem with upsetjsVennDiagram()
- Getting empty plots HOT 4
- generateIntersections improvement HOT 2
- Is it expected behaviour that input$<plot>_click does not produce an event when the same selection is clicked a 2nd time? HOT 3
- upsetjs and rmarkdown HOT 4
- order set names HOT 2
- Ellipses in Euler diagrams HOT 2
- "Coloring Diagrams" vignette example (vignettes/colors.Rmd) unexpected plot output
- Crosstalk example(s)/vignette HOT 2
- fix CRAN submission
- expression input bug in upsetjs?r
- add title / desc to upsetjs_r
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from upsetjs_r.