在R中的维恩图上绘制重量和百分比(维恩包装)
我遇到了一些麻烦/我需要绘制维恩图并一起打印重量值和百分比。现在我正在编写以下代码:在R中的维恩图上绘制重量和百分比(维恩包装),r,venn-diagram,R,Venn Diagram,我遇到了一些麻烦/我需要绘制维恩图并一起打印重量值和百分比。现在我正在编写以下代码: library(Vennerable) > areas 00 01 10 11 38596 6024 40696 8971 VennSet <- Venn(SetNames = category, Weight = areas) VennList <- compute.Venn(VennSet, doWeights = TRUE) gp <- VennThe
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))
及其产出
> VennList
A Venn object on 2 sets named
Glia.LAM.mf_min.bound,Glia.HP1.mf_min.bound
00 10 01 11
38596 40696 6024 8971
from to 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
谁知道如何输出权重和百分比呢?这并不是我想要的。但也有生存的权利
areasPcent <- round(pcentFun(areas), digits=2)
VennSet <- Venn(SetNames = category, Weight = areas)
VennList <- compute.Venn(VennSet, doWeights = TRUE)
VennList_pc <- VennList
for (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, " from ", 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()
areasPcent这并不是我想要的。但也有生存的权利
areasPcent <- round(pcentFun(areas), digits=2)
VennSet <- Venn(SetNames = category, Weight = areas)
VennList <- compute.Venn(VennSet, doWeights = TRUE)
VennList_pc <- VennList
for (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, " from ", 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()
areasPcent虽然这个问题是多年前提出来的,但我相信还是分享一个对我来说很有效的答案为好。实际上,我找到了一种更简单的方法(在区域
和区域之间使用换行符),如下所示:
VennList@FaceLabels$Signature <- paste0(areas, "\n", areasPcent, "%")
plot(VennList, gpList=gp, show = list(FaceText = c("signature"), DarkMatter = TRUE))
VennList@FaceLabels$Signature虽然这个问题是多年前提出来的,但我相信还是分享一个对我有效的答案为好。实际上,我找到了一种更简单的方法(在区域
和区域之间使用换行符),如下所示:
VennList@FaceLabels$Signature <- paste0(areas, "\n", areasPcent, "%")
plot(VennList, gpList=gp, show = list(FaceText = c("signature"), DarkMatter = TRUE))
VennList@FaceLabels$Signature