Curate Venn labels
Usage
curate_venn_labels(
x,
type = c("sign", "color"),
curate_df = NULL,
unicode = TRUE,
blend_preset = "ryb",
split = " ",
...
)
Arguments
- x
vector
of overlap labels.- type
character
string wheretype="sign"
will curatex
into directional sign, andtype="color"
will curatex
into corresponding directional color.- curate_df
data.frame
orNULL
with optional curation rules. The input is coerced todata.frame
if necessary. The colnames are expected to include:"from"
- regular expression patterns"sign"
- replacement value whentype="sign"
"color"
- replacement R color whentype="color"
- unicode
logical
indicating whether to use Unicode characters whentype="sign"
. Note this argument only affects the default values, it is not applied when using a customcurate_df
.- blend_preset
character
string passed aspreset
tocolorjam::blend_colors()
to define the color wheel used during color blending operations.- split
character
string 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 inx
which can cause re-replacement of values which is not intended.- ...
additional arguments are ignored.
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 currently recognizes directional labels such as
"0 -1 1 0"
or the character labels "agreement"
, "concordant"
,
"mixed"
. Note that zeros "0"
are typically removed
before calling this function.
The input vector x
is split using strsplit()
using whitespace
delimiter by default, then each full value is matched and replaced
using "from"
in curate_df
.
When curate_df
is not supplied, default values are generated
for "from"
values: "1"
, "-1"
, "0"
, "concordant|agreement"
,
and "mixed"
. Values are matched using regular expression gsub()
however the full string must match, therefore from="1"
will only
match "1"
and will not match "-1"
.
The curate_df
must contain these three colnames:
"from"
- regular expression patterns, which will be surrounded by"^("
and")$"
to ensure complete match."sign"
-character
replacement for each value matched in"from"
whentype="sign"
."color"
-character
R color to assign to each value matched in"from"
, whentype="color"
.
When two or more replacement values defined by curate_df[,"sign"]
are
present in one entry in x
, the values are concatenated together
with no whitespace. For example "1 1"
becomes "^^"
with no spacing.
To impose whitespace between characters, define sign=c("^ ", "v ")
to include whitespace. Any leading/trailing whitespace will be removed
afterwards.
See also
Other venndir utility:
expand_range()
,
make_color_contrast()
,
make_venn_combn_df()
,
make_venn_test()
,
match_list()
,
modify_venndir_overlap()
,
nudge_venndir_label()
,
plot,Venndir,ANY-method
,
print_color_df()
,
shrink_df()
,
three_point_angle()
,
venndir_legender()
,
venndir_to_df()
Examples
options("warn"=-1); # make them stop
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"
jamba::printDebug(as.list(curate_venn_labels(venn_labels, "sign")),
collapse=", ",
fgText=as.list(curate_venn_labels(venn_labels, "color")))
#> ## (20:59:32) 09Dec2024: -↑-↓, ↑↓, ↑↑↑, X, ‖, ↑↑--