Draw weights and % on Venn Diagram in R (Vennerable Package) -


i have trouble/ need draw venn diagram , print weight values , percentage together. i'm writing code:

library(vennerable) > areas    00    01    10    11  38596  6024 40696  8971 vennset <- venn(setnames = category, weight = areas) vennlist <- compute.venn(vennset, doweights = true) gp <- vennthemes(vennlist) plot(vennlist, gplist=gp, show = list(facetext = c("signature", "weight"), darkmatter = true)) 

result: enter image description here

then wanted change values in last line.

pcentfun <- function(x) { 100 * (x /sum(x)) } areaspcent <- round(pcentfun(areas), digits=2) vennlist@facelabels$signature <- paste(areaspcent, "%", sep="") 

result: enter image description here

i have printed percentages, lost weight. here structure of object:

> str(vennlist) formal class 'venndrawing' [package "vennerable"] 11 slots   ..@ universe        : num [1:2, 1:2] -209 152 -150 150   .. ..- attr(*, "dimnames")=list of 2   .. .. ..$ : null   .. .. ..$ : chr [1:2] "x" "y"   ..@ setlabels       :'data.frame':    2 obs. of  5 variables:   .. ..$ label: chr [1:2] "glia.lam.mf_min.bound" "glia.hp1.mf_min.bound"   .. ..$ x    : num [1:2] -54.2 54.2   .. ..$ y    : num [1:2] 128.3 71.6   .. ..$ hjust:class 'asis'  chr [1:2] "center" "center"   .. ..$ vjust: chr [1:2] "bottom" "bottom"   ..@ facelabels      :'data.frame':    4 obs. of  6 variables:   .. ..$ facename : chr [1:4] "01" "10" "11" "darkmatter"   .. ..$ signature: chr [1:4] "40.93%" "6.39%" "43.16%" "9.51%"   .. ..$ x        : num [1:4] 97.4 -97.4 28.3 123.3   .. ..$ y        : num [1:4] 0.00 1.19e-14 4.23e-15 1.26e+02   .. ..$ hjust    : chr [1:4] "centre" "centre" "centre" "right"   .. ..$ vjust    : chr [1:4] "centre" "centre" "centre" "top"   ..@ setlist         :list of 2   .. ..$ set1: chr [1:2] "i24|i23|1" "i23|i24|1"   .. ..$ set2: chr [1:2] "i24|i23|2" "i23|i24|2"   ..@ nodelist        :list of 2   .. ..$ i23: num [1, 1:2] 50.9 69   .. .. ..- attr(*, "dimnames")=list of 2   .. .. .. ..$ : chr "i23"   .. .. .. ..$ : chr [1:2] "x" "y"   .. ..$ i24: num [1, 1:2] 50.9 -69   .. .. ..- attr(*, "dimnames")=list of 2   .. .. .. ..$ : chr "i24"   .. .. .. ..$ : chr [1:2] "x" "y"   ..@ recentchanges   : chr [1:2] "c11|i24|1" "i24|i23|1"   ..@ edgelist        :list of 4   .. ..$ i24|i23|1:formal class 'vdedgesector' [package "vennerable"] 9 slots   .. .. .. ..@ radius   : num 126   .. .. .. ..@ fromtheta: num 5.7   .. .. .. ..@ totheta  : num 0.581   .. .. .. ..@ centre   : num [1:2] -54.2 0   .. .. .. ..@ hand     : num 1   .. .. .. ..@     : chr "i24"   .. .. .. ..@       : chr "i23"   .. .. .. ..@ visible  : logi true   .. .. .. ..@ bb       : num [1:2, 1:2] -179.9 71.5 -125.7 125.7   .. ..$ i24|i23|2:formal class 'vdedgesector' [package "vennerable"] 9 slots   .. .. .. ..@ radius   : num 69.1   .. .. .. ..@ fromtheta: num 4.66   .. .. .. ..@ totheta  : num 1.62   .. .. .. ..@ centre   : num [1:2] 54.2 0   .. .. .. ..@ hand     : num 1   .. .. .. ..@     : chr "i24"   .. .. .. ..@       : chr "i23"   .. .. .. ..@ visible  : logi true   .. .. .. ..@ bb       : num [1:2, 1:2] -14.9 123.3 -69.1 69.1   .. ..$ i23|i24|1:formal class 'vdedgesector' [package "vennerable"] 9 slots   .. .. .. ..@ radius   : num 126   .. .. .. ..@ fromtheta: num 0.581   .. .. .. ..@ totheta  : num -0.581   .. .. .. ..@ centre   : num [1:2] -54.2 0   .. .. .. ..@ hand     : num 1   .. .. .. ..@     : chr "i23"   .. .. .. ..@       : chr "i24"   .. .. .. ..@ visible  : logi true   .. .. .. ..@ bb       : num [1:2, 1:2] -179.9 71.5 -125.7 125.7   .. ..$ i23|i24|2:formal class 'vdedgesector' [package "vennerable"] 9 slots   .. .. .. ..@ radius   : num 69.1   .. .. .. ..@ fromtheta: num 1.62   .. .. .. ..@ totheta  : num -1.62   .. .. .. ..@ centre   : num [1:2] 54.2 0   .. .. .. ..@ hand     : num 1   .. .. .. ..@     : chr "i23"   .. .. .. ..@       : chr "i24"   .. .. .. ..@ visible  : logi true   .. .. .. ..@ bb       : num [1:2, 1:2] -14.9 123.3 -69.1 69.1   ..@ facelist        :list of 4   .. ..$ darkmatter: chr [1:2] "-i24|i23|1" "-i23|i24|2"   .. ..$ 11        : chr [1:2] "i24|i23|2" "i23|i24|1"   .. ..$ 10        : chr [1:2] "i24|i23|1" "-i24|i23|2"   .. ..$ 01        : chr [1:2] "i23|i24|2" "-i23|i24|1"   ..@ facesignature   :list of 4   .. ..$ darkmatter: chr "darkmatter"   .. ..$ 11        : chr "11"   .. ..$ 10        : chr "10"   .. ..$ 01        : chr "01"   ..@ indicatorweight : num [1:4, 1:3] 0 1 0 1 0 ...   .. ..- attr(*, "dimnames")=list of 2   .. .. ..$ : chr [1:4] "00" "10" "01" "11"   .. .. ..$ : chr [1:3] "glia.lam.mf_min.bound" "glia.hp1.mf_min.bound" ".weight"   ..@ intersectionsets: list() 

and output

> vennlist venn object on 2 sets named glia.lam.mf_min.bound,glia.hp1.mf_min.bound     00    10    01    11  38596 40696  6024  8971                     type npoints              centre hand i24|i23|1  i24 i23 vdedgesector      na -54.2116651664673,0    1 i24|i23|2  i24 i23 vdedgesector      na  54.2116651664673,0    1 i23|i24|1  i23 i24 vdedgesector      na -54.2116651664673,0    1 i23|i24|2  i23 i24 vdedgesector      na  54.2116651664673,0    1           x1        x2 i23 50.89514  69.00766 i24 50.89514 -69.00766                            faces darkmatter -i24|i23|1;-i23|i24|2 11           i24|i23|2;i23|i24|1 10          i24|i23|1;-i24|i23|2 01          i23|i24|2;-i23|i24|1                   sig darkmatter darkmatter 11                 11 10                 10 01                 01      paste.face..collapse....... set1         i24|i23|1;i23|i24|1 set2         i24|i23|2;i23|i24|2 

who has idea how output both weights , percentages?

this not wanted. has right exist.

areaspcent <- round(pcentfun(areas), digits=2) vennset <- venn(setnames = category, weight = areas) vennlist <- compute.venn(vennset, doweights = true) vennlist_pc <- vennlist (i in c(1:length(areaspcent))) {     position <- grep(names(areaspcent)[i], vennlist_pc@facelabels$signature)     vennlist_pc@facelabels$signature[position] <- paste(areaspcent[i], "%", sep="") } gp <- vennthemes(vennlist) pdf(file=file.path(paste("venn diagram between ", v2, " ", v1, ".pdf", sep="")), width=8, height=12.76) par(mfrow=c(1, 2)) par(mai=c(0.7, 0.7, 0.7, 0.5)) rownumbermakevp <<- 1 plot(vennlist, gplist=gp) rownumbermakevp <<- 2 plot(vennlist_pc, gplist=gp, show = list(facetext = c("signature"), darkmatter = true)) dev.off() 

i'm using solution multiple diagram side-by-side venn diagram using vennerable in r


Comments