我有这样的数据
df<- structure(list(X1 = c(37L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, NA,
11L, 12L), X2 = c(40L, NA, 35L, 35L, 35L, 34L, 29L, 28L, 28L,
NA, 25L, 24L), X3 = c(60L, 44L, 49L, 41L, NA, NA, NA, 25L, 26L,
NA, NA, 22L), T1 = c(19L, 55L, 47L, 46L, 36L, 42L, 25L, NA, 33L,
42L, 50L, 22L), T2 = c(75L, NA, 32L, 44L, 27L, 31L, 17L, NA,
18L, 45L, 10L, 11L), T3 = c(5L, 6L, 7L, 8L, 9L, 10L, 11L, NA,
46L, 36L, 42L, NA), P1 = c(2L, 2L, 3L, 4L, 2L, 6L, 7L, 8L, 9L,
NA, 1L, 12L), P2 = c(40L, 44L, 4L, 2L, 1L, 1L, 29L, 1L, 1L, 1L,
5L, 55L), P3 = c(1L, 44L, 49L, 3L, NA, NA, NA, 25L, 26L, NA,
NA, 66L)), class = "data.frame", row.names = c(NA, -12L))
group1是X1,X2,X3 组2是T1,T2,T3 group3是P1,P2,P3
我正在尝试绘制维恩图,但我不知道该怎么做。我在这里阅读了许多问题,在这里也阅读了很好的教程
https://rstudio-pubs-static.s3.amazonaws.com/13301_6641d73cfac741a59c0a851feb99e98b.html
第一组有3个重复,第二组有3个重复,第三组有3个重复。
答案 0 :(得分:0)
如果您想将复制品视为一个组,则可以使用我的nVennR
软件包:
library(nVennR)
nonas <- function(x) {unlist(as.list(na.exclude(x)))}
myV2 <- plotVenn(list(X=unique(c(nonas(df$X1), nonas(df$X2), nonas(df$X3))), P=unique(c(nonas(df$P1), nonas(df$P2), nonas(df$P3))), T=unique(c(nonas(df$T1), nonas(df$T2), nonas(df$T3)))), nCycles = 20)
myV2 <- plotVenn(nVennObj = myV2)
这将为您提供一个准比例的维恩图:
然后您可以检查每个区域:
>listVennRegions(myV2, na.rm = F)
$`0, 0, 0 ()`
[1] NA
$`0, 0, 1 (T)`
[1] 19 47 46 36 42 33 50 75 32 27 31 17 18 45 10
$`0, 1, 0 (P)`
[1] 1 66
$`0, 1, 1 (P, T)`
[1] 55
$`1, 0, 0 (X)`
[1] 37 35 34 28 24 60 41
$`1, 0, 1 (X, T)`
[1] 11 22
$`1, 1, 0 (X, P)`
[1] 2 3 4 12 40 29 49 26
$`1, 1, 1 (X, P, T)`
[1] 5 6 7 8 9 25 44
出于好奇,nVenn
算法没有设置号码的限制。您可以执行九组图,但是它会很慢并且几乎没有信息。它可能像这样:
nonas <- function(x) {unlist(as.list(na.exclude(x)))}
myV <- plotVenn(list(X1=nonas(df$X1), X2=nonas(df$X2), X3=nonas(df$X3), T1=nonas(df$T1), T2=nonas(df$T2), T3=nonas(df$T3), P1=nonas(df$P1), P2=nonas(df$P2), P3=nonas(df$P3)))
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- plotVenn(nVennObj = myV)
myV <- showSVG(myV, opacity = 0.2, borderWidth = 0.5, setColors = c('#ff0044', '#ff4400', '#ff2222', '#44ff00', '#00ff44', '#22ff22', '#4400ff', '#0044ff', '#2222ff'))
可能不是很有用。如果您想了解更多信息,可以阅读该软件包的vignette。