knitr::opts_chunk$set(collapse = TRUE, comment = "#>") # Skip evaluation of all chunks on CRAN's auto-check farm to fit the # 10-minute build budget. Locally, on CI, and under devtools::check(), # NOT_CRAN=true and all chunks evaluate normally. The vignette source # (which CRAN users see in browseVignettes() / vignette()) is unchanged. NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true") knitr::opts_chunk$set(eval = NOT_CRAN)
vennDiagramLab separates analysis from rendering. Once you have a
RegionResult, you can render it with custom names, custom colors,
post-process the SVG, embed it in a ggplot2 chain via geom_venn(), or
export to PNG / PDF.
library(vennDiagramLab) result <- analyze(load_sample("dataset_real_cancer_drivers_4"))
Pass a per-letter mapping (A-I) to override the dataset's set names:
svg <- render_venn_svg( result, set_names = c(A = "Vogelstein\n(2013)", B = "COSMIC CGC", C = "OncoKB", D = "IntOGen"), title = "Pan-source cancer driver agreement" ) substr(svg, 1, 60)
Pass a per-letter hex map. Each letter's color is applied to the matching shape AND the legend bullet (and, where present, the Euler extra shape).
svg <- render_venn_svg( result, colors = c(A = "#E69F00", B = "#56B4E9", C = "#009E73", D = "#CC79A7") ) nchar(svg)
svg_clean <- render_venn_svg(result, show_counts = FALSE) nchar(svg_clean)
(show_names = FALSE does the analogous thing for set names.)
The returned SVG is a plain string; parse it with xml2 to make targeted
edits (e.g. set the page background or add a watermark):
svg <- render_venn_svg(result) doc <- xml2::read_xml(svg) xml2::xml_attr(doc, "viewBox")
geom_venn() returns a list of layers that draws the venn on a
unit-square coordinate system, ready to compose with titles, themes, and
other annotations.
library(ggplot2) ggplot() + geom_venn(data = result) + theme_void() + labs(title = "4 cancer-driver sources", subtitle = "Vogelstein, COSMIC CGC, OncoKB, IntOGen") + theme(plot.title = element_text(size = 14, face = "bold"), plot.subtitle = element_text(size = 10, colour = "grey40"))
render_venn_svg() returns a string. Convert it to PNG or PDF via the
rsvg package (already a hard import of vennDiagramLab):
svg <- render_venn_svg(result) png_path <- tempfile(fileext = ".png") rsvg::rsvg_png(charToRaw(svg), png_path, width = 1200) file.size(png_path) pdf_path <- tempfile(fileext = ".pdf") rsvg::rsvg_pdf(charToRaw(svg), pdf_path) file.size(pdf_path)
For a multi-page composite report (venn + upset + statistics + network + about), use to_pdf_report() — see vignette("v07_pdf_reports").
vignette("v01_quickstart") — basic usage.vignette("v04_upset_vs_venn_vs_network") — alternative visualizations.vignette("v07_pdf_reports") — composite multi-page PDF reports.Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.