如何在r中使用calculate.overlap函数查找与维恩图的哪些部分相关的元素?

时间:2019-04-07 15:02:24

标签: r dataframe overlapping venn-diagram

calculate.overlap的输出不清楚。 维恩图的每个位置都有一些名称,例如:$ a1,$ a2,... 当我们画出五个清单时,它变得如此复杂。 如何识别哪些名称($ a1,$ a2,...)与哪些列表的重叠有关?

library(VennDiagram)

overlap=calculate.overlap(
    x=list(
        "A"=c("a","b","c"),
        "B"=c("a","b","c","d"),
        "C"=c("a","c","d")
    )
)

这是输出:

$a5
[1] "a" "c"

$a2
[1] "b"

$a4
character(0)

$a6
[1] "d"

$a1
character(0)

$a3
character(0)

$a7
character(0)

如何用我的列表名称替换这些名称?

我的预期输出是:

$A,B,C
[1] "a" "c"

$A,B
[1] "b"

$A,C
character(0)

$B,C
[1] "d"

$A
character(0)

$B
character(0)

$C
character(0)

1 个答案:

答案 0 :(得分:1)

有一个答案here。但是,我不主张理解它。在维恩图中对区域排序的一般规则是使用其二进制表示形式。我的nVennR软件包使用该表示形式,可以为您提供任意数量的集合的快速答案:

> library(nVennR)
> myV <- plotVenn(list("A"=c("a","b","c"), "B"=c("a","b","c","d"), "C"=c("a","c","d")), showPlot = F)
> listVennRegions(myV)
$`0, 1, 1 (B, C)`
[1] "d"

$`1, 1, 0 (A, B)`
[1] "b"

$`1, 1, 1 (A, B, C)`
[1] "a" "c"

> listVennRegions(myV, na.rm = F)
$`0, 0, 0 ()`
[1] NA

$`0, 0, 1 (C)`
[1] NA

$`0, 1, 0 (B)`
[1] NA

$`0, 1, 1 (B, C)`
[1] "d"

$`1, 0, 0 (A)`
[1] NA

$`1, 0, 1 (A, C)`
[1] NA

$`1, 1, 0 (A, B)`
[1] "b"

$`1, 1, 1 (A, B, C)`
[1] "a" "c"

有一个vignette,其中包含用法的更多详细信息。