我正在使用UpsetR包制作多个颠倒的图形,并将使用grid.arrange将它们组合在一起形成一个单独的图形。有没有可能强制交叉点的顺序,使它们在绘图之间是相同的?
默认情况下,它按频率对钢筋进行排序,但您也可以指定order.by = “degree”以按相交集数对钢筋进行排序。然而,它并不总是以相同的顺序放置等价度的条块,并且我还没有找到在将绘图指定为对象并查看特征列表时如何手动指定相交顺序。下面是一个例子。
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)理想情况下,我应该让所有地块的交集按以下顺序排列:一&二,一,二,一&三,一&四,一&二&三,一&二&四,一&二&三,二&三&四,一&三&四,二&三,二&四,四,三&四。有没有办法做到这一点?
发布于 2019-10-10 16:31:07
我也有同样的问题!我认为最简单的解决方案是这样的(即,指定intersections order而不是sets one...有点乏味,但它是有效的):
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")))
)

https://stackoverflow.com/questions/57457651
复制相似问题