Text Venn diagram
Usage
textvenn(
setlist,
sets = seq_along(setlist),
overlap_type = c("detect", "concordance", "overlap", "each", "agreement"),
template = c("wide", "tall"),
draw_legend = FALSE,
set_colors = NULL,
spacing = 5,
padding = 1,
inverse_title = TRUE,
inverse_counts = FALSE,
color_by_counts = TRUE,
return_items = TRUE,
unicode = TRUE,
big.mark = ",",
sep = "&",
blend_preset = "ryb",
curate_df = NULL,
lightMode = jamba::checkLightMode(),
debug = NULL,
verbose = FALSE,
...
)Arguments
- setlist
listof item vectors;listof vectors named by item; incidencematrixwith valuesc(0, 1)orc(FALSE, TRUE), orc(-1, 0, 1).- sets
integervectoras index tosetlist, used to pull out a subset of the list elements. This subset is useful because the set colors are defined for the fullsetlist, which allows the subset of colors to be consistent for each set.- overlap_type
characterpassed tosigned_overlaps(), default 'detect' will show 'concordance' when provided signed list, otherwise it shows 'overlap' with only the counts.- template
characterstring, default 'wide' indicatiing the placement of signed counts.'wide' - places signed counts beside total overlap counts
'tall' - places signed counts below total overlap counts
- draw_legend
logicaldefault FALSE, whether to print a text legend table below the text venn output.- set_colors
NULLorcharactervectorthat contains R-compatible colors. Whenset_colorsisNULL, categorical colors are defined usingcolorjam::rainbowJam(). Whenset_colorsis defined, the values are recycled to the total number of sets represented bysetlist.- spacing, padding
integervalues indicating the character spacing and padding around labels printed to the console output.- inverse_title, inverse_counts
logicalindicating whether to inverse the color, wheninverse_title=TRUEthen each Venn set is printed on colored background, wheninverse_title=FALSE, each set is printed with colored text with no background color.- return_items
logicaldefault TRUE, whether to return items in thedata.framein column"items". This argument is passed tosigned_overlaps().- unicode
logicalpassed tocurate_venn_labels()indicating whether the directional label can include special Unicode characters.- big.mark
characterpassed toformat()for numeric labels.- blend_preset
characterstring passed aspresettocolorjam::blend_colors()to define the color wheel used during color blending operations.- curate_df
data.frameorNULLpassed tocurate_venn_labels().- lightMode
logicaldefaultjamba::checkLightMode()checks whether the console has a light background, and therefore needs to have darker text. This check is incomplete, it assumes RStudio has a light background, and everything else is dark. To override consistently, set the option below, or add to.Rprofile:options("jam.lightMode"=TRUE)will force lightMode=TRUE, for light background and darker text.options("jam.lightMode"=FALSE)will force lightMode=FALSE, for dark background and lighter text.
- verbose
logicalindicating whether to print verbose output.
Value
data.frame returned using invisible(), from the
output of signed_overlaps().
Details
This function is a very simple method to print a Venn diagram using text, intended to be displayed using mono-spaced font on an R console.
See also
Other venndir core:
render_venndir(),
venn_meme(),
venndir()
Examples
# for this purpose, set lightMode=TRUE to ensure darker text
withr::with_options(list(jam.lightMode=TRUE), {
# generate test data
setlist <- make_venn_test(n_items=100, do_signed=TRUE)
# two-way Venn by default shows concordance
textvenn(setlist, sets=c(1,2))
# without signed directionality use overlap_type="overlap"
textvenn(setlist, sets=c(1,2), overlap_type="overlap")
# three-way Venn showing each signed directionality
textvenn(setlist, sets=c(1,2,3), overlap_type="each")
# larger number of items
setlist <- make_venn_test(n_items=1000000, n_sets=4, sizes=200000, do_signed=TRUE)
# text Venn with directionality
textvenn(setlist, sets=c(1,4), "agreement")
# basic text Venn with directionality
textvenn(setlist, sets=c(3,4), "each")
# simple way to show legend
venndir_legender(textvenn(setlist, sets=c(1,2,4), overlap_type="overlap"),
combine_size=FALSE,
legend_style="data.frame")
})
#> set_A ↑: 12 set_A&set_B X: 2 set_B ↑: 4
#> 23 ↓: 11 9 ↑↑: 4 7 ↓: 3
#> ↓↓: 3
#> set_A set_A&set_B set_B
#> 23 9 7
#> set_A&set_B ↑↑: 3
#> 8 ↑↓: 2
#> set_A ↑: 9 ↓↓: 3 set_B ↑: 4
#> 16 ↓: 7 7 ↓: 3
#>
#> set_A&set_B&set_C ↑↑↑: 1
#> 1
#> set_A&set_C ↑↑: 2 set_B&set_C ↑↑: 0
#> 7 ↑↓: 1 0
#> ↓↑: 1
#> ↓↓: 3
#> set_C ↑: 5
#> 7 ↓: 2
#> set_A set_A&set_D =: 29,053 set_D
#> 159,926 40,074 X: 11,021 159,926
#> set_C ↑: 80,141 set_C&set_D ↑↑: 10,548 set_D ↑: 79,574
#> 159,700 ↓: 79,559 40,300 ↑↓: 9,375 159,700 ↓: 80,126
#> ↓↑: 9,667
#> ↓↓: 10,710
#> set_A&set_B
#> 31,963
#> set_A set_B
#> 127,963 127,938
#>
#> set_A&set_B&set_D
#> 8,079
#> set_A&set_D set_B&set_D
#> 31,995 32,020
#>
#>
#> set_D
#> 127,906
#> Set Size
#> 1 set_A 200,000
#> 2 set_B 200,000
#> 3 set_D 200,000
#> 4 Total 487,864