Curate Venn signs and symbols
Usage
curate_venn_labels(
x,
type = c("sign", "color", "hide_singlet", "all"),
curate_df = NULL,
unicode = TRUE,
blend_preset = "ryb",
split = " ",
...
)Arguments
- x
vectorof overlap labels.- type
characterstring, default 'type'.type="sign"will curatexto signtype="color"will curatexto colortype="hide_singlet"will indicate whether to hide singlet values, intended for values such as "agreement" which are not useful to display for singlet (single group) count values.type="all"will return all the above asdata.frame.
- curate_df
data.frameorNULLwith optional curation rules. The input is coerced todata.frameif necessary. The colnames are expected to include:"from"- regular expression patterns"sign"- replacement value whentype="sign""color"- replacement R color whentype="color""hide_singlet"- logical whether to display signed counts for singlet overlap sets.
- unicode
logicaldefault TRUE, whether to use Unicode characters, passed toget_venndir_curate_df.- blend_preset
characterstring passed aspresettocolorjam::blend_colors()to define the color wheel used during color blending operations.- split
characterstring used to split each "sign" in the input stringx, assumed to be space character" ". This split is required to process replacement for each "sign" value without iteratively replacing values inxwhich can cause re-replacement of values which is not intended.- ...
additional arguments are ignored.
Value
vector of labels or colors, based upon argument type,
or when type="all" it returns data.frame with rows for each
entry in x.
Details
This venndir utility function is used to convert a basic
directional label such as "0 1 0 -1" suitable for display.
It can output either Unicode or non-Unicode text label,
or a corresponding color.
The input is defined in a data.frame obtained from
get_venndir_curate_df(), or using the user-provided curate_df.
Each sign returned by signed_overlaps()
is matched in the 'from' column, then replaced with values in the
'sign' column, then colorized by the 'color' column.
Note that zeros "0" are typically removed before calling this function.
The curate_df must contain these four colnames:
"from"- regular expression patterns, which will be surrounded by"^("and")$"to ensure complete match."sign"-characterreplacement for each value matched in"from"whentype="sign"."color"-characterR color to assign to each value matched in"from", whentype="color"."hide_singlet"-logicalindicating whether signed singlet counts should be hidden, for example "agreement" has no meaning when only one set is involved.
Multiple signs are concatenated together, in the event the input overlap
has multiple values, for example "1 1" becomes "^^" with no
spacing.
To impose whitespace between sign characters, define sign=c("^ ", "v ")
to include whitespace. Any leading/trailing whitespace will be removed
afterwards.
See also
Other venndir signs:
get_venndir_curate_df()
Examples
venn_labels <- c("0 1 0 -1", "1 -1", "1 1 1", "mixed", "agreement", "1 1 0 0");
(curate_venn_labels(venn_labels, "sign"))
#> [1] "-↑-↓" "↑↓" "↑↑↑" "X" "=" "↑↑--"
(curate_venn_labels(venn_labels, "sign", unicode=FALSE))
#> [1] "-^-v" "^v" "^^^" "X" "=" "^^--"
(curate_venn_labels(venn_labels, "color"))
#> [1] "#9E4497FF" "#9E4497FF" "#B22222FF" "#737373FF" "#1874CDFF" "#B22222FF"
(curate_venn_labels(venn_labels, "all"))
#> sign color hide_singlet
#> 1 -↑-↓ #9E4497FF FALSE
#> 2 ↑↓ #9E4497FF FALSE
#> 3 ↑↑↑ #B22222FF FALSE
#> 4 X #737373FF FALSE
#> 5 = #1874CDFF TRUE
#> 6 ↑↑-- #B22222FF FALSE
jamba::printDebug(as.list(curate_venn_labels(venn_labels, "sign")),
collapse=", ",
fgText=as.list(curate_venn_labels(venn_labels, "color")))
#> ## (22:38:29) 09Jul2025: -↑-↓, ↑↓, ↑↑↑, X, =, ↑↑--