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,4), "agreement")
#> set_A =: 159,926 set_A&set_D =: 29,053 set_D =: 159,926
#> 159,926 40,074 X: 11,021 159,926
# basic text Venn with directionality
textvenn(setlist, sets=c(3,4), "each")
#> 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
# 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&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