Changelog
Source:NEWS.md
venndir 0.0.47.900
- Added to Imports:
eulerr
,gtable
(lightweight, also used by ggplot2) - Added to Suggests:
gridtext
,marquee
- Count labels use
grid::textGrob()
by default, sincegridtext
(kerning) andmarquee
(R crash on MacOS) have “limitations”. - Major refactoring of label grouping: uses
gtable
instead ofgTree
. Faster and more accurate height/width. Fixed labels being slightly cropped. - Simplified the Venndir data model, columns no longer used for labels.
new functions
-
assemble_venndir_labels()
- new workhorse function creates grobs, assembles them intogtable
format.- Reverts
text_grob_type="marquee"
totext_grob_type="textGrob"
on MacOS using R-4.4.1 or older. - Applies fontfamily,fontface,fontsize,fontcolor to each type of label, and multiple labels, each in order.
- Reverts
changes to existing functions
-
- Changed default
fontfamily="sans"
to avoid “Arial” which may not be present for all graphics devices. - Help docs include useful
...
arguments passed to internal functions. - Now calls
assemble_venndir_labels()
, notdraw_gridtext_groups()
. - Argument
group_labels
is dropped, all labels are grouped.
- Changed default
-
- New default shows up/down counts when shown in Venn diagram.
- New default shows table borders.
- New argument
legend_color_style
controls color fill and border. - The “Size” column is now left-aligned, previously right-aligned.
- Added light grey shading to “Total” row.
- Added leading/trailing whitespace to all columns.
venndir 0.0.46.900
Legend labels can include signed counts and percentage values.
changes to existing functions
-
venndir_legender()
can optionally include signed counts and percentage.- Renamed argument
include_total=TRUE
tolegend_total=TRUE
, for consistency with the next two arguments, and to help distinguish these options specific to the legend. - New argument
legend_signed=FALSE
defines whether to show signed counts. WhenNULL
orTRUE
it will display signed counts only when present, for example whenoverlap_type
is not “overlap”.legend_signed=FALSE
will always hide signed counts. - New argument
legend_percentage=NULL
detects whether to display percent total items, and is only used whenlegend_total=TRUE
. Whenshow_labels
includes percentage, it isTRUE
, otherwiseFALSE
.
- Renamed argument
-
- Changed default
segment_distance=0.05
previously0.1
, to shrink the distance of outside labels from the Venn polygons. Outside labels are now always justified relative to the plot, and so the labels can be placed closer, and the Venn diagram can be drawn slightly larger.
- Changed default
-
- Changed default
expand_fraction=NULL
fromexpand_fraction=0
so it detects whether to adjust the default condition whendraw_legend=TRUE
, andmain
is supplied as a plot title. It expands the default location, and shifts it slightly upward.
- Changed default
venndir 0.0.45.900
changes to existing functions
-
- Updated
item_cex
logic again, solidifying the association ofitem_cex
values to specific, named Venn overlaps, which are also stored inmetadata
for persistence, and editing. - Related, fixed a bug causing
item_cex
to be applied incorrectly when there were empty items. Now it is applied by overlap name to keep proper sync.
- Updated
venndir 0.0.45.900
changes to existing functions
-
- Improved the
item_cex
calculations, accounting for relative area of each shape, and number of items, also imposing a floor to prevent microscopic font sizes. - Fixed minor bug causing
item_cex
to be applied incorrectly when there were missing/NA labels.
- Improved the
-
- default argument change:
font_cex=c(1, 1, 0.7)
, 0.7 is down from 0.8. - All
font_cex
values are secretly multiplied by 1.2 as a slight adjustment for the default condition.
- default argument change:
-
- New algorithm to place points inside a polygon, now using adaptive step sizes. Substantially fewer steps, much more accurate, and markedly faster. By being more accurate, it is guaranteed to use the optimal pattern, which finds the closest match to the number of points requested.
- For
spread=FALSE
it no longer takes the firstn
points, it now takes the middlen
points. Most cases the effect will be minimal.
-
- Now has better working examples, which plot the labels for review.
venndir 0.0.44.900
new functions
-
Venndir
has new methods:-
show()
to summarize the contents -
metadata()
andmetadata<-
-
setlist()
- returns the original setlist overlaplist()
-
overlapdf()
- returnsdata.frame
of overlap items signed_counts()
-
im()
- return incidence matrix format
-
-
modify_venndir_overlap()
,highlight_venndir_overlap()
- Customize overlap set visual features, such as fill color, border, fontsize, font color.
- The highlight function streamlines the options to draw a distinctive border around one or more overlap sets.
changes to existing functions
General changes to remove warnings, for example
minus_JamPolygon()
was throwing warnings with empty polygon input or output.Added tests for
area_JamPolygon()
andlabelr_JamPolygon()
for a couple weird cases with nested holes, nested-nested solid polygons.-
- Now accepts incidence matrix input, sets as colnames, items as rows, and
c(-1, 0, 1)
values. - Added to metadata slot for persistence, though some might be added directly to
label_df
for persistence for each overlap label:main
,template
,overlap_type
,draw_legend
,item_buffer
,item_cex
,item_style
,item_degrees
show_segments
,segment_buffer
-
render_venndir()
defaults areNULL
so they will pull from the “metadata” slot, otherwise it assigns the previous defaults. It is now possible to makeVenndir
object, then render separately and use the originalshow_segments
andsegment_buffer
values.
- Now accepts incidence matrix input, sets as colnames, items as rows, and
-
- Very small nudge to default 4-way elliptical Venn shapes to prevent rounding error overlaps at the ends of sets 2 and 3, overlapping the side edge of sets 4 and 1, respectively. Same thing, nudging sets 1 and 4 to prevent rounding error overlaps at the bottom edge. Previously there were miniscule “unique” shapes where the cornered edges slightly criss-crossed, since the ellipses are drawn with N vertices, and not infinite number of vertices. Possible side effect is that item fill for sets 1 and 4 may now also use the tiny section at the bottom for item labels.
-
- Slightly changed how
keep_item_order=TRUE
is implemented, making it markedly faster for larger lists.
- Slightly changed how
-
- For multi-part polygons, it now uses the largest disconnected polygon from the set, instead of using polygons in order. Apparently
polylabelr::poi()
uses the first polygon provided, which is sometimes comically small. - The new method checks for multi-part polygons, then determines whether there are multiple parent polygons. For polygons with holes, the sub-part polygons (holes, or nested solid polygons within a hole) need to be maintained with the appropriate parent. If there is only one parent, use them all as-is, since
polylabelr::poi()
works properly there. Otherwise, use the parent polygon with the largest net area. - This update is an improvement for most Venn diagrams, but may not be optimal for polygon purists, since the polygon with largest area may not be the “most labelable” polygon. That said,
polylabelr::poi()
ignores all but the first polygon anyway.
- For multi-part polygons, it now uses the largest disconnected polygon from the set, instead of using polygons in order. Apparently
-
- improved default condition for item buffer adjustment, it now only uses the number of items to make the buffer more restrictive, no longer uses the relative polygon area. (That adjustment was conflicting with the item-shrinkage approach.)
-
- New argument
scale
so this function accomplishes all manipulations:nudge
,rotate_degrees
, andscale
.
- New argument
venndir 0.0.43.900
changes to existing functions
-
- Minor adjustment to how the item buffer is determined with decreasing number of items. Slightly more centralized with 3 or fewer items.
-
render_venndir()
(andvenndir()
)- Now accepts
item_buffer
as a vector, recycled to all overlap sets. - No longer sorts item labels, instead they are expected to be sorted (or not) by
signed_overlaps()
.
- Now accepts
-
- New argument
keep_item_order=FALSE
by default sorts all items usingjamba::mixedSort()
(proper alphanumeric sort). Whenkeep_item_order=TRUE
it will keep items in the same order they originally appeared, which allows a fixed item label order when displaying item labels.
- New argument
-
- New argument
keep_item_order=TRUE
whose default will keep each overlap label in the order they are provided. Usually there is only one label per overlap, but if it is provided as alist
with multiple entries, they will be rendered in the order they are provided. Motivated by efforts to “reproduce the Venn diagram from a paper.”
- New argument
venndir 0.0.42.900
changes to existing functions
-
check_Venndir()
- validation function forVenndir
objects.- Fixed error when validating
Venndir
, applying logical criteria to vector with size > 1.
- Fixed error when validating
-
- Changed default
item_cex=1
consistent with improvements to item label scaling by Venn overlap polygon size.
- Changed default
venndir 0.0.41.950
changes to existing functions
-
- now applies
halign=0.5
for main count labels, which helps display percentage labels centered under the main count. - Percentage labels are rounded to integer values, except that values between 0 and 1 will show one digit, excluding 0 and 1.
- now applies
-
- new argument
extra_styles
intended to customize the text style for different label types. Currentlyextra_styles=list(percent=c("***", "***"))
will format percentage labels with bold,italic font.
- new argument
venndir 0.0.41.900
overall
- Add plot titles!
- Arrange signed counts in single column, under main counts.
- Outside Venn labels default slightly toward the top, rather than the sides.
-
nudge_venndir_label()
is convenient for moving inside or outside labels.
changes to existing functions
-
Venndir
S4 object changes.- New slot name
"metadata"
to store miscellaneous settings. All efforts are made to accept older Venndir objects without this slot available.
- New slot name
-
- New argument
main
to draw a plot title. It usesgridtext
to enable custom Markdown font options. When provided,main
is also stored inVenndir@metadata$main
for persistence. - New argument
template="wide"
is used to arrange count and signed count labels together:"wide"
places them side-by-side,"tall"
places them in one column. When provided,template
is also stored inVenndir@metadata$template
for persistence. - New argument
center
passed tolabel_outside_JamPolygon()
. The defaultcenter=c(0, -0.15)
tends to place labels at the top rather than the left/right sides by default. The default use case is improved.
- New argument
-
- Now properly converts set names with
"\n"
to use"<br>"
as originally intended, so it “just works”. - New arguments
main
andtemplate
as above, except that when no argument is defined, it will useVenndir@metadata$template
orVenndir@metadata$main
if defined.
- Now properly converts set names with
-
- New argument
offset_list
to define a list of offsets to one or more sets, where set is defined bynames(offset_list)
. - New arguments
align_x
,align_y
to apply uniform alignment of labels to the top/bottom/left/right of a set of labels. Useful to ensure labels are the same y-position and not slightly different heights.
- New argument
venndir 0.0.40.900
- Updated label positioning logic, silenced some unintended verbose output from
render_venndir()
.
venndir 0.0.39.950
-
Small change to use
gridGeometry
0.4.1 from Github until released to CRAN, this version fixes rare error caused by proportional diagram and innerborder, when the delta from two circles creates a small line with zero area. Will update again once it is available on CRAN. Thanks pmur002 for the rapid fix!- Updated tests from 0.0.39.900 which skipped the innerborder to circumvent the bug in the tests that uncovered the error.
-
- default argument
steps=20
, formerlysteps=200
which was (and is) the predominant rate-limiting step.
- default argument
nudge_JamPolygon()
now recognizesrotate_degrees
fixing the bug that previously did not allow rotating the Venn diagram polygons.
venndir 0.0.39.900
changes to existing functions
-
- Signed output now uses
":"
instead of": "
between the directional arrow and the count, for example"^^:20"
instead of"^^: 20"
. Somehow the whitespace calculation is inconsistent, causing some labels to be wider than others withgridtext::richtext_grob()
, with much wider whitespace than anticipated. The effect was inconsistent even on the same machine, between RStudio and R console, and differed across other machines also. Workarounds include choosing different fonts, apparently some provide more reliable whitespace calculations. The change only occurs during rendering whengrobs
are created. The underlyingVenndir
data is not changed.
- Signed output now uses
-
plot.JamPolygon()
, affectingvenndir()
andrender_venndir()
Now renders borders using
gridGeometry
thanks to suggestion from pmur002. Borders are more consistent, without small visual artifacts.Added
"outerborder"
as a formal border type.-
All three types of borders can be rendered, in order: outer, inner, border
- “outerborder” - begins at the outer edge of the boundary
- “border” - is centered on the boundary itself
- “innerborder” - begins at the inner edge of the boundary
- when
border
is not drawn, either the innerborder or outerborder are drawn on the border itself to prevent a tiny artifact gap between the innerborder and outerborder.
-
- The
Venndir
object now usesouterborder
instead ofborder
, and setsborder
toNA
. - New argument
lwd
controls default border line width. -
unicode
(silent argument passed tocurate_venn_labels()
controls the Unicode character with up/down arrows, disagreement, etc. You can supplyunicode=2
for alternate symbols, though they are font-dependent, R-dependent, and terminal-dependent. All things must work well together (apparently). Useunicode=FALSE
for simple text. - New default
poly_alpha=0.6
makes background less intense. - Now calls
make_color_contrast()
properly without forcing saturation, previously caused blue to become cyan instead of light blue.
- The
sample_JamPolygon()
changedn_ratio=1
after testing and disliking the previousn_ratio=4
.-
venndir_to_df()
gained some new features:-
new argument
df_format
with three formats:-
"hits"
- essentially a hit matrix with 1, 0, -1 indicating direction -
"items"
- each column of a data.frame contains items for a Venn overlap. -
"wide"
- intended as an RMarkdown summary - it uses grouped rows to display items in each Venn overlap. Not sure it works very well.
-
-
argument
return_type
:-
"data.frame"
(default) - returns a data.frame -
"kable"
- returns a colorizedkable
table for RMarkdown HTML
-
-
-
- now returns column
"color"
mainly used forvenndir_to_df()
- calls
colorjam::col_linear_xf()
for better colorization of counts whencolor_by_counts=TRUE
.
- now returns column
-
- Changed default
return_type="JamPolygon"
since transition to JamPolygon, removed the option for"polygon_list"
.
- Changed default
polygon_circles()
,polygon_ellipses()
both now returnJamPolygon
.
new functions
-
nudge_JamPolygon()
- simple function to adjustJamPolygon
polygons
added generic functions
Cleaned up some generic function logic, probably more to do.
-
Venndir
objects -
- This function was enhanced to be able to combine multiple
JamPolygon
objects either in a singlelist
, multiplelist
, and will now retain all colnames across allJamPolygon
objects.
- This function was enhanced to be able to combine multiple
removed deprecated functions, mostly related to polygon_list data format
The polygon_list format loosely conformed to polyclip
data input/output, but had several exceptions that motivated me to use JamPolygon
: simple polygons encoded as list, complex polygons encoded as nested list; solid polygon encoded as clockwise points, holes encoded counterclockwise.
bbox_polygon_list()
get_largest_polygon_list()
intersect_polygon_list()
labelr_polygon_list()
minus_polygon_list()
plot_polygon_list()
polygon_list_labelr()
rescale_polygon_list()
union_polygon_list()
get_venn_shapes()
eulerr_to_polygon_list()
polygon_areas()
nudge_polygon_coords()
nudge_polygon_list()
polygon_list_to_xy_list()
xy_list_to_polygon_list()
venndir 0.0.38.900
changes to existing functions
-
- default changed to
spread=TRUE
so that item labels are more evenly distributed by default - new argument
n_ratio
to control the target number of points, from whichspread=TRUE
will choosen
evenly spaced. For now, the ratio is setn_ratio=5
which seems to perform well.
- default changed to
-
- used to display item labels inside the Venn diagram, passes
...
tosample_JamPolygon()
- used to display item labels inside the Venn diagram, passes
-
-
Change:
names(setlist)
will have any characters":"
changed to"."
.- The
":"
character is used bygrid
as a delimited to namegrobs
, which meansnames(setlist)
that also contain":"
create confusion. Easiest workaround is to maintain":"
characters in thesetlist_labels
andlegend_labels
(for display) but to remove the":"
characters from the internal representation of these names. - In principle this should not create new bugs, however it is possible something else depends upon the internal names to match the original setlist names.
- The
-
venndir 0.0.37.900
changes
- Added tests for hidden count labels, hidden signed count labels, and corresponding overlap counts for good measure.
- Added laundry list of topics to document.
- Removed
gridtext_richtext_grob()
and supporting functions.
changes to existing functions
-
- New argument
render_thin_border
to control whether the thin line between inner and outer border is drawn. It may be hidden by default in future. -
buffer
can now be vectorized, to shift the plot along each side in order: (bottom, left, top, right). The default applies buffer to all side, but sometimes it is useful to shift the plot away from one side, for examplebuffer=c(0.1, 0, 0, 0, 0)
. It still maintains proper aspect ratio. - Added checks for line width 0, and empty
""
line colors, both are handled silently by drawing either line with width 0.01, or transparent color, respectively.
- New argument
-
- passes
expand_fraction
toplot.JamPolygon
using argumentbuffer
so it can shift the Venn diagram off-center. - now passes
...
toplot.JamPolygon()
so that optional arguments will be recognized.
- passes
venndir 0.0.36.900
Substantial changes.
The method of assembling labels now arranges labels adjacent to each other, removing an important dependency on internal gridtext
functions (which are not permitted in CRAN/Bioconductor). It also allows more flexible labeling in future, e.g. different overlap metrics, optional overlap names.
Labels use a more aesthetic layout: * The main set label is always top-center of a group of labels. * Count labels are split into left/right columns, for main/signed counts, respectively. They are middle-aligned left-to-right. * Set label and count labels are arranged top/bottom, also centered. * One region is defined for the group of labels. * The previous arrangement can be see with group_labels=FALSE
.
All graphics are returned as grid
graphical objects (grobs), which enables flexible options for drawing the figure. For example it can be drawn inside a grid::viewport
, or included with patchwork
or cowplot
as a figure panel. Or, the grobs
can be directly manipulated.
Bug fixes
-
- Fixed issue that associated a count label to an interior overlap set, a rare occurrence. Caused by the method used to associate an orphan set label, where there is no “uniquely set_B” overlap polygon so it associates “set_B” to an overlap region that contains set_B. That method incorrectly also allowed an overlap count to appear for sets that do not have an overlap region - which occurs when proportional circles fail to find a solution that contains every overlap observed. The fix is to hide overlap count labels when the overlap is not represented, while still displaying the main set label when some overlap exists that contains that set.
changes to existing functions
-
- returns attributes
"gtree"
,"grob_list"
,"viewport"
whendo_plot=TRUE
- assigns
padding
andradius
using the same values.
- returns attributes
-
- Returns attributes
"gtree"
,"grob_list"
,"viewport"
- The figure is rendered with one call to
grid::grid.draw()
instead of being done piecemeal, making it appear faster. - No longer calls custom
gridtext_richtext_grob()
, since that also calls functions internal to the gridtext package. It was done in order to supply vector of differentpadding
values. - Instead calls
gridtext::richtext_grob()
in a list.
- Returns attributes
-
- Now left-aligns the text label columns, and right-aligns the count value column.
- New argument
legend_padding
to control the table cell size. - A bug in
gridExtra::tableGrob()
calculation of padding caused left-aligned text to appear at the very left edge of the text box, without a padded region shown. The padding is only used to extend the box itself, but still allows the label to be aligned relative to the extended box, and not the inner region. This bug was sidestepped by enfocing leading/trailing whitespace.
-
- Modified to return
grid
graphical objects, and theviewport
defined. - New argument
do_draw
to control whether the figure is drawn, or only the graphical objects should be returned.
- Modified to return
draw_gridtext_groups()
- substantial changes, most all previous processing has been changed. It is used internally.
New internal functions
Not terribly exciting, but useful nonetheless. Several new functions were added to help manipulate grid
grobs, to stack, tile, xalign, yalign grobs relative to each other, using units that keep them aligned even when the plot device is resized. These functions are probably dependent upon gridtext
labels, since they are used to create individual overlap and count labels, and define xext
,yext
with the “true” grid
dimensions for each label. These functions make it possible to center the grouped label on the original label point, or align the left column with the right column, etc.
venndir 0.0.35.900
- Added LICENSE and LICENSE.md.
changes to existing functions
-
venndir()
- relatively minor update, fixes unnamedsetlist
orsetlist
with duplicate orNA
names.- Validates that
names(setlist)
are defined, otherwise integer numbers are defined in order. - Validates that
names(setlist)
are unique, and notNA
, otherwise it callsjamba::makeNames()
to create unique names.
- Validates that
bug fixes
-
Fixed bug in
venndir()
when usingsets
to define a subset fromsetlist
causing the colors to be out of sync.- Added tests to confirm duplicated or
NA
fornames(setlist)
are handled.
- Added tests to confirm duplicated or
venndir 0.0.34.900
changes to existing functions
Main goal is to fix bug associated with empty or nested setlist
entries when used with proportional=TRUE
. This update is somewhat of a risk, several core components were updated in venndir()
, render_venndir()
and venndir_label_style()
, which could impact a number of downstream steps. Corresponding testthis
entries have been added, hopefully to prevent occurrence of new bugs.
Added
vdiffr
to R package Suggests.-
venndir()
,render_venndir()
,venndir_label_style()
- All three functions now recognize a new column in
Venndir
slotjps
with column"ref_polygon"
. This new column associates the set name with an overlap polygon, which points the set label to the appropriate part of a polygon. For example, by default “set_A” will point to the overlap_set “set_A” which has no overlaps with other sets. For proportional diagrams, sometimes “set_A” is fully encompassed by “set_B”, in which case the label “set_A” will point to the overlap polygon which is (1) not empty of course, and (2) has the fewest overlaps. - Without this association, the set label was not displayed, which was not intended.
- Further, the previous implementation was incorrect, causing some labels to appear in the wrong position. The line segment from label to overlap polygon still pointed to the correct position, but it was awkwardly placed outside the circle.
- It turns out that moving the set label affected other assumptions of the data model, namely that the set name “set_A” may be associated with
overlap_set
by a different name, for example"set_A&set_B"
. That change broke the label grouping logic, and needed to be resolved.
- All three functions now recognize a new column in
Added test cases
- More
testthis
scenarios have been added, including the first examples that test consistent graphical output. Mainly these tests focus on proportional 2-, 3-, and 4-way Venn and Euler diagrams, with empty sets, or nested sets, or both.
venndir 0.0.33.900
- Removed
matrixStats
from dependencies.
changes to existing functions
-
- New arguments:
setlist_labels
andlegend_labels
that usenames(setlist)
by default, but can be adjusted to be display-friendly. Thesetlist_labels
are displayed on the Venn diagram itself. Thelegend_labels
are displayed only in the Venn legend viavenndir_legender()
.
- New arguments:
-
list2im_opt()
has a new default argumentdo_sparse=FALSE
.- Previously all incidence matrix output used compressed
Matrix
class when available. In almost all cases, I immediately converted back tomatrix
or useddo_sparse=FALSE
anyway. Before wider use of the package, best to improve the default condition.
- Previously all incidence matrix output used compressed
Added examples to
rescale_coordinates()
.
venndir 0.0.32.900
Changes to existing functions
-
venndir()
andrender_venndir()
- Percent can now optionally be labeled for each overlap, with
show_labels
which includes the letter"p"
. When"c"
and"p"
are both included, the two labels are included in the order they appear, separated usingpercent_delimiter
which by default uses a newline. For now, percentage will always appear in the same location with counts"c"
, unless counts are hidden. For exampleshow_labels="Ncp"
will place set names outside, and count and percent inside. Similarlyshow_labels="Np"
will place set names outside, and only the percent will be displayed inside. Also,show_labels="Npc"
will place the percentage first, then the overlap count. - New argument default
item_style="default"
will auto-detect Markdown and imposesitem_style="gridtext"
when found, otherwise uses the fasteritem_style="text"
. -
show_items=NA
default is changed when items should be displayed, defined whenshow_labels
contains"i"
. In that case theoverlap_type
helps determine eithrshow_items="item"
orshow_items="sign item"
.
- Percent can now optionally be labeled for each overlap, with
Venndir-class
- additional documentation.-
- recognizes option to include (or hide) percent, in the same location as the overlap count label.
- Argument
percent_delim
controls the delimiter between count and percent, and takes effect only when both are visible. The default"<br>"
places the second value on a new line.
-
venn_meme()
change via hotfix:- new argument
draw_legend=FALSE
to hide the Venn legend by default, a change from the default forvenndir()
andrender_venndir()
, since the legend is not relevant forvenn_meme()
.
- new argument
venndir 0.0.31.900
- All
sp
andrgeos
references were removed! - More work to be done to improve the use of
Venndir
objects internally, with “convenience functions” to help access and manipulate its data.
changes to existing functions
-
add_orientation_JamPolygon()
,area_JamPolygon()
,plot.JamPolygon()
,union_JamPolygon()
- updated to improve detection of empty polygons
venndir 0.0.30.900
The polyclip update. Removing all remnants of sp
and rgeos
.
Major change, all functions ported or rewritten not to rely upon sp
, rgeos
, and sf
, since the migration to sf
would also incur heavy burden of installing sf
and all its map/geography-related system libraries.
Backward compatibility is limited for pre-existing venndir output, since rgeos
was removed from CRAN (ugh). In principle a pre-existing object could be re-run to produce the new object output.
Attempts were made for venndir()
to produce output equivalent to previous versions, but it is unclear how practical that may be.
All graphical output uses grid
, no support for base
or ggplot2
. The grid
output was chosen since it can be conveniently combined into panels using patchwork
or cowplot
, while offering more robust features to position graphical components, also keeping 1:1 aspect ratio so Venn circles remain circular.
New S4 objects:
-
JamPolygon
- makeshift polygondata.frame
to hold one polygon per row (where one “polygon” may be represented as a multi-part polygon with optional holes or nested holes.) This object makes callingpolyclip
andgrid
functions more reliable, since they recognize slightly different formats. -
Venndir
- replacement forlist
output, with equivalent content. Will transition to function accessors to obtain content, removing need for direct list access.
venndir package changes
- added
pracma
,polyclip
,vwline
to Depends. - removed
sf
,sp
,rgeos
from Depends. (Ack) - removed
ggtext
from Depends, all output usesgridtext
orgrid
. - replaced
venndir()
andrender_venndir()
with new versions, very temporarily moving previous functions tovenndir_OLD()
andrender_venndir_OLD()
. - new function for item label fill, previously called
spsample()
.
new JamPolygon
object and functions
(It may eventually become its own R package.)
-
JamPolygon
is intended to provide a very basic mechanism to store polygon coordinates with the following design:- One “polygon” is stored on one row of a
data.frame
. - One “polygon” can include multiple parts, for example including holes, nested polygons (polygon inside the hole of the parent polygon), and disjoint/separate polygon components. For example one “polygon” could represent multiple separate shapes, each with or without holes and enclosed polygons. The driving reason is to handle proportional Venn diagrams, which sometimes have a set fully enclosed inside another set which creates a hole in the larger set; sometimes two elliptical polygons overlap in the middle at an angle, so the unique portion of one ellipse is split into two parts.
- Multi-part polygons are assumed to be simplified, with no overlapping solid regions. (Polygons are combined with
union_JamPolygon()
.) - Multi-part polygons always use
"evenodd"
logic, so any inner polygon is assumed to be a hole, and any polygon inside a hole is assumed to be solid. This logic is applied regardless the clockwise/counterclockwise orientation of points for each polygon (polyclip convention: solid is clockwise, holes are counter-clockwise). Calls topolyclip
functions will adjust the polygon orientation as needed for the purpose of usingpolyclip
, but these details are not important forJamPolygon
itself. - Other properties can be associated with the polygon row, to help maintain and view these associations in a convenient way: name, label, fill, border, border.lwd, fontsize, family, innerborder, innerborder.lwd.
- Optional properties can be added to describe multi-polygon rows: orientation, polygon_holes, polygon_clockwise, polygon_parent. They are mostly useful for internal functions.
-
innerborder
is a new feature, my selfish desire to enable borders that are not overdrawn with adjacent polygons (which share the same border but on different sides). It requires a brilliant packagevwline
to draw variable-width lines (thanks Paul Murrell). It also requires knowledge of the direction lines are drawn, in order to define left/right border relative to the path taken when rendering the border. - All plot rendering uses
grid
graphics. All coordinates are encoded in theJamPolygon
object, so they can be plotted separately, howeverplot()
andplot.JamPolygon()
usegrid
.
- One “polygon” is stored on one row of a
-
Some supporting functions for
JamPolygon
:-
plot.JamPolygon()
-grid
draw function forJamPolygon
objects -
rbind2()
- generic function to combine multipleJamPolygon
objects -
bbox_JamPolygon()
- bounding box enclosing all polygons -
area_JamPolygon()
- area for each row, accounting for holes and nested polygons. -
buffer_JamPolygon()
- expand or shrink polygon borders -
point_in_JamPolygon()
- test for point inside solid portion of polygons -
has_point_in_JamPolygon()
- logical presence/absence of point in any solid polygon -
add_orientation_JamPolygon()
- adds polygon/multipolygon orientation, including holes, clockwise, and parent enclosing polygon. -
labelr_JamPolygon()
- define best label position within each polygon -
minus_JamPolygon()
- first polygon, removing subsequent polygons -
union_JamPolygon()
- combine and simplify all polygons into one row -
intersect_JamPolygon()
- first polygon, intersecting subsequent polygons -
sample_JamPolygon()
- define sample points within solid polygon -
split_JamPolygon()
- split multi-part polygons onto separate rows. Note that holes become solid polygons during this step. -
polyclip_to_JamPolygon()
- convertpolyclip::polyclip()
output toJamPolygon
.
-
venndir 0.0.29.900
- bumped version dependency for colorjam (>= 0.0.26.900)
- added steps for plan to migrate from
sp
topolyclip
, avoiding heavy dependencies on GDAL, GEOS, LWGEOM software libraries which are unrelated to venndir’s use of polygon geometry functions.
venndir 0.0.28.900
bug fixes
-
polygon_label_fill()
threw an error when supplied with an empty polygon, now returnsNULL
so the upstream function can deal with the lack of labels. The issue appears to arise from proportional diagrams that use item labels, where the item label has no suitable polygon to use. Presumably something from the updatedeulerr
package that creates overlap circles/ellipses to use in these diagrams.
venndir 0.0.27.900
changes to existing functions
-
- The pattern matching was improved so that it can handle replacement values that may contain patterns, without re-replacing resulting
character
strings. For examplefrom="1"
will no longer match the value"-1"
when it is the first entry ofcurate_df[,"from"]
. Similarly, an output string that contains"1"
will no longer be re-replaced again by matching patternfrom="1"
. The use case was noticed when trying to specify a gridtext font size usingfrom=c("-1", "1")
andsign=c("<span style='font-size=18pt'>Down</span>", "<span style='font-size=18pt'>Up</span>")
which caused the"1"
to be re-replaced.
- The pattern matching was improved so that it can handle replacement values that may contain patterns, without re-replacing resulting
venndir 0.0.26.900
changes to existing functions
-
-
plot_style="base"
now plots thesf
form of data, rather thanSpatialPolygonsDataFrame
, the first step in transitioning fromsp
tosf
prior to the deprecation of thesp
package altogether. All plotting should be equivalent. -
lwd
is now honored when plotting Venn circles and polygons, andlwd=0
is silently replaced withlwd=1
andcol="#00000000"
so the borders are hidden. -
plot_style="gg"
honorslwd
aslinewidth
usingggplot2::scale_linewidth_identity()
, which unfortunately is slightly larger line width than corresponding values with base R plots. Ah well. - Default line width changed from
lwd=2
tolwd=0.5
. The value is not configurable in function calls, but can be edited in the venndir outputlist
object, invenn_spdf
.
-
-
- now properly matches subset
setlist
and order of thevenndir_out
, in case using a subset ofsetlist
invenndir(..., sets=c(1, 3, 4))
- fixed issue with grid output when no
venndir_out
was supplied, now it defaults to white background with black text. - new argument
keep_newlines=FALSE
which by default removes newlines (line breaks) in the set labels. Usekeep_newlines=TRUE
to keep line breaks as-is. - new argument
set_colors
to specify optional colors to use in the table. - The
poly_alpha
value used to define transparency of Venn colors is honored in the color legend, usingvenn_spdf$alpha
. - The border color
"border"
is now honored, as is"lwd"
.
- now properly matches subset
venndir 0.0.25.900
new functions
-
venndir_legend()
- option for grid or base style, works with base or ggplot2 venndir.
- The recommended
style="grid"
as it offers a nicely organized style, with better positioning which works the same forbase
andggplot2
venndir()
output.
changes to dependencies
- added
data.table
to dependencies, since it is used byshrink_df()
. - added
gridExtra
to enable optional legendgridExtra::tableGrob()
.
changes to existing functions
-
- argument default
overlap_type="concordance"
was changed tooverlap_type="detect"
to fix regression where all input data is assumed to be signed, thus showing up arrows even for non-directional input data. The functionsigned_overlaps()
will detect an appropriate type unless given a specificoverlap_type
value.
- argument default
-
list2im_opt()
andlist2im_value()
- argument default
do_sparse=TRUE
was changed todo_sparse=FALSE
because in almost all cases the most appropriate class ismatrix
. Only for very rare cases with extremely large matrices should sparse matrix objects be used, which makes it most appropriate as an option and not a default.
- argument default
bug fixes
-
counts2setlist()
warnings regarding GEOS future retirement are silenced in the examples. -
list2im_opt()
uses the updated non-deprecated coersion ofmatrix
to"ngCMatrix"
, although the end result is still an object with class"ngCMatrix"
. It now uses threeas()
coersions, as instructed by the Matrix package. The Matrixas()
is properly imported by usingimportFrom(methods, as)
and placingMatrix
into theSuggests
list.
venndir 0.0.24.900
-
jamba
now requires version 0.0.90.900 forcoordPresets()
to provide figure positioning rather than plot positioning. Used forplot_warning
with proportional Venn diagrams that cannot display all possible overlaps. - Signed labels should now have padding appropriate to their font size, instead of inheriting padding used by other labels. The visual effect is small, but should improve the packing of signed labels, making the overall group of labels smaller and more cohesive.
changes to existing functions
-
- new argument
padding
to customize the padding around Venn labels. - new behavior,
padding
is scaled relative tofont_cex
, for smaller padding when the font size is scaled down. -
plot_warning
label is placed relative to the bottom of the plot figure, not the plot border, giving a bit more space below the typical proportional Venn diagram.
- new argument
render_venndir()
callsgridtext_richtext_grob()
instead ofgridtext::richtext_grob()
to enable vectorizedpadding
.
new functions
Two temporary functions to customize gridtext. Both functions also call internel gridtext
functions, so they cannot be maintained when venndir
is prepared for CRAN. More likely these functions will become the basis for gridtext
issue and/or pull request (PR).
-
gridtext_richtext_grob()
- applypadding
in vectorized form, to enable distinctpadding
to be applied to each label. This function is modified to extendpadding
and call customgridtext_make_outer_box()
. -
gridtext_make_outer_box()
- applypadding
in vectorized form, to enable distinctpadding
to be applied to each label.
venndir 0.0.23.900
change in defaults
- The default
venndir_label_style()
position for set names is now"outside"
, changed from previous"inside"
. There were too many cases where the set name was long, then pushed the numeric count labels too far away from the desired position at the center of the Venn polygon. The new challenge is getting adequate spacing around the Venn diagram to place labels that fit inside the plot window. -
make_color_contrast()
was adjusted to reduce the saturation/chroma of light text colors, the end result reduces the “cyan” appearance of “dodgerblue” when converted to a lighter contrasting color.
changes to existing functions
-
venndir()
new argumentsign_count_delim
allows customization of the delimiter between sign and numeric counts, for example"^^: 12"
uses the default delimiter": "
. In some cases it may be preferred to usesign_count_delim=" "
to omit the colon":"
character.
bug fixes
venndir()
and related functions were failing in RStudio when used underdevtools::load_all()
, apparently because thergeos
package needs to be loaded with@imports
before directly calling functions from thergeos
package. This issue appears to occur only when usingdevtools
.-
Corrected some warnings caused by argument overloading:
-
label_preset
is now recognized byvenndir()
andrender_venndir()
, and is now passed formally fromvenndir()
torender_venndir()
to prevent it being passed to other internal functions, such as theplot()
function. The warning was:"label_preset" is not a graphical parameter
-
display_counts
a developmental argument passed fromvenndir()
torender_venndir()
. The warning was:"display_counts" is not a graphical parameter
-
new branch (future dev)
- A new Github branch was created
"sp-to-sf"
to migrate away from the sp (Spatial Polygons) package, and toward the sf (Simple Features) package. This migration will remove dependencies onsp
andrgeos
which are being retired in 2023 anyway. It should also make the overall dependency footprint ofvenndir
much smaller, sincesf
has few dependencies while also covering the functions required from other packages.
venndir 0.0.22.900
bug fixes
-
textvenn()
was throwing an error with jamba version0.0.83.900
caused by updates tojamba::printDebug()
used for printing colorized output. Dependency was bumped to0.0.84.900
where the bug was fixed.
venndir 0.0.21.900
updates to existing functions
-
venndir()
andrender_venndir()
new argumentitem_buffer
- goal is to make this option easier to modify
- It is passed to
polygon_label_fill()
as argumentscale_width
which was otherwise very hard to find.
-
render_venndir()
will now auto-calculate an appropriateitem_cex
- when
item_cex=NULL
oritem_cex
has only onenumeric
value. The scaling is based upon the total number of items inside each polygon, and the relative area of each polygon. - When
item_cex
is supplied as a singlenumeric
value, it is multipled by the auto-scaled adjustment, so theitem_cex
acts as a relative adjustment to the auto-scale font sizing. -
item_cex_factor
helps control the magnitude of scaling for large numbers of items (which shouldn’t matter much since they are already not very legible.).
- when
-
render_venndir()
default changesegment_buffer=-0.05
- smaller than previous
segment_buffer=-0.2
- This change will cause most segments to end very near the outer border of the polygon.
- For proportional euler diagrams, this change is also a stop-gap correction for having the segment line end too far inside the polygon, sometimes causing it to conflict with other polygons. That issue is caused by having the segment point inside the parent polygon (circle or ellipse) instead of an overlap polygon, and specifically the segment should point to the overlap polygon with the fewest overlaps, by default the polygon whose only overlap is to the set label itself.
- smaller than previous
venn_meme()
was updated to passitem_cex
as a two-itemnumeric
vector in order to prevent the auto-scaling described above.
venndir 0.0.20.900
bug fixes
Proportional Venn diagrams have been a bit of a challenge for labeling. Some edge cases were resolved finally, mostly relevant when certain Venn overlap wedges were razor thin, or when an overlap was represented by more than one polygon in the resulting geometry.
Also, label placement outside the Venn circle was inconsistent, some of the options in polygon_label_outside()
appear to work poorly together. Its default values were adjusted to be more consistently “pleasing”.
-
render_venndir()
had a bug that caused proportional Venn labels for single-set overlaps to be assigned to the wrong set polygon when the label was being positioned outside. The line segment would sometimes be visibly ambiguous. It would point the setA line segment to the full setA instead of the smaller non-overlap polygon representing unique setA items. In most cases the workaround was to usesegment_buffer=0
so the label arrow is drawn to the edge of the circle. When the overall Venn diagram had reasonable proportions the visual effect was not that obvious. With extreme Venn diagrams (small sliver of unique items for some sets) the output was not as intended. -
get_largest_polygon()
was updated to work withSpatialPolygonsDataFrame
, previously it did not subset the polygons, returning the full set of polygons. It contributed to set labels being weirdly placed, specifically in rare cases where an overlap set (for examplesetA&setB
) was represented by two polygons where setA and setB uniquely overlap, and where one of those polygons was extremely small. In the weird test case, the smaller polygon had area 0.2, while the larger polygon had area 150. The label is intended to point to the largest available polygon for each overlap, however with objectsSpatialPolygonsDataFrame
it was returning all polygons for each overlap, and the first polygon was labeled. The issue showed up only when the first of multiple polygons happened to be the smaller one, and substantially smaller.
Lightweight change: polygon_label_outside()
was moved into a separate .R file. The venndir-sp.R
file has too many functions, it will be split into pieces eventually.
venndir 0.0.19.900
bug fixes
-
polygon_label_fill()
: At last fixed an elusive bug causing certain item label scenarios to throw an error, turned out to be caused by lack of rownames on a matrix sorted byjamba::mixedSortDF()
. The error occurred in an internal functionget_poly_points()
that iterates different labeling conditions until at leastn
label coordinates are returned. Apparently the functionspsample()
does not guarantee returning the same number of coordinate points as requested. This error must have bitten someone else somewhere in the R world, requesting 15 sampled points, then receiving only 12.
changes to existing functions
-
rescale_sp()
argumentrotate_degrees
will now recognized a named vector.- names are expected to match polygon names stored in the
sp
object in the ID slotName of each individualPolygons
object, for example the first polygon in aSpatialPolygon
object would have name stored as:sp@polygons[[1]]@ID
. Whenrotate_degrees
contains names, only names that match the polygons will be applied, which allows rotating individual polygons within aSpatialPolygons
object. -
share_polygon_center=TRUE
new argument intended for multi-polygonPolygons
objects, which happens when there are two disconnected parts inside onePolygons
element. When this occurs, by default the two parts are rotated as if they were one unit, around their own local center, by default. Whenshare_polygon_center=FALSE
each polygon is rotated about its own personal center.
- names are expected to match polygon names stored in the
-
- new argument
item_style="gridtext"
is a different default thanvenndir()
because memes are expected to have fewer labels, and are most likely to use fancy markdown text formatting. This argument is passed tovenndir()
. Whenitem_style="text"
it will autocorrect"<br>"
into newline; whenitem_style="gridtext"
it will autocorrect newline into"<br>"
.
- new argument
venndir 0.0.18.900
bug fixes
To resolve issue #2, the colorjam
package was updated to add prefix to call jamba::tcount()
to function colorjam::approx_degrees()
. When the colorjam
package is loaded, using library(colorjam)
or require(colorjam)
it automatically also loads jamba so its functions are available. However, when colorjam::approx_degrees()
is called directly, without formally loading the colorjam
package, the jamba
functions are not loaded. This issue caused the error, which unfortunately causes the venndir()
function to fail unless jamba
or colorjam
packages have been loaded previously.
All that said, the “fix” is to require the updated colorjam(>= 0.0.22.950)
package version that includes this fix.
venndir 0.0.17.900
updates to existing functions
-
venndir()
was updated to change the priority of label placement for proportional Venn diagrams. It used to choose the full set circle for the main set label, now it chooses the unique overlap polygon for that set if it exists, then uses the full set circle only as a fallback. -
venndir_label_style()
was updated to fix longstanding weird glitch with proportional Venn diagrams sometimes displaying counts when one set is fully inside all other sets, but that set has non-zero items unique to that set - so there is nowhere appropriate to display them. Because the main set label was displayed, the count label was errantly placed at the center of the Venn circle. Now the bug is fixed, the value is not displayed - it is part of the optional warning message that lists any overlap counts that could not be displayed. -
render_venndir()
fixed type “bow_lwd” is now correctly “box_lwd”, only impacted box line width when the line width was changed from default.
venndir 0.0.16.900
bug fix
-
counts2setlist()
corrected an error when supplied with empty overlaps, which previously included at least one delimiter even for empty sets. Entries were added to the tests to confirm this behavior. -
polygon_label_fill()
small bug in how label placement used rotation, the polygon center was not properly re-used when un-rotating labels to the original orientation. The default was -20 degrees, so the effect was subtle.
changes to existing functions
venndir_label_style()
was updated to change the logic used to place labels inside or outside each Venn overlap polygon, specifically to allow item labels to be inside, or hidden, and adjust the count label visibility accordingly.venndir_label_style()
, andvenndir()
now properly hide item labels usingmax_items
, instead displaying the overlap count.-
venndir_label_style()
argumentscount
andsigned
have new options:-
"ifneeded"
will display the overlap count when item labels are not being displayed, otherwise when item labels are displayed the count will be hidden. -
"detect"
will display the overlap count inside when item labels are not being displayed, otherwise the overlap count is outside when item labels are displayed.
-
polygon_label_fill()
new argumentref_sp
used to know the relative size of the polygon being labeled, to account for the adjustment whenapply_n_scale=TRUE
: the buffer polygon is generally smaller for fewer labels, but the new adjustment prevents polygons from being shrunk when the polygon is already very small.signed_overlaps()
new defaultoverlap_type="default"
which attempts to choose a reasonable option. When all values arec(0, 1)
it will chooseoverlap_type="overlap"
which does not use directionality. When the input containsnumeric
orinteger
values it will enforcesign()
so the comparison is done with the sign and not decimal values by default.
venndir 0.0.15.900
bug fixes
-
signed_overlaps()
was not handlingfactor
vectors as input, they were getting coerced tointeger
values instead ofcharacter
values. This issue was caused by handling duplicate entries, in this case the duplicate entries were not renamed to unique entries by callingc()
for themakeNamesFunc
part ofjamba::makeNames()
. The base R assignmentnames(x) <- c(y)
coercesfactor
values iny
tointeger
values, which in this case breaks the expected behavior. This seems like an edge case, but certainly one thatvenndir
should handle without issue - it is not always clear when values are stored as factors instead of character, and the expected behavior in all cases is forvenndir
to treatfactor
ascharacter
values. (Thank you Dr. Ashley Brooks for bringing my attention to this issue!)
changes to existing functions
-
list2im_value()
was also updated to handlefactor
values by coercing tocharacter
instead of allowing the base Rmatrix
coersion which by default coerces tointeger
. -
list2im_value()
was also updated to handleempty
which is a user-defined value to use in the resulting incidence matrix for empty entries. This argument is not used byvenndir
but is available for general conversion of value list to value incidence matrix. -
list2im_value()
was also updated to use a consistent defaultempty
based upon whether the inputsetlist
contains anycharacter
orfactor
values. The previous behavior handled each column independently. The rule is that when any column containscharacter
orfactor
values, the default isempty=""
across all columns; if all values arenumeric
the default isempty=0
. The result is a consistently formatted value incidence matrix. This is a rare edge case that is not expected for common use ofvenndir
but may arise from the conversion functions from value list to value incidence matrix.
new unit tests
- unit tests were added to confirm the behavior of
signed_overlaps()
with namedfactor
vectors as input.
venndir 0.0.14.900
new function
-
venn_meme()
is a wrapper function to help create “Venn Memes” also known as “Concept Venns”. These have text inside each overlap but no other counts or labels. Input is expected to be an overlap list, which is converted to setlist usingoverlaplist2setlist()
. See examples.
updates
-
venndir()
argumentfont_cex
was updated to accept length 3 which is applied to (1) main set labels, (2) main count labels, (3) directional count labels. It is sometimes useful to have main set labels larger than the main count labels, which prompted this change. Now it is possible to place main set labels outside the diagram, and have smaller count labels inside the diagram, for example to fit inside proportional Euler diagram shapes. This change addsfontsize
to thevenn_spdf
output object, thus storing the set label font size separate from the count label font size. -
venndir_label_style()
new argument optionlabel_preset="custom"
will not modify any label position settings. This option is intended when labels are manually adjusted and should not be changed, and where the user wants to applylabel_style
to affect the label color, fill, and box outline. - Updated dependency on
colorjam
to version0.0.18.900
to fix error withrad2deg()
when blending colors.
bug fixed
-
venndir_label_style()
now recognizes when items cannot be displayed inside proportional diagrams, and setsshow_items="none"
for those entries inlabel_df
. This change prevents trying to place labels inside a NULL overlap polygon.
testthat
- Added more tests, covering
venndir converters
likeim2list_opt()
,list2im()
,im_value2list()
, andlist2im_value()
.
venndir 0.0.13.900
updates to existing functions
-
label_polygon_fill()
new argumentlayout_degrees
allows rotating the label placement, relevant mostly forlabel_method="regular"
which produces square point grid, andlabel_method="hexagonal"
which produces a hexagonal point grid. It can be useful to rotate those points so text labels have less overlap. As a resultdegrees=0
is the new default, aslayout_degrees=-22
is also the new default. See the new set of examples which includes visual representation of methods to reduce text label overlaps. -
render_venndir()
default is changed toitem_degrees=0
. -
match_list()
was updated to require both list elements to have the same length, to account for duplicate items. - Added more tests, still many more to add.
venndir 0.0.12.900
updates to existing functions
- Added new function categories: “spatial”, “label”, “conversion”, “plotly”.
- Several functions were updated with newer examples.
- Renamed function
label_polygon_fill()
topolygon_label_fill()
to be consistent withpolygon_label_outside()
andpolygon_label_segment()
– also before anyone happens to start using this function! - Fixed issue where
fontfamily
was not being used with item labels, breaking display of unicode characters in some sessions.
new functions (experimental for plotly)
-
to_basic.GeomRichText()
andto_basic.GeomTextBox()
were added for rudimentary compatibility when usingplotly::ggplotly()
withggtext::geom_richtext()
andggtext::geom_textbox()
. These functions do display text inside plotly figure, however: (1) they do not cleanly use text positioning, even withtextposition
;
- plotly does not interpret markdown, so any markdown text is displayed as-is. Ultimately plotly support will probably be added to
render_venndir()
viaplot_style="plotly"
then usingplotly::plot_ly()
commands in native form.
venndir 0.0.11.900
bug fixes
- FIXED:
show_zero=TRUE
was not working, zeros were always hidden. - FIXED:
alpha_by_counts
appears to be mis-aligned. - FIXED: Fix issue where directional label colors apply
make_color_contrast()
without using the correctalpha
value. See withvenndir(make_venn_test(100, 3), poly_alpha=0)
venndir 0.0.10.900
updates to existing functions
-
render_venndir()
by default groups gridtext labels together, and draws one contiguous background and border around them all. It currently only works for R base plots, since it needs to know the grob sizes upfront. That said, at this point the base R plot looks substantially better than ggplot2 when labels are placed on the outside of the Venn circles. Hopefully I will figure out how to do the same for ggplot2 output.
new functions
-
draw_gridtext_groups()
does the work for grouping multiplegridtext::richtext_grob()
labels together, usingx, y, overlap_set
to define the grouping. This method also aligns text relative to a line segment if present, by usingdegrees_to_adj()
. A by-product of the approach is that labels are now centered by the label width, instead of having left/right components which may differ in width.
venndir 0.0.9.900
Began adding testthat
tests for various functions.
one more refactor
Proportional Venn diagrams (Euler diagrams) warranted a refactor in order to label each set even when one set is fully contained inside another set.
new functions
-
signed_counts2setlist()
is an import method similar tocounts2setlist()
but to allow importing directional overlaps. -
get_sp_buffer()
applies a buffer width to the interior of a polygon, either with fixed width, or relative width based upon the minimum width required to make the polygon disappear. The relative value meanssp_buffer=0.5
can be used to create a buffer at half-width, for a polygon of any size. The purpose is to draw a line segment from outside the polygon to “just inside” the polygon, using an amount appropriate for the size and shape of the polygon. As “rgeos”gBuffer()
has no ability to scale relative to the polygon size and shape,get_sp_buffer()
quickly runs a sweep to determine thewidth
where an internal polygon is just barely non-zero, and defines that assp_buffer=-1
. -
mean_degrees()
takes a vector of angles in degrees and returns the mean angle based upon the sum of unit vectors. It adds a small random bit to prevent vectors from exactly cancelling out, and an argumentseed
that makes the randomness reproducible. -
mean_degree_arc()
is similar tomean_degrees()
except it takes an ordered set of angles that define an arc, and returns the mean position along that arc. Use argumentdo_plot=TRUE
to see a visual representation of the options. It turns out that spreading text labels along an arc only worked when the mean angle was fixed inside the arc. Otherwise occassionally the mean angle could be exactly 180 degrees off, when the angles span more than 180 degrees, and if multiple labels were present at each end. You’d think that would be rare, but it happened enough to notice the bug and to implement better logic. -
degrees_to_adj()
is a helper function that takes an angle in degrees, and returns the textadjx
andadjy
values so a text label will be positioned outside the angle.
functions removed
-
ggrender_venndir()
was removed, userender_venndir(plot_style="gg")
in its place. It made sense to keep the visualization logic inside one function.
bug fixes
-
spread_degrees()
was not properly maintaining the initial order of angles when it iteratively spread out a series of angles. For example one group of angles could be spread wide enough to overlap another existing angle, in which case that angle should be kept outside the initial group, instead of being placed into the middle. The telltale sign is that line segments wildly criss-crossed inside the polygon.
changes to existing functions
New argument
inside_percent_threshold
added tovenndir()
,render_venndir()
, andvenndir_label_style()
used to position labels outside a polygon when its size is below this percent of the total polygon size. It works as a reasonable alternative for determining if the label visually fits inside a polygon.venndir()
can accept polygon shapes to use as input, instead of defining its own or using those fromeulerr::euler()
. New argumentvenn_sp
accepts anySpatialPolygons
compatible object, which must have at least as many polygons as there are sets insetlist
.venndir()
now adds the Venn shapes to the outputvenn_spdf
withtype="set"
; all other polygons havetype="overlap"
. The shapes will serve as an anchor for set labels, in the event we want to label one or more circles – like when one circle is fully contained inside another.polygon_label_outside()
now determines a reasonable text alignmentadj
based upon the angle offset, to help minimize label overlap with the line segment.polygon_label_outside()
was updated to correct some internal use of coordinates. New argumentsp_buffer
to allow the line segment to end slightly inside each polygon.get_venn_shapes()
default 4-way Venn ellipses were slightly adjusted so the middle ellipses broke the outer ellipses into two polygons. This change helps the automated position of labels bypolygon_label_outside()
with certain settings.venndir_label_style()
was refactored to be able to position labels inside or outside the polygon, for four types of labels:"set"
- e.g."set_A"
"overlap"
- e.g."set_A&set_B"
normally this label is not shown"count"
- e.g.10
"items"
- e.g.c("item1", "item3", "item9")
for each overlap set.
It has some label_preset
options, which help position set and count labels inside or outside.
venndir 0.0.8.900
One more refactor is in progress. Label coordinates will be pre-calculated inside and outside each polygon, then labels can be toggled in or out (or moved to a custom location). The main driver is to be able to label the Venn circles on the perimeter of the diagram. For proportional circles, when a set is fully contained inside another set, there is no polygon with that set alone – thus the defaul labeling fails.
new functions
-
polygon_label_outside()
defines label placement outside a polygon, one of two methods: “label” positions outside using relative label positioning; “bbox” positions outside using relative polygon position within the bounding box. -
expand_range()
is a simple function to expand a numeric range byexpand_fraction
, mainly for R plots to have space to render labels outside a central Venn diagram. -
spread_degrees()
takes a vector of angles in degrees as input, and returns a vector where angles are separated by at leastmin_degrees
. -
mean_degrees()
calculates the mean angle in degrees for an input vector of angles. -
diff_degrees()
takes a vector of angles in degrees, and returns the angular difference. Suitable for cases with angles likec(355, 2, 12)
where the difference between355
and2
is7
. -
sp_polylabelr()
is a simple wrapper function topolylabelr::poi()
forSpatialPolygons
objects.
venndir 0.0.7.900
Several refactoring processes being implemented, some further updates ad bugfixes may be necessary. Pushed this version for more testing on CentOS where the gridtext
package was hard to install for GCC below version 5.3, but was installed with GCC 5.3.
new dependencies
-
Added dependencies:
-
sf
package dependency for ggplot2 output -
gridtext
andggtext
for label output -
gridBase
for base R plotting
-
bug fixes
-
render_venndir()
addedsp
prefix toplot()
for base R plotting. -
signed_overlaps()
was updated to allow usingsep="|"
. Previous this delimited was used to make unique rownames, and needed to be parsed properly to prevent errors. -
venndir()
new argumentsep
which is now properly passed tosigned_overlaps()
andget_venn_shapes()
. -
find_vennpoly_overlaps()
,overlaplist2setlist()
,counts2setlist()
now callstrsplit(..., fixed=TRUE)
so thesep
character is not treated like a regular expression, thus allowing delimitersep="|"
if specified.
changes to existing functions
textvenn()
new argumentsep
to allow customizing the delimiter between set names, for example the defaultsep="&"
creates overlap names likeset_A&set_B
; butsep=" | "
creates overlap names likeset_A | set_B
.-
venndir()
new argumentshow_set
to customize display of each set name.-
show_set="main"
displays only the set name for main sets -
show_set="all"
displays all set names in each overlap -
show_set="none"
displays no set name -
show_set="boundary"
not yet implemented will display the set label for each circle/ellipse boundary
-
venndir 0.0.6.900
Much closer to a release-ready form. It needs the ggplot2 option enabled with the newest render_venndir()
logic.
bug fixes / changes
- Fixed obscure bug where set names could fail if not provided in alphabetic order.
- Changed
venndir()
defaultshow_zero=FALSE
to hide empty labels. - Removed
ggrender_venndir()
from the exported functions list, this function needs to be included insiderender_venndir()
.
refactoring the details
More refactoring may take place to simplify the workflow, until the package is publicized.
-
label_df$col
renamed tolabel_df$color
for consistency, and preparing for use by others. -
ggrender_vendir()
will be retired, or will be converted to a simple wrapper function which callsrender_venndir()
.
new features
-
label_polygon_fill()
new argumentsdither_cex
anddither_color
which slightly adjust thecex
andcolor
values. Thecex
is uniformly distributed +/- thedither_cex
value, as a fraction of thecex
, the default is roughly 4% variation incex
. Thedither_color
is similar, it adds some heterogeneity todarkFactor
andsFactor
and callsjamba::makeColorDarker()
to adjust brightness and saturation. -
label_polygon_fill()
can plot the polygon buffer behind the labels, to review the effect of adjustingscale_width
for each polygon. -
label_df
usesshow_label
andshow_items
to control visibility of the count label, and item labels, respectively. When the values areNA
it applied default rules, which favors showing count label, unless the count label is moved outside the polygon. -
label_df
recognizesx_offset,y_offset
to nudge count labels somewhere else. Currently manual, this adjustment may be automated at some point. When a label is moved outside its parent polygon, a line segment is drawn from the label to just inside the polygon boundary. When no items are displayed, the segment is drawn more toward the center. -
venndir_label_style()
new function to control the visual style of count labels, with option to fill and draw a border around labels. -
polygon_label_segment()
is used when moving a label from inside a polygon to somewhere that may or may not be inside that polygon. When it is moved outside, it returns the point on the polygon boundary along that line segment. It can be used withsp_buffer
so the line can be drawn slightly inside the polygon boundary.
venndir 0.0.5.900
display item labels inside Venn polygons
-
ggrender_venndir()
andrender_venndir()
both allow optional display of items inside the Venn polygons. For relatively small sets (<500) this works fairly well. You can configure the label to include the"sign"
, and/or"item"
. It works as an alternative or supplement to using proportional Venn diagrams.
new render functions
-
ggrender_venndir()
renders a venndir diagram using ggplot2. Note that this function requires the packagesf
, and in future other objects internal to venndir may be converted fromsp
tosf
. -
label_polyogn_fill()
takes aSpatialPolygons
object, a vector of labels, and returns coordinates to place labels inside the polygon. It has some adjustments to add buffer around polygon boundaries, but does not directly detect label overlaps. It either plots labels in base R graphics, or returns coordinates suitable for ggplot2.
new rescale_*()
functions
The rescale_*()
functions are intended to allow manipulation of numeric coordinates in each relevant object type, aimed at SpatialPolygons
and the various sub-types.
-
rescale_sp()
manipulatesSpatialPolygons
which contains one or morePolygons
objects, and therefore calls: -
rescale_ps()
manipulatesPolygons
which contains one or morePolygon
objects, and therefore calls: -
rescale_p()
manipulatesPolygon
which contains numericmatrix
coordinates, and therefore calls: -
rescale_coordinates()
manipulates numericmatrix
coordinates.
The rescale_*()
operations enable three types of manipulations:
-
scale
- multiplies coordinates for each axis -
rotate_degrees
- rotates points in degrees -
shift
- shifts coordinates by adding a constant to each axis -
center
- thescale
androtate_degree
are applied relative to thecenter
, which by default uses the mean bounding box.
new conversion functions
-
list2im_opt()
- optimized method to convert a list of character vectors to a logical incidence matrix. Thelist
names become colnames, which represent the names of each set. The rownames represent items. -
list2im_value()
- convert list of named vectors to a value incidence matrix. The list vectors are named by item, and the vector values are stored in the matrix. -
im2list()
- convert incidence matrix to list of character vectors. -
im_value2list()
- convert value incidence matrix to a list of vectors. Vectors are named by item, and values are from the incidence matrix. -
counts2setlist()
- convert vector of overlap counts to setlist, intended for compatibility with other packages likeeulerr
,upsetr
, andVennDiagram
.
changes to existing functions
-
venndir()
new argumentalpha_by_counts
adjusts alpha transparency of each overlap based upon the number of counts. Implemented to evaluate the visual effect for now.
venndir 0.0.4.900
changes to existing functions
-
venndir()
no longer renders the plot, but callsrender_venndir()
in order to offer more customized options. It also allows editing the source data as needed, like adjusting individual overlap settings. -
textvenn()
now supports directional Venn counts, even with"each"
it uses two columns for all possible directions for the central 3-way overlaps.
new functions
-
render_venndir()
renders a Venn or Euler diagram using the output format fromvenndir()
. It displays a warning at the bottom of the plot whenever a Venn overlap cannot be displayed, for example with proportional Venn (Euler) diagrams when an overlap cannot be represented. This label can be hidden, but by default is displayed so the information is not lost.
venndir 0.0.3.900
new functions
-
venndir()
the core visual function that displays either Venn diagram or a Euler diagram for proportional diagrams.
venndir 0.0.2.900
The venndir
package is intended for analyses where direction is encoded alongside each item in a set. The driving example is for gene expression analysis, which results in a subset of differentially expressed genes, where the expression can either by “up-regulation” or “down-regulation.” When comparing two sets of differentially expressed genes, it is helpful if not essential to recognize when any overlaps also share the same direction of change (or opposite direction.)
Although there are some 40,000 gene loci in human (give or take), it is common to see many of the same few hundred genes differentially regulated across a very diverse array of experiments. For two experiments to identify 800 genes each, with overlap of 400, these outcomes illustrate the utility of venndir:
- 400 genes overlap, 200 share the same direction, 200 are opposite. In this case, the overlap may represent response by similar functional set of genes, but with different biological drivers.
- 400 genes overlap, 396 genes share the same direction. In this case, the overlap could be seen as highly similar between the two sets.
- 400 genes overlap, only 4 genes share the same direction. In this case, the overlap could be see as nearly exactly opposite.
new functions
-
textvenn()
prints a Venn diagram using console text output. It also supports directionality, the formatting is still being adjusted for best visual appeal. -
signed_overlaps()
is the core overlap function for venndir, it performs directional and direct overlap, with configurable output. It returns adata.frame
with counts for each Venn overlap set, and optionally includes items. The exact output format may be adjusted in future, currently it returns one row per overlap. For directional overlaps, it returns one row per combination of up/down. -
make_venn_test()
is a convenience function to generate test sets for Venn diagrams. It can return simple sets, or sets with directionality. It is mainly intended to help create very large sets to test efficiency of the process.