在UpSetR中使用查询

时间:2017-11-23 13:26:08

标签: r 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")

Basic upset plot for my (simplified) dataset

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

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

查询中的错误[[i]] $ color:类型为&#39;关闭的对象&#39;不是   subsettable

1 个答案:

答案 0 :(得分:2)

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

enter image description here