UpsetR:手动排列集合交点以对齐多个翻转绘图
我正在使用UpsetR软件包制作多个翻转绘图,并将使用UpsetR:手动排列集合交点以对齐多个翻转绘图,r,R,我正在使用UpsetR软件包制作多个翻转绘图,并将使用网格将它们合并。排列以生成单个图形。是否可以强制交点的顺序,以便它们在绘图之间相同 默认情况下,它按频率排列条形图,但您也可以指定order.By=“degree”按相交集的数量排列条形图。但是,它并不总是以相同的顺序放置同等度数的条形图,而且我还没有找到如何在将绘图指定为对象和查看要素列表时手动指定相交顺序。下面是一个例子 listInput1 <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13)
网格将它们合并。排列以生成单个图形。是否可以强制交点的顺序,以便它们在绘图之间相同
默认情况下,它按频率排列条形图,但您也可以指定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)
listInput1我也有同样的问题!我认为最简单的解决方案应该是这样的(即,指定交点
顺序,而不是集合
一个…有点繁琐,但它可以工作):
plot.ls谢谢@jgarces!这种方法起初并不适用于我的真实数据。我得到了以下错误:[.data.frame
中的错误(数据,保留):未定义的列被选中。但是,为了美观起见,我的集合名中有空格,因此如果我删除空格,那么这就行了。我还没有弄清楚如何指定与包含空格的集合名的交点。您好@jcampo,我通常会尽量避免在R中使用空格,因为所有内容通常都会在下游崩溃…有些问题使用反勾号(`)是一种可能的解决方案,但我没有弄清楚您的具体情况。有两个选项:在R中将colnames重命名为语法正确的名称(并在绘图后再次手动重命名)或修改函数代码(祝您好运!)。因此,很抱歉无法提供更多详细帮助。
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")))
)