开发者

Overlapping graphs using R or Excel

I have following matrix and I want to draw overlapping graph using R (preferable) or Excel.

    a       b       c
a   1       0.5     0.7
b   0.5     1       0.4
c   0.7     0.4     1

For example, the above table shows that a and b have 50% overlapping, whereas a a开发者_运维知识库nd c have 70%.


If you want overlapping then you missed one number - overlapping all three: a, b, c.

As Aniko write in comment you could use Venn diagrams, e.g. Vennerable from R-forge.

Installation need some packages from BioConductor:

source("http://bioconductor.org/biocLite.R")
biocLite(c("graph", "RBGL", "gtools", "xtable"))
install.packages("Vennerable", repos="http://R-Forge.R-project.org")

You mast prepare your data properly:

require(Vennerable)
x <- Venn(
    SetNames = c("a", "b", "c"),
    Weight = c(`100`=1,   `010`=1,   `001`=1,
               `110`=0.5, `101`=0.7, `011`=0.4,
               `111`=.5) # I made this up cause your question miss it
)

And voilà:

plot(x, doWeights=TRUE)

Overlapping graphs using R or Excel


Some additional explanations.

Data structures for Vennerable package need to provide set names ("a", "b", "c" in your case) and frequencies/proportions of each intersects. This 0/1 names identify subsets: 1 means "in set", 0 means "not in set". So e.g.:

  • 100 means in a, not in b, not in c,
  • 011 means not in a, in b, in c

So 111 means in all three sets, which is missing in your matrix and it can't be added there. For your sample data when a&b has 0.7 overlapping and b&c has 0.4 means that at least 0.1 is in three set at the same time (or I missed interpretation of this numbers). (note: I think I overestimated this 0.5, cause it should be lower than 0.4)

You could prepare your data to Venn plot before creating matrix, e.g:

X <- list(
    a = c("One", "Two", "Three"),
    b = c("One", "Three", "Four", "Five", "Seven"),
    c = c("Three", "Five", "Eight", "Nine", "Ten")
)

x <- Venn(X)
x
# A Venn object on 3 sets named
# a,b,c 
# 000 100 010 110 001 101 011 111 
#   0   1   2   1   3   0   1   1 
plot(x, doWeights=TRUE)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜