I am trying to use the query capabilites in the package UpSetR to highlight certain items depending on one variable.
My dataset Dropbox link
I can do a basic plot without any problems:
stress <- read_delim("upset_plot_high_freq.csv", "\t", escape_double = FALSE, trim_ws = TRUE)
stress_data<-as.data.frame(stress)
upset(stress_data, sets = c("reg_region","sweep","gene_association","chromatin"),
mainbar.y.label = "Number of TEs", sets.x.label = "Total number of TEs",
text.scale = 2, group.by = "degree", order.by="freq")
However, when I try to do some basic queries I get all sort of errors. For example in a basic query where I ask all the elements with a given value in a variable to be painted blue I get the following error:
myfunction <- function(row, min){
newData <- (row["chip_num"] > min)
}
upset(stress_data, sets = c("reg_region","sweep","gene_association","chromatin"),
queries = list(query = myfunction, params = list(0), active = TRUE),
mainbar.y.label = "Number of TEs", sets.x.label = "Total number of TEs",
text.scale = 2, group.by = "degree", order.by="freq")
Error in queries[[i]]$color : object of type 'closure' is not subsettable
The input of queries
must be a list of lists:
library(UpSetR)
library(readr)
stress <- read_delim("upset_plot_fixed_freq.csv", "\t",
escape_double = FALSE, trim_ws = TRUE)
stress_data <- as.data.frame(stress)
names(stress_data)[c(9,12,13,10)] <- c("reg_region","sweep",
"gene_association","chromatin")
myfunction <- function(row, min) {
newData <- (row["chip_num"] > min)
}
upset(stress_data, sets=c("reg_region","sweep","gene_association","chromatin","chip_num"),
queries = list(list(query = myfunction, params = list(0), active = T)),
mainbar.y.label = "Number of TEs", sets.x.label = "Total number of TEs",
text.scale = 2, group.by = "degree", order.by="freq")