This function plots epicontacts objects using the visNetwork package. The produced object is an htmlwidget which will need rendering within a web browser.

vis_epicontacts(
  x,
  thin = TRUE,
  node_color = "id",
  label = "id",
  annot = TRUE,
  node_shape = NULL,
  shapes = NULL,
  edge_label = NULL,
  edge_color = NULL,
  legend = TRUE,
  legend_max = 10,
  x_axis = NULL,
  col_pal = cases_pal,
  NA_col = "lightgrey",
  edge_col_pal = edges_pal,
  width = "90%",
  height = "700px",
  selector = TRUE,
  editor = FALSE,
  edge_width = 3,
  ...
)

Arguments

x

An epicontacts object.

thin

A logical indicating if the data should be thinned with thin so that only cases with contacts should be plotted.

node_color

An index or character string indicating which field of the linelist should be used to color the nodes.

label

An index, logical, or character string indicating which fields of the linelist should be used for labelling the nodes. Logical will be recycled if necessary, so that the default TRUE effectively uses all columns of the linelist.

annot

An index, logical, or character string indicating which fields of the linelist should be used for annotating the nodes. Logical will be recycled if necessary, so that the default TRUE effectively uses all columns of the linelist.

node_shape

An index or character string indicating which field of the linelist should be used to determine the shapes of the nodes.

shapes

A named vector of characters indicating which icon code should be used for each value node_shape, e.g. c(m = "male", f = "female") if 'm' amd 'f' are values from node_shape. See codeawesome for all available codes.

edge_label

An index or character string indicating which field of the contacts data should be used to label the edges of the graph.

edge_color

An index or character string indicating which field of the contacts data should be used to color the edges of the graph.

legend

A logical indicating whether a legend should be added to the plot.

legend_max

The maximum number of groups for a legend to be displayed.

x_axis

A character string indicating which field of the linelist data should be used to specify the x axis position (must be numeric or Date)

col_pal

A color palette for the nodes.

NA_col

The color used for unknown group.

edge_col_pal

A color palette for the edges.

width

The width of the output, in html compatible format (e.g. '90%' or '800px').

height

The height of the output, in html compatible format (e.g. '800px').

selector

A logical indicating if the selector tool should be used; defaults to TRUE.

editor

A logical indicating if the editor tool should be used; defaults to FALSE.

edge_width

An integer indicating the width of the edges. Defaults to 3.

...

Further arguments to be passed to visNetwork.

Value

The same output as visNetwork.

See also

visNetwork in the package visNetwork. edges_pal and cases_pal for color palettes used

Author

Thibaut Jombart (thibautjombart@gmail.com) VP Nagraj (vpnagraj@virginia.edu) Zhian N. Kamvar (zkamvar@gmail.com)

Examples

if (require(outbreaks)) { ## example using MERS outbreak in Korea, 2014 head(mers_korea_2015[[1]]) head(mers_korea_2015[[2]]) x <- make_epicontacts(linelist=mers_korea_2015[[1]], contacts = mers_korea_2015[[2]], directed=TRUE) if (FALSE) { plot(x) plot(x, node_color = "place_infect") # show transmission tree with time as the horizontal axis, showing all nodes vis_epicontacts(x, x_axis = "dt_onset", thin = FALSE) plot(x, node_color = "loc_hosp", legend_max=20, annot=TRUE) plot(x, node_color = "loc_hosp", legend_max=20, annot=TRUE, x_axis = "dt_onset") plot(x, "place_infect", node_shape = "sex", shapes = c(M = "male", F = "female")) plot(x, "sex", node_shape = "sex", shapes = c(F = "female", M = "male"), edge_label = "exposure", edge_color = "exposure") } }
#> Warning: Cycle(s) detected in the contact network: this may be unwanted