Changelog
Source:NEWS.md
ggtargets 0.0.0.9001
Collapse graph
-
dag_collapse(dag, by)collapses a DAG by any node column: the nodes that share a value are merged into one, labeled with its member count, and the edges between groups are drawn once per pair, with annthat counts them. A pipeline of fifty targets in four stages becomes four nodes.bycan be a column of your own (viaas_dag(nodes =)) or one of the columnstar_dag()returns:description, the one free-form per-target fieldtargetshas,typeorstatus. A grouping that makes a cycle is an error naming the groups and the edges behind it.tar_ggplot(collapse_by =)does it in one call. A pipeline’s stages go in thedescriptionof its targets, for a block of them withtar_option_set(description = ): see “Collapsing a pipeline by stage” in?tar_ggplot, the get-started vignette and the “Collapsing a pipeline” article. A stage whose targets have different statuses has no status, and is drawn gray. -
node_sizeandedge_width(inggplot_dag(),dag_layers()andtar_ggplot()) draw a numeric node or edge column as the node’s radius and the edge’s width, for any DAG: for a collapsed graph,node_size = "n"andedge_width = "n"show how many targets and dependencies each node and edge stands for. The ranges arestyle_metro(node_size_range, edge_width_range), kept within the grid’s spacing. Edges that share a line in the metro layout are drawn whole, the widest first, so the shared line is as wide as the widest edge on it, and each bridge is as wide as the widest edge it lies under.dag_layout()now also returns the dag’sedges, with their extra columns.
Fixes
- A node with no value in the
node_colorcolumn (NA) is drawn gray, with no legend entry and no warning from a named palette. The edges drawn in its color (edge_color = "source"or"target") used to be dropped: they had no color, and ggplot2 removed them without a word when it drew the plot, sonode_color = "branches"lost the edges out of every stem.NAno longer takes a color from the palette either: with a palette function or an unnamed vector, the other values of a column that hasNAmove up a color, and a palette one color short of the values plusNAno longer errors. - A node column can’t be named
row,col,x,yorcolor_index, the names of the layout’s own columns, which it would silently overwrite (a columnxreplaced the nodes’ coordinates):as_dag()anddag_layout()stop with an error naming the column. -
dag_collapse()keeps thebycolumn’s own value whenbyisseconds,bytesorbranches(it summed it, like the others), and leaves a node whosebyvalue is an empty string on its own, like one with anNA. -
as_dag()stops on an empty node name (it failed with “attempt to use zero-length variable name”), and keeps a factorlabelcolumn as text (it turned it into integer codes). A node column value of""gets its palette color or shape like any other value. -
node_color = NA_character_andedge_color = NA_character_are an error, as they would give every node or edge a missing color.dag_layout()stops with a clear message when it is not given adag. - Summaries print “1 node”, “1 edge” and “1 column” in the singular.
ggtargets 0.0.0.9000
Initial release.
Plotting
metro_palette()never repeats a color: the 18 distinct dagviz colors (dagviz’s 21-color cycle repeats three of them) are followed by generated, perceptibly distinct colors. A too-short vectorpaletteis an error, not recycled.tar_ggplot()plots the currenttargetspipeline in one call, in dagviz’s “metro” style: one row per target, thick colored edges with rounded bends, and a white “bridge” wherever two edges cross. It mirrorstargets::tar_visnetwork()’s filtering arguments (names/allow/excludeas tidyselect,targets_only,script,store, …).as_dag()builds the same kind of plot from any directed acyclic graph: an edge-list data frame, or atargets::tar_network()-shaped list.tar_dag()is a thin wrapper reading the current pipeline this way.node_color/palettecolor nodes by a node column, a single color, or dagviz’s own default palette (metro_palette());targets_status_colors()givestargets’s own status palette fornode_color = "status".edge_colorcolors edges by their source node (the default), their target node, or a single color.Nodes are drawn by their
type, astargets::tar_visnetwork()does (targets_node_shapes()): a circle for a regular target, a square for a dynamic-branching one, and an up and a down triangle for an imported function and object (withtar_ggplot(targets_only = FALSE)). A legend names the shapes whenever more than one is drawn, merged with the color legend ifnode_coloris the same column.node_shapepicks the column (or one shape for every node) andshapesmaps its values to shapes ("circle","square","diamond","triangle","triangle_down"), so any DAG’s nodes can be shaped by a column too. Nodes are drawn as points, so withfixed_size = FALSEthey keep their size, like lines and text, while the spacing stretches; legend keys are circles.A legend taller than the graph (a few nodes with a status and a shape legend) is not cut off:
dag_size()andggsave_dag()make the plot as tall as the legend.Plots have a fixed physical size (one data unit is
zoompx at 96 dpi), so nodes, lines and text look the same in every pipeline.dag_size()returns that size andggsave_dag()saves at it, at dagviz’s own scale (and, withstyle_metro(minimal_width = 500), its canvas width).
Styling and ggplot2
-
style_metro()exposes every visual detail of the metro style: node/arc size, edge width, label font, bridge color, and more - accepting either dagviz’s ownStyleConfigvalues or their R equivalents. - Plots end just past their longest label, rather than leaving a wide blank area on the right: the label text is measured to size the plot.
style_metro(minimal_width = 500)gives dagviz’s wider canvas. -
ggplot_dag(lay, ...)and manual assembly (ggplot() + dag_layers(dag_layout(dag)) + dag_theme()) both return plainggplotobjects that compose with the rest of ggplot2 - titles, themes, patchwork, and so on.
Fidelity
- The metro layout - node order, column/lane assignment, and pixel geometry - matches dagviz 0.6.0’s own SVG output exactly on all 67 reference fixtures (drawn from real Snakemake rulegraphs via snakevision, hand-built edge cases, and random graphs), including draw order within dagviz’s own SVG groups. The one deliberate difference is the width of the plot, which is fitted to the labels by default (see above); with
minimal_width = 500the view box matches too.