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:
make_venn_test()
,
plot,Venndir,ANY-method
,
render_venndir()
,
signed_overlaps()
,
venn_meme()
,
venndir()
,
venndir_legender()
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 ↑: 12 set_A&set_B X: 2 set_B ↑: 4
#> 23 ↓: 11 9 ↑↑: 4 7 ↓: 3
#> ↓↓: 3
# without signed directionality use overlap_type="overlap"
textvenn(setlist, sets=c(1,2), overlap_type="overlap")
#> set_A set_A&set_B set_B
#> 23 9 7
# three-way Venn showing each signed directionality
textvenn(setlist, sets=c(1,2,3), overlap_type="each")
#> 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
# 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 set_A&NA NA
#> 2e+05 0e+00 0e+00
# basic text Venn with directionality
textvenn(setlist, sets=c(3,4), "each")
#> set_C ↑: 99,955 set_C&NA ↑↑: 0 NA ↑: 0
#> 2e+05 ↓: 100,045 0e+00 0e+00
# 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
#> 40,042
#> set_A set_B
#> 159,958 159,958
#>
#> set_A&set_B&NA
#> 0
#> set_A&NA set_B&NA
#> 0 0
#>
#>
#> NA
#> 0
#> Set Size
#> 1 NA 0
#> 2 set_A 200,000
#> 3 set_B 200,000
#> 4 Total 359,958