From what I can tell, the as are distributed from top left to right, to bottom. · i.e. · a1 = 1761 · a2=126 · a3=466 · a4=64 · a5=44 · a6=27 · a7=366 · This is based on: · > library("VennDiagram") · > · > gene_list = paste0("GENE", 1:1000) · > · > studies = list( S1=sample(gene_list, 700, replace = FALSE), · + S2=sample(gene_list, 700, replace = FALSE), · + S3=sample(gene_list, 700, replace = FALSE) ) · > · > ol = calculate.overlap(x = studies) · > ol_size=sapply(ol, length) · > · > · > venn.diagram( · + x = studies, · + euler.d = TRUE, · + filename = "Euler_3set_scaled.tiff", · + cex = 2.5, · + cat.cex = 2.5, · + cat.pos = 0 · + ); · [1] 1 · > # Get the 63 · > length( setdiff(studies$S1, union(studies$S2, studies$S3)) ) · [1] 63 · > # Confirm order · > ol_size · a5 a2 a4 a6 a1 a3 a7 · 351 143 143 134 63 72 72 · And it matches the order from a1 to a7 going left-right, top-bottom. · If you want to be sure of what you're getting, you can use set operators like I did with setdiff() and union().
🌐
CRAN
cran.r-project.org › web › packages › VennDiagram › VennDiagram.pdf pdf
VennDiagram.pdf - CRAN - R Project
the diagram in a graphical device unless specified with ind = FALSE. Grid::grid.draw can be used ... Partitions a list into Venn regions. ... A list of vectors. ... A logical value. Should only unique values be considered? ... A logical value. Should the elements in each region be returned? ... A logical value. Changed the way overlapping elements are treated if force.unique
🌐
R Graph Gallery
r-graph-gallery.com › 14-venn-diagramm
Venn Diagram – the R Graph Gallery
# Load library library(VennDiagram) # Generate 3 sets of 200 words set1 <- paste(rep("word_" , 200) , sample(c(1:1000) , 200 , replace=F) , sep="") set2 <- paste(rep("word_" , 200) , sample(c(1:1000) , 200 , replace=F) , sep="") set3 <- paste(rep("word_" , 200) , sample(c(1:1000) , 200 , replace=F) , sep="") # Prepare a palette of 3 colors with R colorbrewer: library(RColorBrewer) myCol <- brewer.pal(3, "Pastel2") # Chart venn.diagram( x = list(set1, set2, set3), category.names = c("Set 1" , "Set 2 " , "Set 3"), filename = '#14_venn_diagramm.png', output=TRUE, # Output features imagetype="png"
🌐
Rdrr.io
rdrr.io › cran › VennDiagram › man › calculate.overlap.html
calculate.overlap: Calculate Overlap in VennDiagram: Generate High-Resolution Venn and Euler Plots
January 11, 2026 - Returns a list of lists which contain the values assigned to each of the areas of a venn diagram. ... # A simple single-set diagram cardiome <- letters[1:10] superset <- letters[8:24] overlap <- calculate.overlap( x = list( "Cardiome" = cardiome, "SuperSet" = superset ) );
🌐
Statistics Globe
statisticsglobe.com › home › learn r programming (tutorial & examples) | free introduction › how to create a venn diagram in r (8 examples)
Venn Diagram in R (8 Examples) | Single, Pairwise, Tripple, Multiple
March 17, 2022 - I am using the VennDiagram package and the diagram is fine. But I don’t know why the total numbers are not matching from the original datasets. Suppose, A=762 & B=641 $ overlapping is 222, then the unique numbers in A & B circles should be 540 and 419 respectively.
🌐
R Project
search.r-project.org › CRAN › refmans › VennDiagram › html › calculate.overlap.html
R: Calculate Overlap
calculate.overlap(x) This function mostly complements the venn.diagram() function for the case where users want to know what values are grouped into the particular areas of the venn diagram. Returns a list of lists which contain the values assigned to each of the areas of a venn diagram.
🌐
Datanovia
datanovia.com › home › venn diagram with r or rstudio: a million ways
Venn Diagram with R or RStudio: A Million Ways - Datanovia
April 15, 2025 - This article provides multiple solutions to create an elegant Venn diagram with R or RStudio. The following R packages will be illustrated: ggvenn, ggVenDiagram, VennDiagram and the gplots packages. ... set.seed(20190708) genes <- paste("gene",1:1000,sep="") x <- list( A = sample(genes,300), B = sample(genes,525), C = sample(genes,440), D = sample(genes,350) )
🌐
RDocumentation
rdocumentation.org › packages › VennDiagram › versions › 1.7.3 › topics › calculate.overlap
calculate.overlap function - RDocumentation
Returns a list of lists which contain the values assigned to each of the areas of a venn diagram. This function mostly complements the venn.diagram() function for the case where users want to know what values are grouped into the particular areas of the venn diagram.
Find elsewhere
🌐
R Project
search.r-project.org › CRAN › refmans › dga › html › venn4.html
R: Four List Venn Diagram
venn4( overlap.counts, main = NULL, num.test.points = 1e+05, p.cex = 0.75, cex.main = 1 ) A venn diagram of the list overlap structure for four lists.
Top answer
1 of 4
13

Take a look at ?intersect, ?union and ?setdiff function to extract the different fields of the Venn diagram.

I have created some list versions of the two functions to better get the elements in the different compartments:

Intersect <- function (x) {  
  # Multiple set version of intersect
  # x is a list
  if (length(x) == 1) {
    unlist(x)
  } else if (length(x) == 2) {
    intersect(x[[1]], x[[2]])
  } else if (length(x) > 2){
    intersect(x[[1]], Intersect(x[-1]))
  }
}

Union <- function (x) {  
  # Multiple set version of union
  # x is a list
  if (length(x) == 1) {
    unlist(x)
  } else if (length(x) == 2) {
    union(x[[1]], x[[2]])
  } else if (length(x) > 2) {
    union(x[[1]], Union(x[-1]))
  }
}

Setdiff <- function (x, y) {
  # Remove the union of the y's from the common x's. 
  # x and y are lists of characters.
  xx <- Intersect(x)
  yy <- Union(y)
  setdiff(xx, yy)
}

So, if we want to see the common elements (i.e. the union of A, B, C, and D) or the ones in C and D but not in A and B in your example we do something like the following.

set.seed(1)
xx.1 <- list(A = sample(LETTERS, 15), 
             B = sample(LETTERS, 15), 
             C = sample(LETTERS, 15), 
             D = sample(LETTERS, 15))
Intersect(xx.1)
#[1] "E" "L"
Setdiff(xx.1[c("C", "D")], xx.1[c("A", "B")])
#[1] "O" "P" "K" "H"

Hope this helps!

Edit: Systematically get all components

By some (I think) clever use of the combn function, indexing, and a good understanding of lapply we can all elements systematically:

# Create a list of all the combinations
combs <- 
  unlist(lapply(1:length(xx.1), 
                function(j) combn(names(xx.1), j, simplify = FALSE)),
         recursive = FALSE)
names(combs) <- sapply(combs, function(i) paste0(i, collapse = ""))
str(combs)
#List of 15
# $ A   : chr "A"
# $ B   : chr "B"
# $ C   : chr "C"
# $ D   : chr "D"
# $ AB  : chr [1:2] "A" "B"
# $ AC  : chr [1:2] "A" "C"
# $ AD  : chr [1:2] "A" "D"
# $ BC  : chr [1:2] "B" "C"
# $ BD  : chr [1:2] "B" "D"
# $ CD  : chr [1:2] "C" "D"
# $ ABC : chr [1:3] "A" "B" "C"
# $ ABD : chr [1:3] "A" "B" "D"
# $ ACD : chr [1:3] "A" "C" "D"
# $ BCD : chr [1:3] "B" "C" "D"
# $ ABCD: chr [1:4] "A" "B" "C" "D"

# "A" means "everything in A minus all others"
# "A", "B" means "everything in "A" and "B" minus all others" and so on
elements <- 
  lapply(combs, function(i) Setdiff(xx.1[i], xx.1[setdiff(names(xx.1), i)]))

n.elements <- sapply(elements, length)
print(n.elements)
#   A    B    C    D   AB   AC   AD   BC   BD   CD  ABC  ABD  ACD  BCD ABCD 
#   2    2    0    0    1    2    2    0    3    4    4    1    1    2    2 
2 of 4
11

You can also use venn in gplots package to get a list of items in each section of venn diagram ('ItemsList'). Given your list xx.1, it should be:

ItemsList <- venn(xx.1, show.plot = FALSE)

ItemsList contains:

  1. a matrix of all diagram sections and the counts of items in these sections and
  2. the list of items in each Venn diagram section.

to get the counts:

lengths(attributes(ItemsList)$intersections)
# A       B     A:B     A:C     A:D     B:D     C:D   A:B:C   A:B:D   A:C:D   B:C:D A:B:C:D 
# 2       2       1       2       2       3       4       4       1       1       2       2
🌐
R Project
search.r-project.org › CRAN › refmans › dga › html › venn3.html
R: Three List Venn Diagram
venn3( overlap.counts, main = NULL, num.test.points = 1e+05, p.cex = 0.75, write_numbers = FALSE, t.cex = 1.25, cex.main = 1 ) a 3-way venn diagram with points inside of each segment representing the number of records on each list overlap.
🌐
R-bloggers
r-bloggers.com › r bloggers › set analysis: a face off between venn diagrams and upset plots
Set Analysis: A face off between Venn diagrams and UpSet plots | R-bloggers
May 1, 2019 - # Set the chart data expressionInput <- c(`#rstats` = 5, memes = 5, `#rstats&memes` = 3) To create a simple Venn diagram, you can just pass in the list with the specified set and overlap values into the venneuler() function.
🌐
IOS Press
content.iospress.com › articles › data-science › ds210032
BioVenn – an R and Python package for the comparison and visualization of biological lists using area-proportional Venn diagrams - Tim Hulsen, 2021
Some web-based tools were created that can create area-proportional Venn diagrams, such as the (deprecated) tools VennMaster [13] and DrawEuler [17]. In 2003, the website Venndiagram.tk [9] was launched, followed in 2007 by the BioVenn web interface [12], which has been used to create publication figures by many researchers [7], and is still available at this moment. The “Bio” in BioVenn showcases that it can do mapping of biological identifiers before determining sets and overlaps. Another useful functionality of BioVenn is that it displays the list of elements belonging to each of the subsets in the Venn diagram, i.e., the thirteen subsets resulting from the overlaps between the circles X, Y and Z.
🌐
GitHub
github.com › cran › VennDiagram › blob › master › R › venn.diagram.R
VennDiagram/R/venn.diagram.R at master · cran/VennDiagram
return(grob.list); } · calculate.overlap <- function(x) { # draw a single-set Venn diagram · if (1 == length(x)) { overlap <- x; } · # draw a pairwise Venn diagram · else if (2 == length(x)) { · overlap <- list( a1 = x[[1]], a2 = x[[2]], a3 = intersect(x[[1]],x[[2]]) ); } ·
Author   cran
🌐
Bioconductor
bioconductor.org › packages › › release › bioc › vignettes › VennDetail › inst › doc › VennDetail.html
The VennDetail package
VennDetail An R package for visualizing and extracting details of multi-sets intersection · Visualizing and extracting unique (disjoint) or overlapping subsets of multiple gene datasets are a frequently performed task for bioinformatics. Although various packages and web applications are available, no R package offering functions to extract and combine details of these subsets with user datasets in data frame is available.
🌐
Rdrr.io
rdrr.io › cran › VennDiagram › src › R › venn.diagram.R
VennDiagram source: R/venn.diagram.R
4 <- intersect(n13, D); n234 <- intersect(n23, D); n1234 <- intersect(n123, D); # calculate overlaps a6 = n1234; a12 = n123[which(!n123 %in% a6)]; a11 = n124[which(!n124 %in% a6)]; a5 = n134[which(!n134 %in% a6)]; a7 = n234[which(!n234 %in% a6)]; a15 = n12[which(!n12 %in% c(a6,a11,a12))]; a4 = n13[which(!n13 %in% c(a6,a5,a12))]; a10 = n14[which(!n14 %in% c(a6,a5,a11))]; a13 = n23[which(!n23 %in% c(a6,a7,a12))]; a8 = n24[which(!n24 %in% c(a6,a7,a11))]; a2 = n34[which(!n34 %in% c(a6,a5,a7))]; a9 = A[which(!A %in% c(a4,a5,a6,a10,a11,a12,a15))]; a14 = B[which(!B %in% c(a6,a7,a8,a11,a12,a13,a15))];