upsetjs_r
upsetjs_r copied to clipboard
"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:
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.