This function creates a Venn diagram using the eulerr package to visualize
intersections across multiple sets. Supports both
GenomicOverlapResult and SetOverlapResult objects. Diagrams are
recommended for two to four sets: beyond that, an area-proportional layout
is rarely attainable, and plotUpSet is the better choice.
Usage
plotVenn(
overlap_object,
fills = TRUE,
edges = TRUE,
labels = FALSE,
quantities = list(type = "counts"),
legend = "right",
main = NULL,
verbose = TRUE,
...
)Arguments
- overlap_object
A
GenomicOverlapResultorSetOverlapResultobject returned bycomputeOverlaps.- fills
Controls the fill appearance of the diagram. Can be:
logical:
TRUE(default) shows fills,FALSEhides themcharacter vector: Colors for the fills. Default colors are: c("#2B70AB", "#FFB027", "#3EA742", "#CD3301", "#9370DB", "#008B8B", "#D87093", "#C7C4FC", "#FCBAA3", "#187EFA", "#CFCE64", "#527346", "#F8B6D8", "#AB80C5", "#B99074"). One color is used per region of the diagram, so a two-set diagram uses the first three, a three-set diagram the first seven, and a four-set diagram all fifteen.
list: Fine control with graphical parameters including
fill(colors),alpha(transparency 0-1)
- edges
Controls the edge/border appearance. Can be:
logical:
TRUE(default) shows edges,FALSEhides themcharacter vector: Colors for the edges
list: Fine control with
col(colors),alpha(transparency 0-1),lty(line type),lwd(line width),lex(line expansion)
- labels
Controls set labels. Can be:
logical:
TRUEshows default labels,FALSEhides themcharacter vector: Custom text for labels
list: Fine control with
col(text color),fontsize,font(1=plain, 2=bold, 3=italic, 4=bold italic),fontfamily,cex(character expansion),alpha(transparency 0-1)
- quantities
Controls intersection quantities display. Can be:
logical:
TRUEshows counts,FALSEhides themcharacter vector: Custom text labels
list: Fine control with
type(c("counts", "percent")),col(text color),fontsize,font,fontfamily,cex,alpha
- legend
Controls the legend. Can be:
logical:
FALSEto disablecharacter: Position ("right", "top", "bottom", "left")
list: Fine control with
side(position),labels(custom labels),col,fontsize,cex,fontfamily
- main
Title for the plot. Can be character, expression, or list with
label(text),col,fontsize,font,fontfamily- verbose
Logical. If
TRUE(default), printsdiagErrorand whether it exceeds the 1e-6 threshold, and names any populated region the diagram gives no area to. The diagnostics are attached to the returned object regardless (seeValue).- ...
Additional arguments passed to
plot.euler.
Value
A Venn diagram plot generated by eulerr, with two
attributes:
"fit_diagnostics": a list withstress,diagError,regionError(seeeuler) andundrawnRegions, the populated regions given no area.diagErroris the largest difference, over all regions, between the share of the diagram's area a region receives and the share its count requires; Micallef and Rodgers (2014) consider a diagram accurate when it is at most 1e-6."euler_fit": theeulerrfit itself.
See also
plotVennError to see which regions the diagram
misrepresents and in which direction, plotUpSet.
Examples
# Example with gene sets
data(gene_list)
res_sets <- computeOverlaps(gene_list)
# Basic plot
plotVenn(res_sets)
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Customize fills with transparency and custom colors
plotVenn(res_sets,
fills = list(fill = c("#FF6B6B", "#4ECDC4", "#45B7D1"),
alpha = 0.6))
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Customize edges
plotVenn(res_sets,
edges = list(col = "darkgray", lwd = 2, lty = 2))
#> ✔ Venn diagError = 2.510e-14 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Customize labels
plotVenn(res_sets,
labels = list(col = "white", font = 2, fontsize = 14))
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Show both counts and percentages
plotVenn(res_sets,
quantities = list(type = c("counts", "percent"),
col = "black", fontsize = 10))
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Add a title
plotVenn(res_sets,
main = list(label = "Gene Set Overlaps",
col = "navy", fontsize = 16, font = 2))
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Transparent fills with colored borders only
plotVenn(res_sets,
fills = "transparent",
edges = list(col = c("red", "blue", "green"), lwd = 3))
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Custom legend
plotVenn(res_sets,
legend = list(side = "bottom",
labels = c("Treatment A", "Treatment B", "Control"),
fontsize = 12))
#> ✔ Venn diagError = 8.693e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
# Inspect eulerr's fit diagnostics (stress, diagError, regionError)
venn <- plotVenn(res_sets)
#> ✔ Venn diagError = 2.821e-13 (<= 1e-06)
#> Access fit diagnostics with attr(<plotVenn output>, "fit_diagnostics")
attr(venn, "fit_diagnostics")
#> $stress
#> [1] 5.208696e-25
#>
#> $diagError
#> [1] 2.820591e-13
#>
#> $regionError
#> random_genes_A
#> 1.323386e-13
#> random_genes_B
#> 1.004752e-13
#> random_genes_C
#> 1.043610e-13
#> random_genes_A&random_genes_B
#> 3.377854e-14
#> random_genes_A&random_genes_C
#> 2.820591e-13
#> random_genes_B&random_genes_C
#> 9.008072e-14
#> random_genes_A&random_genes_B&random_genes_C
#> 6.875056e-14
#>
#> $undrawnRegions
#> character(0)
#>