Skip to contents

Convert a model specification into a graph (using the graph package) that can be plotted with Rgraphviz: see ?Rgraphviz::plot.graphNEL and https://graphviz.org/doc/info/attrs.html for information on customizing the plot.

Usage

dot_layout(spec, include_inout = FALSE)

Arguments

spec

a model specification

include_inout

(logical) include nodes defined by mp_per_capita_inflow and mp_per_capita_outflow ?

Details

In order to plot the graph, you need to have loaded the Rgraphviz package (library("Rgraphviz")). We suppress package startup messages when loading Rgraphviz in the examples below, because bioconductor (which is the R ecosystem for which Rgraphviz is developed) and tidyverse (which is an R ecosystem heavily used in macpan2 examples and workflows) use the same names for different functions. This naming clash gets reported when we load Rgraphviz, and we prefer to suppress these distracting messages. Please be aware of this in your workflows that use both tidyverse and dot_layout (and therefore bioconductor), and take appropriate action.

Examples

## Note: See above for an explanation of `suppressPackageStartupMessages`
if (suppressPackageStartupMessages(require(Rgraphviz))) {
  macpan_base = mp_tmb_library("starter_models", "macpan_base", package = "macpan2")
  ## plot with left-to-right layout, rectangles instead of default circles
  dot_layout(macpan_base) |>
    plot(attrs = list(graph = list(rankdir = "LR"),
                      node = list(shape = "rectangle")))
}