rupsetr

"Object 'freq' not found" error applying colour in UpSetR


If I run this reprex, I get the required output:

``` r
library(UpSetR)
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))

upset(fromList(listInput), order.by = "freq")
```

If I apply a colour, I get the following error.

``` r
library(UpSetR)
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))

upset(fromList(listInput), order.by = "freq",
      queries = list(list(query = intersects, params = list("one"), color = "orange", active = T)))
#> Error in eval(expr, envir, enclos): object 'freq' not found
```

I've looked at the colouring "example 5" in the vignettes, but can't spot my misstep.


Solution

  • Add a column of integers to the dataframe inputted into upset.

    library(UpSetR)
    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))
    df <- fromList(listInput)
    df$n <- sample(1:nrow(df))
    
    upset(df, order.by = "freq",
          queries = list(list(query = intersects, 
                              params = list("one"), 
                              color = "orange")))
    

    enter image description here