| Title: | Comprehensive Visualization and Analysis of Multi-Set Intersections |
|---|---|
| Description: | A comprehensive package for visualizing multi-set intersections and extracting detailed subset information. VennDetail generates high-resolution visualizations including traditional Venn diagrams, Venn-pie plots, and UpSet-style plots. It provides functions to extract and combine subset details with user datasets in various formats. The package is particularly useful for bioinformatics applications but can be used for any multi-set analysis. |
| Authors: | Kai Guo [aut, cre], Brett McGregor [aut], James Porter [aut], Junguk Hur [aut] |
| Maintainer: | Kai Guo <[email protected]> |
| License: | GPL-2 |
| Version: | 1.29.0 |
| Built: | 2026-05-29 10:01:12 UTC |
| Source: | https://github.com/bioc/VennDetail |
A comprehensive package for visualizing multi-set intersections and extracting detailed subset information. VennDetail generates high-resolution visualizations including traditional Venn diagrams, Venn-pie plots, and UpSet-style plots. It provides functions to extract and combine subset details with user datasets in various formats.
The VennDetail package offers several powerful visualization and analysis tools:
Visualization methods:
Traditional Venn diagram (for 2-5 sets)
VennPie visualization (useful for more than 5 sets)
UpSet plot (matrix-based visualization)
Bar plot (simple visualization of subset sizes)
Key features:
Extraction of elements in any subset combination
Combining subset information with user-supplied data frames
Statistical analysis of set intersections
Enrichment analysis for set members
Interactive visualizations
High-resolution figure export
Shiny app for interactive exploration
To create a Venn object for analysis:
“' # Create sample datasets A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE)
# Create a Venn object res <- venndetail(list(A = A, B = B, C = C)) “'
“' # Traditional Venn diagram vennDiagram(res)
# VennPie visualization vennpie(res)
# UpSet plot upsetPlot(res)
# Bar plot dplot(res, order = TRUE)
# Generic plot function with type selection plot(res, type = "venn") “'
“' # Extract elements shared by all sets shared <- getSet(res, "Shared")
# Extract elements unique to set A unique_to_A <- getSet(res, "A") “'
“' # Test for significance of overlaps stats <- vennStats(res) “'
Kai Guo, Brett McGregor
Useful links:
Give first colname as RowNxyz
.add_colnames(x).add_colnames(x)
x |
data frame |
return data frame with the first colnames change to "RowNxyz"
make table for venndetail modified from make.truth.table (VennDiagram)
.make.table(x).make.table(x)
x |
A list with input groups |
A data frame with logical vector columns and 2 ^ length(x)-1 rows.
Kai Guo
Extract elements from the result slot of a Venn object using bracket notation.
## S3 method for class 'Venn' x[i, j]## S3 method for class 'Venn' x[i, j]
x |
Venn object |
i |
Row indices |
j |
Column indices |
Subset of the result data.frame
Extract a column from the result slot of a Venn object using $ notation.
## S3 method for class 'Venn' x$name## S3 method for class 'Venn' x$name
x |
Venn object |
name |
Column name to extract |
Vector containing the specified column
Internal utility functions for the VennDetail package
Converts a Venn object to a data frame for easier manipulation
## S3 method for class 'Venn' as.data.frame(x, ...)## S3 method for class 'Venn' as.data.frame(x, ...)
x |
A Venn object |
... |
Additional arguments (not used) |
A data frame with subset information
Kai Guo
# Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) res <- venndetail(list(A = A, B = B)) # Convert to data frame df <- as.data.frame(res) head(df)# Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) res <- venndetail(list(A = A, B = B)) # Convert to data frame df <- as.data.frame(res) head(df)
Compares two Venn objects and returns a list of differences
compareVenn(x, y, what = c("groups", "subsets", "all"))compareVenn(x, y, what = c("groups", "subsets", "all"))
x |
First Venn object |
y |
Second Venn object |
what |
What to compare: "groups" (default), "subsets", or "all" |
A list with differences between the objects
Kai Guo
# Create two Venn objects A1 <- sample(1:100, 40, replace = FALSE) B1 <- sample(1:100, 60, replace = FALSE) res1 <- venndetail(list(A = A1, B = B1)) A2 <- sample(1:100, 45, replace = FALSE) B2 <- sample(1:100, 55, replace = FALSE) res2 <- venndetail(list(A = A2, B = B2)) # Compare the objects compareVenn(res1, res2)# Create two Venn objects A1 <- sample(1:100, 40, replace = FALSE) B1 <- sample(1:100, 60, replace = FALSE) res1 <- venndetail(list(A = A1, B = B1)) A2 <- sample(1:100, 45, replace = FALSE) B2 <- sample(1:100, 55, replace = FALSE) res2 <- venndetail(list(A = A2, B = B2)) # Compare the objects compareVenn(res1, res2)
Creates a simple pie chart visualization for interactive exploration of set intersections
create_interactive_vennpie( object, subset = NULL, any = NULL, color = NULL, revcolor = "lightgrey", title = NULL )create_interactive_vennpie( object, subset = NULL, any = NULL, color = NULL, revcolor = "lightgrey", title = NULL )
object |
A Venn object |
subset |
Character vector of subset names to highlight |
any |
Highlight subsets shared by exactly this many sets |
color |
Optional vector of colors for the subsets |
revcolor |
Color for non-highlighted subsets |
title |
Optional plot title |
A plotly object
Kai Guo
Returns a named numeric vector with counts for each subset
The objective of this function is to summarizes the overlaps across groups identified by venndetail without creating diagram.
detail(object) ## S4 method for signature 'Venn' detail(object)detail(object) ## S4 method for signature 'Venn' detail(object)
object |
A Venn object |
A named numeric vector with counts for each subset
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) detail(res) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) detail(res)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) detail(res) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) detail(res)
Returns the dimensions of the result slot in a Venn object.
## S3 method for class 'Venn' dim(x)## S3 method for class 'Venn' dim(x)
x |
Venn object |
Integer vector of length 2 (rows, columns)
Creates a bar plot showing counts for each subset
dplot( object, order = FALSE, textsize = 5, color = NULL, theme = ggplot2::theme_light(), title = NULL, xlabel = NULL, ylabel = NULL ) ## S4 method for signature 'Venn' dplot(object, order = FALSE, textsize = 5)dplot( object, order = FALSE, textsize = 5, color = NULL, theme = ggplot2::theme_light(), title = NULL, xlabel = NULL, ylabel = NULL ) ## S4 method for signature 'Venn' dplot(object, order = FALSE, textsize = 5)
object |
Venn object |
order |
Boolean indicating whether to sort the bar (default: FALSE). |
textsize |
Numeric vector giving the text size above the bar. |
color |
Optional vector of colors for the bars |
theme |
The ggplot2 theme to use. Default: theme_light |
title |
Optional plot title |
xlabel |
Optional x-axis label |
ylabel |
Optional y-axis label |
A ggplot2 object
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) dplot(res, order = TRUE, textsize = 3) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) dplot(res, order = TRUE, textsize = 3)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) dplot(res, order = TRUE, textsize = 3) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) dplot(res, order = TRUE, textsize = 3)
Combines subset information with user-supplied data frames
GetFeature allows users to extract subsets from venn object into a table format along with accompanying information from the data frames provided in the rlist argument
getFeature( object, subset, rlist, userowname = TRUE, gind = NULL, sep = "_", wide = FALSE ) ## S4 method for signature 'Venn' getFeature( object, subset, rlist, userowname = TRUE, gind = NULL, sep = "_", wide = FALSE )getFeature( object, subset, rlist, userowname = TRUE, gind = NULL, sep = "_", wide = FALSE ) ## S4 method for signature 'Venn' getFeature( object, subset, rlist, userowname = TRUE, gind = NULL, sep = "_", wide = FALSE )
object |
Venn object |
subset |
Character vector giving the names of the user-defined subset to extract |
rlist |
List of user-supplied data frames to combine with venndetail result |
userowname |
Boolean indicating whether to use row names to join data frames or not (default: TRUE) |
gind |
Column name or index of each user-supplied data.frame to use to join data frames(valid only when userowname=FALSE) |
sep |
Character string used to separate the terms when concatenating group names into new separation character for new column names in the resulting data frame |
wide |
Boolean indicating whether to use wide format(default:FALSE) |
A data.frame combining subset information with user data
data.frame with subsets information and details from the user supplied data frame
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) dC <- data.frame(C = C, "FC" = rnorm(40)) res <- venndetail(list(A = A, B = B, C = C)) features <- getFeature(res, subset = "Shared", rlist = list(dA, dB, dC), userowname = FALSE, gind = rep(1, 3)) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) dC <- data.frame(C = C, "FC" = rnorm(40)) res <- venndetail(list(A = A, B = B, C = C)) rhs <- getFeature(res, subset = "Shared", rlist = list(dA, dB, dC), userowname= FALSE, gind = rep(1, 3))A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) dC <- data.frame(C = C, "FC" = rnorm(40)) res <- venndetail(list(A = A, B = B, C = C)) features <- getFeature(res, subset = "Shared", rlist = list(dA, dB, dC), userowname = FALSE, gind = rep(1, 3)) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) dC <- data.frame(C = C, "FC" = rnorm(40)) res <- venndetail(list(A = A, B = B, C = C)) rhs <- getFeature(res, subset = "Shared", rlist = list(dA, dB, dC), userowname= FALSE, gind = rep(1, 3))
Extracts elements from specified subsets
getSet function provides a way to extract subsets from venndetail object
getSet(object, subset = NULL, min = 0, wide = FALSE) ## S4 method for signature 'Venn' getSet(object, subset = NULL, min = 0, wide = FALSE)getSet(object, subset = NULL, min = 0, wide = FALSE) ## S4 method for signature 'Venn' getSet(object, subset = NULL, min = 0, wide = FALSE)
object |
Venn object |
subset |
Character vector giving the subset names |
min |
The minimum number of input groups that a subset must belong to e.g. min = 2 will only report those subsets with elements shared by 2 or more input groups. |
wide |
Boolean indicating return wide format (default: FALSE). |
A data.frame with elements from the specified subsets
Specific subset information
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Get elements unique to set A unique_to_A <- getSet(res, "A") # Get elements shared by all sets shared <- getSet(res, "Shared") A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) getSet(res, "A")A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Get elements unique to set A unique_to_A <- getSet(res, "A") # Get elements shared by all sets shared <- getSet(res, "Shared") A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) getSet(res, "A")
Methods to extract the first or last parts of a Venn object's result slot.
## S3 method for class 'Venn' head(x, n = 6L, ...) ## S3 method for class 'Venn' tail(x, n = 6L, ...)## S3 method for class 'Venn' head(x, n = 6L, ...) ## S3 method for class 'Venn' tail(x, n = 6L, ...)
x |
Venn object |
n |
number of rows to display |
... |
other arguments ignored (for compatibility with generic) |
A data.frame with the first n rows
A data.frame with the last n rows
Loads a Venn object from an RDS file
loadVenn(file)loadVenn(file)
file |
File name to load from |
A Venn object
Kai Guo
## Not run: # Load a saved Venn object res <- loadVenn("my_venn.rds") # Plot the loaded object plot(res) ## End(Not run)## Not run: # Load a saved Venn object res <- loadVenn("my_venn.rds") # Plot the loaded object plot(res) ## End(Not run)
Identifies all possible intersections between sets and returns a list of subsets
make_subset(x, sep = "_")make_subset(x, sep = "_")
x |
A list of vectors |
sep |
Character used to separate set names in subset labels |
A named list where each element contains the unique items in that subset
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) x <- list(A = A, B = B, C = C) subsets <- make_subset(x) lengths(subsets) # Number of elements in each subsetA <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) x <- list(A = A, B = B, C = C) subsets <- make_subset(x) lengths(subsets) # Number of elements in each subset
Get subset from list of input groups
make.subset(x, sep = "_")make.subset(x, sep = "_")
x |
A list with input groups |
sep |
symbol character used when concatenating group names into subset names |
A list of subsets. The names on the list are the subset names and the list elements are the subset details.
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) x <- list(A = A, B = B, C = C) out <- make.subset(x)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) x <- list(A = A, B = B, C = C) out <- make.subset(x)
Merge will combine multiple venn diagrams to allow comparison between multiple groups
## S3 method for class 'Venn' merge(x, y, ignore.case = FALSE, useupper = TRUE, plot = FALSE, ...)## S3 method for class 'Venn' merge(x, y, ignore.case = FALSE, useupper = TRUE, plot = FALSE, ...)
x |
Venn object |
y |
Venn object |
ignore.case |
Boolean indicating whether to ignore case of group names (default: FALSE) |
useupper |
Boolean indicating whether to use uppercases for group names (default: TRUE) |
plot |
Boolean indicating whether to plot figure or not (default: FALSE) |
... |
arguments for venndetail |
venn object
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res1 <- venndetail(list(A = A, B = B)) res2 <- venndetail(list(A = A, C = C)) res <- merge(res1, res2)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res1 <- venndetail(list(A = A, B = B)) res2 <- venndetail(list(A = A, C = C)) res <- merge(res1, res2)
Returns the names of all subsets in a Venn object
## S3 method for class 'Venn' names(x)## S3 method for class 'Venn' names(x)
x |
A Venn object |
A character vector of subset names
Kai Guo
# Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) res <- venndetail(list(A = A, B = B)) # Get subset names names(res)# Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) res <- venndetail(list(A = A, B = B)) # Get subset names names(res)
Constructor function for creating Venn objects with validation
newVenn( input, raw, sep = "_", GroupNames, result, detail, wide, metadata = list() )newVenn( input, raw, sep = "_", GroupNames, result, detail, wide, metadata = list() )
input |
A list of input sets |
raw |
A named vector with counts |
sep |
The separator character |
GroupNames |
Names of the input groups |
result |
The result data.frame |
detail |
The detail vector |
wide |
The wide-format data.frame |
metadata |
Additional metadata (optional) |
A new Venn object
Kai Guo
## Not run: A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) raw <- c(A = 40, B = 60) groups <- c("A", "B") # Create a new Venn object manually (normally done by venndetail function) venn_obj <- newVenn(input = list(A = A, B = B), raw = raw, GroupNames = groups, ...) ## End(Not run)## Not run: A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) raw <- c(A = 40, B = 60) groups <- c("A", "B") # Create a new Venn object manually (normally done by venndetail function) venn_obj <- newVenn(input = list(A = A, B = B), raw = raw, GroupNames = groups, ...) ## End(Not run)
Unified plotting function for Venn objects that supports multiple visualization types
## S3 method for class 'Venn' plot( x, type = "venn", title = NULL, interactive = FALSE, filename = NULL, width = 8, height = 6, dpi = 300, fill = NULL, alpha = 0.5, labels = TRUE, counts = TRUE, showNumbers = TRUE, numberSize = 4, numberColor = "black", labelSize = 4, labelColor = "black", borderCol = FALSE, fillCol = TRUE, fixedCoords = TRUE, xlim = c(0, 1), ylim = c(0, 1), show_percentages = TRUE, show_unique_only = FALSE, scaled = FALSE, subset = NULL, top = 31, min = 0, color = NULL, revcolor = "lightgrey", any = NULL, show.number = TRUE, show.x = TRUE, sep = "_", log = FALSE, base = NULL, percentage = FALSE, nintersects = 40, min_size = 1, sets_bar_color = NULL, main_bar_color = "steelblue", point_size = 3, line_size = 1, show_numbers = TRUE, sort_intersections_by = "freq", sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", highlight_intersections = NULL, highlight_color = "darkorange", empty_point_size = 1.5, bar_width = 0.7, text_angle = 0, text_size = 10, set_label_size = 3, intersection_label_size = 3, point_outline_color = "black", point_stroke = 0.3, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, plot_margin = 0.5, height_ratio = 0.7, width_ratio = 0.3, bar_offset = -0.01, set_text_size = 10, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), return_data = FALSE, order = FALSE, textsize = 5, theme = ggplot2::theme_light(), xlabel = NULL, ylabel = NULL, ... )## S3 method for class 'Venn' plot( x, type = "venn", title = NULL, interactive = FALSE, filename = NULL, width = 8, height = 6, dpi = 300, fill = NULL, alpha = 0.5, labels = TRUE, counts = TRUE, showNumbers = TRUE, numberSize = 4, numberColor = "black", labelSize = 4, labelColor = "black", borderCol = FALSE, fillCol = TRUE, fixedCoords = TRUE, xlim = c(0, 1), ylim = c(0, 1), show_percentages = TRUE, show_unique_only = FALSE, scaled = FALSE, subset = NULL, top = 31, min = 0, color = NULL, revcolor = "lightgrey", any = NULL, show.number = TRUE, show.x = TRUE, sep = "_", log = FALSE, base = NULL, percentage = FALSE, nintersects = 40, min_size = 1, sets_bar_color = NULL, main_bar_color = "steelblue", point_size = 3, line_size = 1, show_numbers = TRUE, sort_intersections_by = "freq", sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", highlight_intersections = NULL, highlight_color = "darkorange", empty_point_size = 1.5, bar_width = 0.7, text_angle = 0, text_size = 10, set_label_size = 3, intersection_label_size = 3, point_outline_color = "black", point_stroke = 0.3, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, plot_margin = 0.5, height_ratio = 0.7, width_ratio = 0.3, bar_offset = -0.01, set_text_size = 10, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), return_data = FALSE, order = FALSE, textsize = 5, theme = ggplot2::theme_light(), xlabel = NULL, ylabel = NULL, ... )
x |
A Venn object |
type |
Type of plot: "venn" (traditional Venn diagram), "vennpie" (pie-chart style), "upset" (UpSet plot), or "bar" (bar plot of subset sizes) |
title |
Optional plot title |
interactive |
Logical: create an interactive plot? Default: FALSE |
filename |
Optional file name to save the plot |
width |
Width of the saved plot (default: 8) |
height |
Height of the saved plot (default: 6) |
dpi |
Resolution in dots per inch (default: 300) |
fill |
Colors for filling the circles (venn) |
alpha |
Transparency level (0-1), default: 0.5 (venn) |
labels |
Logical: show set labels? Default: TRUE (venn) |
counts |
Logical: show counts? Default: TRUE (venn) |
showNumbers |
Logical: show counts and percentages? Default: TRUE (venn) |
numberSize |
Size of count labels, default: 4 (venn) |
numberColor |
Color of count labels, default: "black" (venn) |
labelSize |
Size of set labels, default: 4 (venn) |
labelColor |
Color of set labels, default: "black" (venn) |
borderCol |
Logical: color borders? Default: FALSE (venn) |
fillCol |
Logical: fill circles? Default: TRUE (venn) |
fixedCoords |
Logical: fixed coordinates? Default: TRUE (venn) |
xlim |
X axis limits, default: c(0, 1) (venn) |
ylim |
Y axis limits, default: c(0, 1) (venn) |
show_percentages |
Logical: show percentages? Default: TRUE (venn) |
show_unique_only |
Logical: show unique only? Default: FALSE (venn) |
scaled |
Logical: scale circles? Default: FALSE (venn) |
subset |
Character vector of subsets to highlight (vennpie) |
top |
Maximum subsets to display, default: 31 (vennpie) |
min |
Minimum set membership, default: 0 (vennpie/getSet) |
color |
Colors for subsets (vennpie/bar) |
revcolor |
Color for non-highlighted, default: "lightgrey" (vennpie) |
any |
Highlight subsets shared by this many sets (vennpie) |
show.number |
Logical: show counts? Default: TRUE (vennpie) |
show.x |
Logical: show labels? Default: TRUE (vennpie) |
sep |
Character separator, default: "_" (vennpie) |
log |
Logical: use log scale? Default: FALSE (vennpie) |
base |
Base for log transformation (vennpie) |
percentage |
Logical: show percentages? Default: FALSE (vennpie) |
nintersects |
Maximum intersections, default: 40 (upset) |
min_size |
Minimum intersection size, default: 1 (upset) |
sets_bar_color |
Colors for set size bars (upset) |
main_bar_color |
Color for intersection bars, default: "steelblue" (upset) |
point_size |
Size of matrix points, default: 3 (upset) |
line_size |
Width of matrix lines, default: 1 (upset) |
show_numbers |
Logical: show bar counts? Default: TRUE (upset) |
sort_intersections_by |
Sort method: "freq", "degree", or "custom" (upset) |
sort_sets_by |
Sort method: "size", "name", or "custom" (upset) |
sort_sets_decreasing |
Logical: decreasing order? Default: TRUE (upset) |
custom_sets_order |
Custom set order (upset) |
sort_intersections_decreasing |
Logical: decreasing? Default: TRUE (upset) |
custom_intersections_order |
Custom intersection order (upset) |
intersection_color |
Color for dots/lines, default: "black" (upset) |
highlight_intersections |
IDs to highlight (upset) |
highlight_color |
Highlight color, default: "darkorange" (upset) |
empty_point_size |
Empty point size, default: 1.5 (upset) |
bar_width |
Bar width (0-1), default: 0.7 (upset) |
text_angle |
Text angle, default: 0 (upset) |
text_size |
Text size, default: 10 (upset) |
set_label_size |
Set label size, default: 3 (upset) |
intersection_label_size |
Intersection label size, default: 3 (upset) |
point_outline_color |
Point outline color, default: "black" (upset) |
point_stroke |
Point outline width, default: 0.3 (upset) |
set_size_show_values |
Show set values? Default: TRUE (upset) |
intersection_size_show_values |
Show intersection values? Default: TRUE (upset) |
show_empty_intersections |
Show empty? Default: FALSE (upset) |
show_set_labels |
Show set labels? Default: TRUE (upset) |
plot_margin |
Margin in cm, default: 0.5 (upset) |
height_ratio |
Matrix height ratio, default: 0.7 (upset) |
width_ratio |
Set size width ratio, default: 0.3 (upset) |
bar_offset |
Bar offset, default: -0.01 (upset) |
set_text_size |
Set label size, default: 10 (upset) |
intersection_title |
Intersection title (upset) |
set_size_title |
Set size title (upset) |
matrix_point_shape |
Point shape, default: 21 (upset) |
number_color_threshold |
Color threshold, default: 0.75 (upset) |
number_colors |
Label colors vector (upset) |
theme_params |
Theme parameters list (upset) |
return_data |
Return data? Default: FALSE (upset) |
order |
Logical: order bars? Default: FALSE (bar) |
textsize |
Text size, default: 5 (bar) |
theme |
ggplot2 theme (bar) |
xlabel |
X-axis label (bar) |
ylabel |
Y-axis label (bar) |
... |
Additional arguments passed to the specific plotting function |
A ggplot2 or plotly object
Kai Guo
# Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Traditional Venn diagram plot(res, type = "venn") # Venn diagram with custom colors and transparency plot(res, type = "venn", fill = c("red", "blue", "green"), alpha = 0.3) # Venn-pie visualization plot(res, type = "vennpie") # Venn-pie with highlighted subsets plot(res, type = "vennpie", any = 2, log = TRUE) # UpSet plot plot(res, type = "upset") # UpSet plot with custom sorting and highlighting plot(res, type = "upset", sort_sets_by = "size", highlight_intersections = c(1, 2), highlight_color = "red") # Bar plot of subset sizes plot(res, type = "bar") # Ordered bar plot with larger text plot(res, type = "bar", order = TRUE, textsize = 8) # Save plot to file (not run during check) ## Not run: plot(res, type = "venn", filename = "my_venn.png", width = 10, height = 8) ## End(Not run) # Create interactive plot if(interactive()) { plot(res, type = "venn", interactive = TRUE) }# Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Traditional Venn diagram plot(res, type = "venn") # Venn diagram with custom colors and transparency plot(res, type = "venn", fill = c("red", "blue", "green"), alpha = 0.3) # Venn-pie visualization plot(res, type = "vennpie") # Venn-pie with highlighted subsets plot(res, type = "vennpie", any = 2, log = TRUE) # UpSet plot plot(res, type = "upset") # UpSet plot with custom sorting and highlighting plot(res, type = "upset", sort_sets_by = "size", highlight_intersections = c(1, 2), highlight_color = "red") # Bar plot of subset sizes plot(res, type = "bar") # Ordered bar plot with larger text plot(res, type = "bar", order = TRUE, textsize = 8) # Save plot to file (not run during check) ## Not run: plot(res, type = "venn", filename = "my_venn.png", width = 10, height = 8) ## End(Not run) # Create interactive plot if(interactive()) { plot(res, type = "venn", interactive = TRUE) }
Print method for upset_grob objects
## S3 method for class 'upset_grob' print(x, ...)## S3 method for class 'upset_grob' print(x, ...)
x |
An upset_grob object |
... |
Additional arguments (ignored) |
Invisibly returns the input object
Retrieves results from a Venn object in long or wide format
Result will return output in a table format including the contents of the subsets included in the venndetail object
result(object, wide = FALSE) ## S4 method for signature 'Venn' result(object, wide = FALSE)result(object, wide = FALSE) ## S4 method for signature 'Venn' result(object, wide = FALSE)
object |
A Venn object |
wide |
Logical: should results be returned in wide format? Default: FALSE |
A data.frame containing subset information
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Get results in long format result_long <- result(res) # Get results in wide format result_wide <- result(res, wide = TRUE) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) result <- result(res)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Get results in long format result_long <- result(res) # Get results in wide format result_wide <- result(res, wide = TRUE) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) result <- result(res)
Joins two data.frames using various join methods
join two dataframes by rownames
rowjoin(x, y, fun = "full_join", by = NULL) ## S4 method for signature 'data.frame,data.frame' rowjoin(x, y, fun = "full_join")rowjoin(x, y, fun = "full_join", by = NULL) ## S4 method for signature 'data.frame,data.frame' rowjoin(x, y, fun = "full_join")
x |
data.frame x |
y |
data.frame y |
fun |
Different join format: left_join, full_join, right_join (default:full_join) |
by |
Optional vector of column names to join by |
A joined data.frame
dataframe with join results
Kai Guo
library(dplyr) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) rownames(dA) <- A rownames(dB) <- B # Full join by row names result <- rowjoin(dA, dB) # Left join by row names result <- rowjoin(dA, dB, fun = "left_join") library(dplyr) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) rownames(dA) <- A rownames(dB) <- B rowjoin(dA, dB)library(dplyr) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) rownames(dA) <- A rownames(dB) <- B # Full join by row names result <- rowjoin(dA, dB) # Left join by row names result <- rowjoin(dA, dB, fun = "left_join") library(dplyr) A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) dA <- data.frame(A = A, "FC" = rnorm(40)) dB <- data.frame(B = B, "FC" = rnorm(60)) rownames(dA) <- A rownames(dB) <- B rowjoin(dA, dB)
Saves a Venn object to an RDS file for later use
saveVenn(object, file)saveVenn(object, file)
object |
A Venn object |
file |
File name to save to |
The file name (invisibly)
Kai Guo
## Not run: # Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) res <- venndetail(list(A = A, B = B)) # Save to a file saveVenn(res, "my_venn.rds") ## End(Not run)## Not run: # Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) res <- venndetail(list(A = A, B = B)) # Save to a file saveVenn(res, "my_venn.rds") ## End(Not run)
Setcolor will provide a list of color vectors based on the number used as an input.
setcolor(n, palette = "default")setcolor(n, palette = "default")
n |
Number of colors needed |
palette |
Type of palette: "default", "categorical", "sequential", or "diverging" |
color vector
Kai Guo
mycol <- setcolor(10) mycolmycol <- setcolor(10) mycol
This function provides a summary of the venn object, including a full results and subsets as well as an summary information.
## S4 method for signature 'Venn' show(object)## S4 method for signature 'Venn' show(object)
object |
venn object |
summary information for the venn object
Kai Guo
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) show(res)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) show(res)
print the summary information of Venn object
## S3 method for class 'Venn' summary(object, ...)## S3 method for class 'Venn' summary(object, ...)
object |
Venn object |
... |
other arguments ignored (for compatibility with generic) |
summary information
A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) summary(res)A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) summary(res)
T2DM data are differential expression genes (DEGs) with annotation from the publication by Hinder et al.
T2DM data are differential expression genes (DEGs) with annotation from the publication by Hinder et al. The data contains three DEG sets from three different tissues (Cortex,SCN,Glom). DEGs were determined by using Cuffdiff with a false discovery rate (FDR) < 0.05 between groups with or without pioglitazone treatment.
T2DM T2DMT2DM T2DM
A list of data frames with five columns each
A list of data frame with five columns individually:
Entrez gene IDs
HGNC symbols
Gene function
log2 Fold Change
False Discovery Rate
T2DMT2DM
Creates a custom UpSet plot showing the intersections between sets. It displays the size of each intersection and the sets involved in each intersection.
upset_plot( data_list, sets = NULL, min_intersection_size = 1, max_sets_display = NULL, sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_by = "freq", sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", main_bar_color = "steelblue", sets_bar_colors = NULL, highlight_intersections = NULL, highlight_color = "darkorange", point_outline_color = "black", filled_point_size = 2, empty_point_size = 1.5, line_size = 0.5, bar_width = 0.6, point_stroke = 0.3, text_angle = 0, text_size = 10, set_text_size = 10, set_label_size = 3, intersection_label_size = 3, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, show_numbers_on_bars = TRUE, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), plot_margin = 0.5, height_ratio = 0.5, width_ratio = 0.3, bar_offset = -0.01, theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), return_data = FALSE )upset_plot( data_list, sets = NULL, min_intersection_size = 1, max_sets_display = NULL, sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_by = "freq", sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", main_bar_color = "steelblue", sets_bar_colors = NULL, highlight_intersections = NULL, highlight_color = "darkorange", point_outline_color = "black", filled_point_size = 2, empty_point_size = 1.5, line_size = 0.5, bar_width = 0.6, point_stroke = 0.3, text_angle = 0, text_size = 10, set_text_size = 10, set_label_size = 3, intersection_label_size = 3, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, show_numbers_on_bars = TRUE, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), plot_margin = 0.5, height_ratio = 0.5, width_ratio = 0.3, bar_offset = -0.01, theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), return_data = FALSE )
data_list |
A named list of vectors, each containing elements in a set |
sets |
Optional vector of set names to include (default: all sets in data_list) |
min_intersection_size |
Minimum intersection size to include (default: 1) |
max_sets_display |
Maximum number of sets to display (default: all) |
sort_sets_by |
How to sort the sets: "size", "name", or "custom" (default: "size") |
sort_sets_decreasing |
Whether to sort sets in decreasing order (default: TRUE) |
custom_sets_order |
Custom order for sets if sort_sets_by="custom" |
sort_intersections_by |
How to sort intersections: "freq", "degree", or "custom" (default: "freq") |
sort_intersections_decreasing |
Whether to sort intersections in decreasing order (default: TRUE) |
custom_intersections_order |
Custom order for intersections if sort_intersections_by="custom" |
intersection_color |
Color for intersection dots and lines (default: "black") |
main_bar_color |
Color for the intersection size bars (default: "steelblue") |
sets_bar_colors |
Named vector of colors for each set (default: auto-generated) |
highlight_intersections |
Vector of intersection IDs to highlight (default: NULL) |
highlight_color |
Color for highlighted intersections (default: "#FF5500") |
point_outline_color |
Color for the outline of points (default: "black") |
filled_point_size |
Size of filled points in the matrix (default: 2) |
empty_point_size |
Size of empty points in the matrix (default: 1.5) |
line_size |
Width of connecting lines (default: 0.5) |
bar_width |
Width of bars (0-1 scale) (default: 0.7) |
point_stroke |
Width of point outline (default: 0.3) |
text_angle |
Angle for text labels (default: 0) |
text_size |
Size of text in the plot (default: 10) |
set_text_size |
Size of set labels (default: 10) |
set_label_size |
Size of set size labels (default: 3) |
intersection_label_size |
Size of intersection size labels (default: 3) |
intersection_title |
Title for the intersection size plot (default: "Intersection Size") |
set_size_title |
Title for the set size plot (default: "Set Size") |
matrix_point_shape |
Shape of the dots in the matrix (21=filled circle) (default: 21) |
set_size_show_values |
Whether to show set size values (default: TRUE) |
intersection_size_show_values |
Whether to show intersection size values (default: TRUE) |
show_empty_intersections |
Whether to show empty intersections (default: FALSE) |
show_set_labels |
Whether to show set labels (default: TRUE) |
show_numbers_on_bars |
Logical, whether to display counts on bars (default: TRUE) |
number_color_threshold |
Fraction of max value where number color switches (default: 0.75) |
number_colors |
Named vector with colors for labels on/off bars (default: c(on_bar="white", off_bar="black")) |
plot_margin |
Margin around the plots in cm (default: 0.5) |
height_ratio |
Ratio of matrix to total height (default: 0.7) |
width_ratio |
Ratio of set size to total width (default: 0.3) |
bar_offset |
Horizontal offset for top bars to improve alignment (default: 0) |
theme_params |
List of theme parameters for customization (default: list of defaults) |
return_data |
Whether to return the data along with the plot (default: FALSE) |
If return_data=FALSE, returns the patchwork plot object. If return_data=TRUE, returns a list containing the plot and component data.
Kai Guo
# Basic example sets <- list( "Set A" = c(1:100), "Set B" = c(30:120), "Set C" = c(20:50, 90:110), "Set D" = c(10:40, 80:120) ) upset_plot(sets) # With highlighting upset_plot(sets, highlight_intersections = c(1, 2), highlight_color = "darkorange", bar_offset = -0.02) # Custom colors set_colors <- c("Set A" = "blue", "Set B" = "green", "Set C" = "orange", "Set D" = "purple") upset_plot(sets, sets_bar_colors = set_colors, main_bar_color = "darkblue")# Basic example sets <- list( "Set A" = c(1:100), "Set B" = c(30:120), "Set C" = c(20:50, 90:110), "Set D" = c(10:40, 80:120) ) upset_plot(sets) # With highlighting upset_plot(sets, highlight_intersections = c(1, 2), highlight_color = "darkorange", bar_offset = -0.02) # Custom colors set_colors <- c("Set A" = "blue", "Set B" = "green", "Set C" = "orange", "Set D" = "purple") upset_plot(sets, sets_bar_colors = set_colors, main_bar_color = "darkblue")
Creates an UpSet plot to visualize set intersections
upsetPlot( object, nintersects = 40, min_size = 1, sets_bar_color = NULL, main_bar_color = "steelblue", point_size = 3, line_size = 1, show_numbers = TRUE, sort_intersections_by = "freq", sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", highlight_intersections = NULL, highlight_color = "darkorange", empty_point_size = 1.5, bar_width = 0.7, text_angle = 0, text_size = 10, set_label_size = 3, intersection_label_size = 3, point_outline_color = "black", point_stroke = 0.3, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, plot_margin = 0.5, height_ratio = 0.7, width_ratio = 0.3, bar_offset = -0.01, set_text_size = 10, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), title = NULL, interactive = FALSE, return_data = FALSE, ... )upsetPlot( object, nintersects = 40, min_size = 1, sets_bar_color = NULL, main_bar_color = "steelblue", point_size = 3, line_size = 1, show_numbers = TRUE, sort_intersections_by = "freq", sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", highlight_intersections = NULL, highlight_color = "darkorange", empty_point_size = 1.5, bar_width = 0.7, text_angle = 0, text_size = 10, set_label_size = 3, intersection_label_size = 3, point_outline_color = "black", point_stroke = 0.3, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, plot_margin = 0.5, height_ratio = 0.7, width_ratio = 0.3, bar_offset = -0.01, set_text_size = 10, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), title = NULL, interactive = FALSE, return_data = FALSE, ... )
object |
A Venn object |
nintersects |
Maximum number of intersections to show |
min_size |
Minimum intersection size to include (default: 1) |
sets_bar_color |
Colors for the set size bars |
main_bar_color |
Color for the intersection size bars |
point_size |
Size of points in the matrix |
line_size |
Width of lines in the matrix |
show_numbers |
Logical: show counts on bars? |
sort_intersections_by |
How to sort intersections |
sort_sets_by |
How to sort sets |
sort_sets_decreasing |
Whether to sort sets in decreasing order |
custom_sets_order |
Custom order for sets if sort_sets_by="custom" |
sort_intersections_decreasing |
Whether to sort intersections in decreasing order |
custom_intersections_order |
Custom order for intersections |
intersection_color |
Color for intersection dots and lines |
highlight_intersections |
Vector of intersection IDs to highlight |
highlight_color |
Color for highlighted intersections |
empty_point_size |
Size of empty points in the matrix |
bar_width |
Width of bars |
text_angle |
Angle for text labels |
text_size |
Size of text in the plot |
set_label_size |
Size of set size labels |
intersection_label_size |
Size of intersection size labels |
point_outline_color |
Color for the outline of points |
point_stroke |
Width of point outline |
set_size_show_values |
Whether to show set size values |
intersection_size_show_values |
Whether to show intersection size values |
show_empty_intersections |
Whether to show empty intersections |
show_set_labels |
Whether to show set labels |
plot_margin |
Margin around the plots in cm |
height_ratio |
Ratio of matrix to total height |
width_ratio |
Ratio of set size to total width |
bar_offset |
Horizontal offset for top bars |
set_text_size |
Size of set labels |
intersection_title |
Title for the intersection size plot |
set_size_title |
Title for the set size plot |
matrix_point_shape |
Shape of the dots in the matrix |
number_color_threshold |
Fraction of max value for label color switch |
number_colors |
Colors for labels on/off bars |
theme_params |
Theme parameters for customization |
title |
Optional plot title |
interactive |
Create interactive plot? |
return_data |
Whether to return the data along with the plot |
... |
Additional arguments passed to internal functions |
A ggplot object or a combined grid layout
Kai Guo
# Basic example sets <- list( "Set A" = c(1:100), "Set B" = c(30:120), "Set C" = c(20:50, 90:110), "Set D" = c(10:40, 80:120) ) ven <- venndetail(sets) upsetPlot(ven, bar_offset = -0.02) # With highlighting upsetPlot(ven, highlight_intersections = c(1, 2), highlight_color = "darkorange", bar_offset = -0.02)# Basic example sets <- list( "Set A" = c(1:100), "Set B" = c(30:120), "Set C" = c(20:50, 90:110), "Set D" = c(10:40, 80:120) ) ven <- venndetail(sets) upsetPlot(ven, bar_offset = -0.02) # With highlighting upsetPlot(ven, highlight_intersections = c(1, 2), highlight_color = "darkorange", bar_offset = -0.02)
Creates an UpSet plot to visualize set intersections
## S4 method for signature 'Venn' upsetPlot( object, nintersects = 40, min_size = 1, sets_bar_color = NULL, main_bar_color = "steelblue", point_size = 3, line_size = 1, show_numbers = TRUE, sort_intersections_by = "freq", sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", highlight_intersections = NULL, highlight_color = "darkorange", empty_point_size = 1.5, bar_width = 0.7, text_angle = 0, text_size = 10, set_label_size = 3, intersection_label_size = 3, point_outline_color = "black", point_stroke = 0.3, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, plot_margin = 0.5, height_ratio = 0.7, width_ratio = 0.3, bar_offset = -0.01, set_text_size = 10, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), title = NULL, interactive = FALSE, return_data = FALSE )## S4 method for signature 'Venn' upsetPlot( object, nintersects = 40, min_size = 1, sets_bar_color = NULL, main_bar_color = "steelblue", point_size = 3, line_size = 1, show_numbers = TRUE, sort_intersections_by = "freq", sort_sets_by = "size", sort_sets_decreasing = TRUE, custom_sets_order = NULL, sort_intersections_decreasing = TRUE, custom_intersections_order = NULL, intersection_color = "black", highlight_intersections = NULL, highlight_color = "darkorange", empty_point_size = 1.5, bar_width = 0.7, text_angle = 0, text_size = 10, set_label_size = 3, intersection_label_size = 3, point_outline_color = "black", point_stroke = 0.3, set_size_show_values = TRUE, intersection_size_show_values = TRUE, show_empty_intersections = FALSE, show_set_labels = TRUE, plot_margin = 0.5, height_ratio = 0.7, width_ratio = 0.3, bar_offset = -0.01, set_text_size = 10, intersection_title = "Intersection Size", set_size_title = "Set Size", matrix_point_shape = 21, number_color_threshold = 0.75, number_colors = c(on_bar = "black", off_bar = "black"), theme_params = list(background_color = "white", grid_color = "grey92", axis_text_color = "black", use_grid = TRUE, border_color = NA), title = NULL, interactive = FALSE, return_data = FALSE )
object |
A Venn object |
nintersects |
Maximum number of intersections to show (default: 40) |
min_size |
Minimum intersection size to include (default: 1) |
sets_bar_color |
Colors for the set size bars (default: NULL for auto-generate) |
main_bar_color |
Color for the intersection size bars (default: "steelblue") |
point_size |
Size of points in the matrix (default: 3) |
line_size |
Width of lines in the matrix (default: 1) |
show_numbers |
Logical: show counts on bars? (default: TRUE) |
sort_intersections_by |
How to sort intersections: "freq" (default), "degree" |
sort_sets_by |
How to sort sets: "size" (default), "name" |
sort_sets_decreasing |
Whether to sort sets in decreasing order (default: TRUE) |
custom_sets_order |
Custom order for sets if sort_sets_by="custom" |
sort_intersections_decreasing |
Whether to sort intersections in decreasing order (default: TRUE) |
custom_intersections_order |
Custom order for intersections if sort_intersections_by="custom" |
intersection_color |
Color for intersection dots and lines (default: "black") |
highlight_intersections |
Vector of intersection IDs to highlight (default: NULL) |
highlight_color |
Color for highlighted intersections (default: "darkorange") |
empty_point_size |
Size of empty points in the matrix (default: 1.5) |
bar_width |
Width of bars (0-1 scale) (default: 0.7) |
text_angle |
Angle for text labels (default: 0) |
text_size |
Size of text in the plot (default: 10) |
set_label_size |
Size of set size labels (default: 3) |
intersection_label_size |
Size of intersection size labels (default: 3) |
point_outline_color |
Color for the outline of points (default: "black") |
point_stroke |
Width of point outline (default: 0.3) |
set_size_show_values |
Whether to show set size values (default: TRUE) |
intersection_size_show_values |
Whether to show intersection size values (default: TRUE) |
show_empty_intersections |
Whether to show empty intersections (default: FALSE) |
show_set_labels |
Whether to show set labels (default: TRUE) |
plot_margin |
Margin around the plots in cm (default: 0.5) |
height_ratio |
Ratio of matrix to total height (default: 0.7) |
width_ratio |
Ratio of set size to total width (default: 0.3) |
bar_offset |
Horizontal offset for top bars to improve alignment (default: 0) |
set_text_size |
Size of set labels (default: 10) |
intersection_title |
Title for the intersection size plot (default: "Intersection Size") |
set_size_title |
Title for the set size plot (default: "Set Size") |
matrix_point_shape |
Shape of the dots in the matrix (21=filled circle) (default: 21) |
number_color_threshold |
Fraction of max value where number color switches (default: 0.75) |
number_colors |
Named vector with colors for labels on/off bars (default: c(on_bar="white", off_bar="black")) |
theme_params |
List of theme parameters for customization (default: list of defaults) |
title |
Optional plot title |
interactive |
Logical: create interactive plot? (default: FALSE) |
return_data |
Whether to return the data along with the plot (default: FALSE) |
A ggplot object or a combined grid layout
Kai Guo
# Basic example sets <- list( "Set A" = c(1:100), "Set B" = c(30:120), "Set C" = c(20:50, 90:110), "Set D" = c(10:40, 80:120) ) ven <- venndetail(sets) upsetPlot(ven, bar_offset = -0.02) # With highlighting upsetPlot(ven, highlight_intersections = c(1, 2), highlight_color = "darkorange", bar_offset = -0.02)# Basic example sets <- list( "Set A" = c(1:100), "Set B" = c(30:120), "Set C" = c(20:50, 90:110), "Set D" = c(10:40, 80:120) ) ven <- venndetail(sets) upsetPlot(ven, bar_offset = -0.02) # With highlighting upsetPlot(ven, highlight_intersections = c(1, 2), highlight_color = "darkorange", bar_offset = -0.02)
S4 class to store and manage set intersection data and visualizations
inputA list containing the original input datasets
rawA named vector with counts of elements in each input set
sepThe character used to separate set names in subset labels
GroupNamesA character vector of input group names
resultA data.frame containing subset information (subset name and elements)
detailA named vector with counts of elements in each subset
wideA data.frame with subset information in wide format for easier analysis
metadataA list to store additional metadata about the analysis
Kai Guo
## Not run: A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) venn_obj <- venndetail(list(A = A, B = B, C = C)) # Access the detail slot venn_obj@detail ## End(Not run)## Not run: A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) venn_obj <- venndetail(list(A = A, B = B, C = C)) # Access the detail slot venn_obj@detail ## End(Not run)
Creates a Shiny app for interactive exploration of Venn diagrams
vennApp(object, launch = TRUE, ...)vennApp(object, launch = TRUE, ...)
object |
A Venn object |
launch |
Launch the app immediately? Default: TRUE |
... |
Additional arguments passed to shiny::runApp |
A Shiny app object (invisibly)
Kai Guo
## Not run: # Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Launch interactive app vennApp(res) ## End(Not run)## Not run: # Create a Venn object A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Launch interactive app vennApp(res) ## End(Not run)
Extracts shared and unique elements from multiple sets and creates a Venn object for analysis and visualization
venndetail( x, sep = "_", abbr = FALSE, minlength = 3, abbr.method = "both.sides", verbose = FALSE )venndetail( x, sep = "_", abbr = FALSE, minlength = 3, abbr.method = "both.sides", verbose = FALSE )
x |
A list of vectors with group names |
sep |
Symbol character used when concatenating group names into subset names (default: '_') |
abbr |
Logical: abbreviate subset names? Default: FALSE |
minlength |
Minimal length for abbreviated subset names. Default: 3 |
abbr.method |
Method for abbreviation: "both.sides", "left.sides", or "right.sides" |
verbose |
Logical: show progress messages? Default: FALSE |
A Venn object
Kai Guo
# Create a Venn object with three sets A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Examine the results summary(res) # Plot the results plot(res, type = "venn") # With abbreviated set names sets <- list( LongNameGroup1 = sample(1:100, 40), LongNameGroup2 = sample(1:100, 50), LongNameGroup3 = sample(1:100, 45) ) res <- venndetail(sets, abbr = TRUE, minlength = 4)# Create a Venn object with three sets A <- sample(1:100, 40, replace = FALSE) B <- sample(1:100, 60, replace = FALSE) C <- sample(1:100, 40, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Examine the results summary(res) # Plot the results plot(res, type = "venn") # With abbreviated set names sets <- list( LongNameGroup1 = sample(1:100, 40), LongNameGroup2 = sample(1:100, 50), LongNameGroup3 = sample(1:100, 45) ) res <- venndetail(sets, abbr = TRUE, minlength = 4)
Creates a traditional Venn diagram for 2-5 sets
vennDiagram( object, fill = NULL, alpha = 0.5, labels = TRUE, counts = TRUE, showNumbers = TRUE, numberSize = 4, numberColor = "black", labelSize = 4, labelColor = "black", borderCol = FALSE, fillCol = TRUE, fixedCoords = TRUE, xlim = c(0, 1), ylim = c(0, 1), show_percentages = TRUE, show_unique_only = FALSE, scaled = FALSE, title = NULL, interactive = FALSE, ... )vennDiagram( object, fill = NULL, alpha = 0.5, labels = TRUE, counts = TRUE, showNumbers = TRUE, numberSize = 4, numberColor = "black", labelSize = 4, labelColor = "black", borderCol = FALSE, fillCol = TRUE, fixedCoords = TRUE, xlim = c(0, 1), ylim = c(0, 1), show_percentages = TRUE, show_unique_only = FALSE, scaled = FALSE, title = NULL, interactive = FALSE, ... )
object |
A Venn object |
fill |
Colors for filling the circles |
alpha |
Transparency level for the circles (0-1) |
labels |
Logical: show set labels? (default: TRUE) |
counts |
Logical: show counts? (default: TRUE) |
showNumbers |
Logical: whether to show counts and percentages in each region |
numberSize |
Size of the count labels |
numberColor |
Color of the count labels |
labelSize |
Size of the set labels |
labelColor |
Color of the set labels |
borderCol |
Logical: whether to color the borders of circles |
fillCol |
Logical: whether to fill circles with colors |
fixedCoords |
Logical: whether to use fixed coordinates |
xlim |
Vector with 2 numbers, x axis limits for the venn diagram |
ylim |
Vector with 2 numbers, y axis limits for the venn diagram |
show_percentages |
Logical: show percentages alongside counts? (default: TRUE) |
show_unique_only |
Logical: show counts only for unique elements? (default: FALSE) |
scaled |
Logical: scale circles by set size? (default: FALSE) |
title |
Optional plot title |
interactive |
Logical: create interactive plot? (default: FALSE) |
... |
Additional arguments passed to ggplot2 functions |
A ggplot2 or plotly object
Kai Guo
Creates a traditional Venn diagram for 2-5 sets
## S4 method for signature 'Venn' vennDiagram( object, fill = NULL, alpha = 0.5, labels = TRUE, counts = TRUE, showNumbers = TRUE, numberSize = 4, numberColor = "black", labelSize = 4, labelColor = "black", borderCol = FALSE, fillCol = TRUE, fixedCoords = TRUE, xlim = c(0, 1), ylim = c(0, 1), show_percentages = TRUE, show_unique_only = FALSE, scaled = FALSE, title = NULL, interactive = FALSE, ... )## S4 method for signature 'Venn' vennDiagram( object, fill = NULL, alpha = 0.5, labels = TRUE, counts = TRUE, showNumbers = TRUE, numberSize = 4, numberColor = "black", labelSize = 4, labelColor = "black", borderCol = FALSE, fillCol = TRUE, fixedCoords = TRUE, xlim = c(0, 1), ylim = c(0, 1), show_percentages = TRUE, show_unique_only = FALSE, scaled = FALSE, title = NULL, interactive = FALSE, ... )
object |
A Venn object |
fill |
Colors for filling the circles |
alpha |
Transparency level for the circles (0-1) |
labels |
Logical: show set labels? (default: TRUE) |
counts |
Logical: show counts? (default: TRUE) |
showNumbers |
Logical: whether to show counts and percentages in each region |
numberSize |
Size of the count labels |
numberColor |
Color of the count labels |
labelSize |
Size of the set labels |
labelColor |
Color of the set labels |
borderCol |
Logical: whether to color the borders of circles |
fillCol |
Logical: whether to fill circles with colors |
fixedCoords |
Logical: whether to use fixed coordinates |
xlim |
Vector with 2 numbers, x axis limits for the venn diagram |
ylim |
Vector with 2 numbers, y axis limits for the venn diagram |
show_percentages |
Logical: show percentages alongside counts? (default: TRUE) |
show_unique_only |
Logical: show counts only for unique elements? (default: FALSE) |
scaled |
Logical: scale circles by set size? (default: FALSE) |
title |
Optional plot title |
interactive |
Logical: create interactive plot? (default: FALSE) |
... |
Additional arguments passed to ggplot2 functions |
A ggplot2 or plotly object
Kai Guo
Performs enrichment analysis to identify overrepresented categories in set intersections
vennEnrichment( object, annotation, id_col, category_col, subsets = NULL, min_overlap = 3, adjust.method = "BH", sig_threshold = 0.05 )vennEnrichment( object, annotation, id_col, category_col, subsets = NULL, min_overlap = 3, adjust.method = "BH", sig_threshold = 0.05 )
object |
A Venn object |
annotation |
A data frame with annotation data (e.g., Gene Ontology terms) |
id_col |
Column in the annotation data frame containing identifiers matching elements in the Venn object |
category_col |
Column in the annotation data frame containing category information |
subsets |
Character vector of subset names to analyze (default: NULL, all subsets) |
min_overlap |
Minimum number of elements a category must share with a subset (default: 3) |
adjust.method |
Method for multiple testing correction (default: "BH") |
sig_threshold |
Significance threshold for p-values (default: 0.05) |
A data.frame with enrichment analysis results
Kai Guo
# Create a Venn object with gene sets A <- sample(1:1000, 100, replace = FALSE) B <- sample(1:1000, 150, replace = FALSE) C <- sample(1:1000, 120, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Create simulated annotation data gene_ids <- 1:1000 categories <- sample(c("Category1", "Category2", "Category3", "Category4"), 1000, replace = TRUE) anno <- data.frame(GeneID = gene_ids, Category = categories) # Perform enrichment analysis enrichment <- vennEnrichment(res, anno, "GeneID", "Category")# Create a Venn object with gene sets A <- sample(1:1000, 100, replace = FALSE) B <- sample(1:1000, 150, replace = FALSE) C <- sample(1:1000, 120, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Create simulated annotation data gene_ids <- 1:1000 categories <- sample(c("Category1", "Category2", "Category3", "Category4"), 1000, replace = TRUE) anno <- data.frame(GeneID = gene_ids, Category = categories) # Perform enrichment analysis enrichment <- vennEnrichment(res, anno, "GeneID", "Category")
Creates a pie-chart-like visualization of set intersections
vennpie( object, subset = NULL, top = 31, min = 0, color = NULL, revcolor = "lightgrey", any = NULL, show.number = TRUE, show.x = TRUE, sep = "_", log = FALSE, base = NULL, percentage = FALSE, title = NULL, interactive = FALSE, ... )vennpie( object, subset = NULL, top = 31, min = 0, color = NULL, revcolor = "lightgrey", any = NULL, show.number = TRUE, show.x = TRUE, sep = "_", log = FALSE, base = NULL, percentage = FALSE, title = NULL, interactive = FALSE, ... )
object |
A Venn object |
subset |
Character vector of subset names to highlight |
top |
Maximum number of subsets to display |
min |
Minimum number of sets an element must be in |
color |
Optional vector of colors for the subsets |
revcolor |
Color for non-highlighted subsets |
any |
Highlight subsets shared by exactly this many sets |
show.number |
Logical: show counts in labels? |
show.x |
Logical: show subset labels? |
sep |
Character separator for subset names |
log |
Logical: use log scale for counts? |
base |
Base for log transformation if log=TRUE |
percentage |
Logical: show percentages instead of counts? |
title |
Optional plot title |
interactive |
Logical: create interactive plot? |
... |
Additional arguments |
A ggplot2 or plotly object
Kai Guo
Creates a pie-chart-like visualization of set intersections, which is particularly useful for visualizing more than 5 sets
## S4 method for signature 'Venn' vennpie( object, subset = NULL, top = 31, min = 0, color = NULL, revcolor = "lightgrey", any = NULL, show.number = TRUE, show.x = TRUE, sep = "_", log = FALSE, base = NULL, percentage = FALSE, title = NULL, interactive = FALSE, ... )## S4 method for signature 'Venn' vennpie( object, subset = NULL, top = 31, min = 0, color = NULL, revcolor = "lightgrey", any = NULL, show.number = TRUE, show.x = TRUE, sep = "_", log = FALSE, base = NULL, percentage = FALSE, title = NULL, interactive = FALSE, ... )
object |
A Venn object |
subset |
Character vector of subset names to highlight |
top |
Maximum number of subsets to display. Default: 31 |
min |
Minimum number of sets an element must be in. Default: 0 |
color |
Optional vector of colors for the subsets |
revcolor |
Color for non-highlighted subsets. Default: "lightgrey" |
any |
Highlight subsets shared by exactly this many sets |
show.number |
Logical: show counts in labels? Default: TRUE |
show.x |
Logical: show subset labels? Default: TRUE |
sep |
Character separator for subset names |
log |
Logical: use log scale for counts? Default: FALSE |
base |
Base for log transformation if log=TRUE |
percentage |
Logical: show percentages instead of counts? Default: FALSE |
title |
Optional plot title |
interactive |
Logical: create interactive plot? Default: FALSE |
... |
Additional arguments |
A ggplot2 or plotly object
Kai Guo
Performs statistical tests to evaluate the significance of set intersections
vennStats( object, universe = NULL, method = c("hypergeometric", "permutation"), nperm = 1000, adjust.method = "BH", include_singles = FALSE )vennStats( object, universe = NULL, method = c("hypergeometric", "permutation"), nperm = 1000, adjust.method = "BH", include_singles = FALSE )
object |
A Venn object |
universe |
Size of the universe for hypergeometric test. Default: NULL (will use the union of all sets) |
method |
Statistical method to use: "hypergeometric" or "permutation". Default: "hypergeometric" |
nperm |
Number of permutations if method="permutation". Default: 1000 |
adjust.method |
Method for multiple testing correction. Default: "BH" |
include_singles |
Logical: include tests for single sets? Default: FALSE |
A data.frame with statistical test results
Kai Guo
A <- sample(1:1000, 100, replace = FALSE) B <- sample(1:1000, 150, replace = FALSE) C <- sample(1:1000, 120, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) stats <- vennStats(res)A <- sample(1:1000, 100, replace = FALSE) B <- sample(1:1000, 150, replace = FALSE) C <- sample(1:1000, 120, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) stats <- vennStats(res)
Performs statistical tests to evaluate the significance of set intersections
## S4 method for signature 'Venn' vennStats( object, universe = NULL, method = c("hypergeometric", "permutation"), nperm = 1000, adjust.method = "BH", include_singles = FALSE )## S4 method for signature 'Venn' vennStats( object, universe = NULL, method = c("hypergeometric", "permutation"), nperm = 1000, adjust.method = "BH", include_singles = FALSE )
object |
A Venn object |
universe |
Size of the universe for hypergeometric test (default: NULL, will use the union of all sets) |
method |
Statistical method to use: "hypergeometric" or "permutation" (default: "hypergeometric") |
nperm |
Number of permutations if method="permutation" (default: 1000) |
adjust.method |
Method for multiple testing correction (default: "BH") |
include_singles |
Logical: include tests for single sets? (default: FALSE) |
A data.frame with statistical test results
Kai Guo
# Create a Venn object A <- sample(1:1000, 100, replace = FALSE) B <- sample(1:1000, 150, replace = FALSE) C <- sample(1:1000, 120, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Perform statistical tests stats <- vennStats(res) # With custom universe size stats <- vennStats(res, universe = 2000) # Using permutation test stats <- vennStats(res, method = "permutation", nperm = 500)# Create a Venn object A <- sample(1:1000, 100, replace = FALSE) B <- sample(1:1000, 150, replace = FALSE) C <- sample(1:1000, 120, replace = FALSE) res <- venndetail(list(A = A, B = B, C = C)) # Perform statistical tests stats <- vennStats(res) # With custom universe size stats <- vennStats(res, universe = 2000) # Using permutation test stats <- vennStats(res, method = "permutation", nperm = 500)