Text Venn diagram
Usage
textvenn(
setlist,
sets = seq_along(setlist),
overlap_type = c("concordance", "overlap", "each", "agreement"),
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
list
of item vectors;list
of vectors named by item; incidencematrix
with valuesc(0, 1)
orc(FALSE, TRUE)
, orc(-1, 0, 1)
.- sets
integer
vector
as 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.- set_colors
NULL
orcharacter
vector
that contains R-compatible colors. Whenset_colors
isNULL
, categorical colors are defined usingcolorjam::rainbowJam()
. Whenset_colors
is defined, the values are recycled to the total number of sets represented bysetlist
.- spacing, padding
integer
values indicating the character spacing and padding around labels printed to the console output.- inverse_title, inverse_counts
logical
indicating whether to inverse the color, wheninverse_title=TRUE
then each Venn set is printed on colored background, wheninverse_title=FALSE
, each set is printed with colored text with no background color.- return_items
logical
default TRUE, whether to return items in thedata.frame
in column"items"
. This argument is passed tosigned_overlaps()
.- unicode
logical
passed tocurate_venn_labels()
indicating whether the directional label can include special Unicode characters.- big.mark
character
passed toformat()
for numeric labels.- blend_preset
character
string passed aspreset
tocolorjam::blend_colors()
to define the color wheel used during color blending operations.- curate_df
data.frame
orNULL
passed tocurate_venn_labels()
.- lightMode
logical
defaultjamba::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
logical
indicating 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()
,
signed_overlaps()
,
venn_meme()
,
venndir()
Examples
# for this purpose, set lightMode=TRUE to ensure darker text
options(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))
#> set_A ↑: 13 set_A&set_B X: 2 set_B ↑: 6
#> 26 ↓: 13 6 ↑↑: 3 10 ↓: 4
#> ↓↓: 1
# without signed directionality use overlap_type="overlap"
textvenn(setlist, sets=c(1,2), overlap_type="overlap")
#> set_A set_A&set_B set_B
#> 26 6 10
# three-way Venn showing each signed directionality
textvenn(setlist, sets=c(1,2,3), overlap_type="each")
#> set_A&set_B ↑↑: 3
#> 5 ↓↑: 1
#> set_A ↑: 9 ↓↓: 1 set_B ↑: 6
#> 18 ↓: 9 10 ↓: 4
#>
#> set_A&set_B&set_C ↓↑↑: 1
#> 1
#> set_A&set_C ↑↑: 2 set_B&set_C ↑↑: 0
#> 8 ↑↓: 2 0
#> ↓↑: 2
#> ↓↓: 2
#> set_C ↑: 1
#> 6 ↓: 5
# larger number of items
setlist <- make_venn_test(n_items=1000000, sizes=200000, do_signed=TRUE)
# text Venn with directionality
textvenn(setlist, sets=c(1,2,3), "agreement")
#> set_A&set_B X: 7,975
#> 31,988 ‖: 24,013
#> set_A ‖: 128,007 set_B ‖: 128,192
#> 128,007 128,192
#>
#> set_A&set_B&set_C X: 3,557
#> 8,054 ‖: 4,497
#> set_A&set_C X: 16,069 set_B&set_C X: 7,903
#> 31,951 ‖: 15,882 31,766 ‖: 23,863
#>
#>
#> set_C ‖: 128,229
#> 128,229
# basic text Venn with directionality
textvenn(setlist, sets=c(1,2,3), "each")
#> set_A&set_B ↑↑: 11,990
#> 31,988 ↑↓: 4,007
#> set_A ↑: 64,078 ↓↑: 3,968 set_B ↑: 63,910
#> 128,007 ↓: 63,929 ↓↓: 12,023 128,192 ↓: 64,282
#>
#> set_A&set_B&set_C ↑↑↑: 2,243 ↓↑↑: 757
#> 8,054 ↑↑↓: 766 ↓↑↓: 243
#> set_A&set_C ↑↑: 7,950 ↑↓↑: 287 ↓↓↑: 756 set_B&set_C ↑↑: 11,919
#> 31,951 ↑↓: 7,902 ↑↓↓: 748 ↓↓↓: 2,254 31,766 ↑↓: 3,918
#> ↓↑: 8,167 ↓↑: 3,985
#> ↓↓: 7,932 ↓↓: 11,944
#> set_C ↑: 64,000
#> 128,229 ↓: 64,229