Venndir class
Details
This object is intended to contain all the required data to produce a venndir figure. The components in this object can be edited.
Slots:
jps:
JamPolygon
containing the set and overlap polygons.Columns
"x"
,"y"
contain polygon coordinates, seeJamPolygon-class
for details on multi-part polygons, and polygons with holes.The polygon type is defined with column
type
and values"set"
or"overlap"
.The "set" polygons are intended to be the full circle for each set, but may be
NA
orNULL
to indicate the set is empty.The "overlap" polygons are expected to be contained inside "set" polygons, and each overlap polygon may be multi-polygons with or without holes. For example, the "set" polygon for
set_A
which is a circle fully contained inside another setset_B
. The "overlap" polygon forset_A
would be empty, since there is no region unique toset_A
. However the "overlap" polygonset_A&set_B
would contain the full circle defined by "set" polygonset_A
. Lastly the "overlap" polygon forset_B
would be a circle with a hole located at "overlap"set_A&set_B
. or ellipse. The overlap polygons are polygons, possibly multi-part with or without holes, or may beNA
orNULL
to indicate that this overlap does not have a corresponding polygon.The
name
column contains set or overlap names, where multiple sets are concatenated with"&"
by default. or ellipse corresponding to each set insetlist
), and the overlap polygons. Where an overlap does not exist, the polygon coordinates will be empty, or will have entirelyNA
values for "x" and "y".
label_df:
data.frame
which contains information about Venn labels placement and content. It should contain one row for each Venn overlap. When data contains signed overlaps, each overlap is sub-divided by the combination of overlap signs, with one row per overlap and overlap signs. Overlap signs are summarized based upon argumentoverlap_type
, seesigned_overlaps()
."overlap_sign"
represents the combination of overlap name, and the overlap sign across all sets."text"
indicates the count label to be displayed."venn_counts"
indicates the numeric number of Venn overlaps in each row."item"
should be alist
that containscharacter
vectors of items in each overlap set. Column"item"
is optional."nsets"
indicates the number of sets involved in the overlap."x"
,"y"
represent the label coordinate to use inside each polygon overlap. When the label is displayed outside the polygon, the values"x_offset"
and"y_offset"
are added to"x"
and"y"
, respectively. In this way, a line segment can be drawn from the outer label back to the corresponding polygon."color"
indicates the color for each label. Note the actual color may be modified based upon the background fill color to maximize the contrast and visibility of the color. For example blue on a dark background is displayed as light blue."fontsize"
indicates the base font size, prior to any optional adjustment withfont_cex
."fill"
indicates an optional color fill behind the count label. WhenNULL
(default) there is no color fill. This value is usually populated by argumentlabel_style
which is passed tovenndir_label_preset()
."border"
indicates an optional border around count labels, and is handled similar to"fill"
."padding"
,"padding_unit"
,"r"
, and"r_unit"
are used withgridtext::richtext_grob()
to define padding around count labels, and optional rounded corners when border is displayed.Other columns are intended for internal use by
render_venndir()
and are not yet fully editable.
setlist:
list
with thesetlist
used to create the Venn overlaps. Previously this data could be inferred fromlabel_df
which was tedious, and required column"item"
which is optional. That said,setlist
can be an emptylist()
.metadata:
list
with optional metadata, intended for future expansion, such as plot title.
See also
Other venndir advanced:
curate_venn_labels()
,
get_venndir_curate_df()
,
modify_venndir_overlap()
,
nudge_venndir_label()
Examples
v <- venndir(make_venn_test(100, 2, do_signed=TRUE), do_plot=FALSE)
# default print for Venndir gives a concise summary
v
#> class: Venndir
#> number of sets: 2
#> number of polygons: 2 sets, 3 overlaps
#> overlap_type: 'concordance'
#> sets:
#> set_name setlist_labels legend_labels set_colors size
#> 1 set_A set_A set_A #EEC12E 32
#> 2 set_B set_B set_B #D54848 16
# example with overlap which is not shown
overlaps <- c(set_A=187, set_B=146, set_C=499,
`set_A&set_B`=1,
`set_A&set_C`=181,
`set_B&set_C`=219,
`set_A&set_B&set_C`=20);
setlist_o <- counts2setlist(overlaps)
v3 <- venndir(setlist_o, proportional=TRUE, do_plot=FALSE)
# the print includes '1 overlap cannot be displayed'
v3
#> class: Venndir
#> number of sets: 3
#> number of polygons: 3 sets, 7 overlaps
#> overlap_type: 'overlap'
#> 1 overlap cannot be displayed:
#> * `set_A&set_B`=1
#> sets:
#> set_name setlist_labels legend_labels set_colors size
#> 1 set_A set_A set_A #EEC12E 389
#> 2 set_B set_B set_B #D54848 386
#> 3 set_C set_C set_C #9F8DFF 919
# the warnings(v3) also contain the overlaps not displayed
warnings(v3)
#> Warning message:
#> In "set_A&set_B" : 1
# the overlap names can be extracted directly
as.character(warnings(v3))
#> [1] "set_A&set_B"
# the counts for each overlap are also available
as.numeric(names(warnings(v3)))
#> [1] 1