首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UpsetR:手动排序集合交叉点以对齐多个颠倒图

UpsetR:手动排序集合交叉点以对齐多个颠倒图
EN

Stack Overflow用户
提问于 2019-08-12 16:11:51
回答 1查看 1.8K关注 0票数 0

我正在使用UpsetR包制作多个颠倒的图形,并将使用grid.arrange将它们组合在一起形成一个单独的图形。有没有可能强制交叉点的顺序,使它们在绘图之间是相同的?

默认情况下,它按频率对钢筋进行排序,但您也可以指定order.by = “degree”以按相交集数对钢筋进行排序。然而,它并不总是以相同的顺序放置等价度的条块,并且我还没有找到在将绘图指定为对象并查看特征列表时如何手动指定相交顺序。下面是一个例子。

代码语言:javascript
复制
listInput1 <- 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),
                  four = c(1, 11, 14))
listInput2 <- list(one = c(1, 2, 4, 6, 7, 9, 11, 12, 13), 
                   two = c(1, 2, 4, 5, 10, 13, 14), 
                   three = c(1, 3, 6, 7, 8, 9, 10, 12, 13),
                   four = c(1, 2, 3, 4, 5, 6, 7, 8, 9))
listInput3 <- list(one = c(1, 2, 4, 6, 8, 9, 11, 12, 13), 
                   two = c(1, 2, 4, 5, 10, 13, 14), 
                   three = c(1, 2, 3, 6, 7, 8, 9, 10, 12, 13, 14),
                   four = c(2, 6, 9, 11, 12))
listInput4 <- list(one = c(1, 2, 3, 4, 6, 8, 9, 11, 12, 13, 15, 16, 17), 
                   two = c(1, 2, 3, 4, 5, 7, 10, 13, 14), 
                   three = c(1, 2, 3, 6, 7, 8, 9, 10, 12, 13, 14),
                   four = c(4, 5, 6, 10, 11, 12))

plot.ls <- list(
  p1 = upset(fromList(listInput1), order.by = "degree", sets = c("four", "three", "two", "one"), keep.order = TRUE, empty.intersections = "on"),
  p2 = upset(fromList(listInput2), order.by = "degree", sets = c("four", "three", "two", "one"), keep.order = TRUE, empty.intersections = "on"),
  p3 = upset(fromList(listInput3), order.by = "degree", sets = c("four", "three", "two", "one"), keep.order = TRUE, empty.intersections = "on"),
  p4 = upset(fromList(listInput4), order.by = "degree", sets = c("four", "three", "two", "one"), keep.order = TRUE, empty.intersections = "on")
  )
for (v in names(plot.ls)) {
  print(plot.ls[[v]])
  grid.text(v, x = 0.65, y=0.97, gp = gpar(fontsize = 20))
  grid.edit('arrange', name = v)
  vp <- grid.grab()
  plot.ls[[v]] <- vp
}
grid.arrange(grobs = plot.ls, ncol = 2)

理想情况下,我应该让所有地块的交集按以下顺序排列:一&二,一,二,一&三,一&四,一&二&三,一&二&四,一&二&三,二&三&四,一&三&四,二&三,二&四,四,三&四。有没有办法做到这一点?

EN

回答 1

Stack Overflow用户

发布于 2019-10-10 16:31:07

我也有同样的问题!我认为最简单的解决方案是这样的(即,指定intersections order而不是sets one...有点乏味,但它是有效的):

代码语言:javascript
复制
plot.ls <- list(
  p1 = upset(fromList(listInput1), order.by = "degree", keep.order = TRUE, empty.intersections = "on", 
             intersections = list(list("one", "two"), list("one"), list("two"), list("one", "three"), list("one", "four"), list("one", "two", "three"), list("one", "two", "four"), list("one", "two", "three", "four"), list("two", "three", "four"), list("one", "three", "four"), list("two", "three"), list("two", "four"), list("four"), list("three"), list("three", "four"))),
  p2 = upset(fromList(listInput2), order.by = "degree", keep.order = TRUE, empty.intersections = "on",
             intersections = list(list("one", "two"), list("one"), list("two"), list("one", "three"), list("one", "four"), list("one", "two", "three"), list("one", "two", "four"), list("one", "two", "three", "four"), list("two", "three", "four"), list("one", "three", "four"), list("two", "three"), list("two", "four"), list("four"), list("three"), list("three", "four"))),
  p3 = upset(fromList(listInput3), order.by = "degree", keep.order = TRUE, empty.intersections = "on", 
             intersections = list(list("one", "two"), list("one"), list("two"), list("one", "three"), list("one", "four"), list("one", "two", "three"), list("one", "two", "four"), list("one", "two", "three", "four"), list("two", "three", "four"), list("one", "three", "four"), list("two", "three"), list("two", "four"), list("four"), list("three"), list("three", "four"))),
  p4 = upset(fromList(listInput4), order.by = "degree", keep.order = TRUE, empty.intersections = "on",
             intersections = list(list("one", "two"), list("one"), list("two"), list("one", "three"), list("one", "four"), list("one", "two", "three"), list("one", "two", "four"), list("one", "two", "three", "four"), list("two", "three", "four"), list("one", "three", "four"), list("two", "three"), list("two", "four"), list("four"), list("three"), list("three", "four")))
)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57457651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档