在 UpSetR 中使用查询

Using queries in UpSetR

我正在尝试使用包 UpSetR 中的查询功能来根据一个变量突出显示某些项目。

我的数据集Dropbox link

我可以毫无问题地完成基本情节:

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")

但是,当我尝试执行一些基本查询时,我遇到了各种各样的错误。例如,在一个基本查询中,我要求将变量中具有给定值的所有元素都涂成蓝色,但出现以下错误:

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

queries的输入必须是列表的列表:

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")