graph3D: Interactive 3D Force-directed graph from epicontacts object

View source: R/graph3D.R

graph3DR Documentation

Interactive 3D Force-directed graph from epicontacts object

Description

This function creates a 3D graph from an epicontacts object

Usage

graph3D(
  x,
  node_color = "id",
  annot = TRUE,
  col_pal = cases_pal,
  NA_col = "lightgrey",
  g_title = "",
  bg_col = "white",
  label_col = "darkgrey",
  node_size = 1,
  edge_size = 0.5
)

Arguments

x

An epicontacts object

node_color

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

annot

An index, logical, or character string indicating which fields of the linelist should be used for annotating the nodes upon mouseover. The default TRUE shows the 'id' and 'node_color' (if the grouping column is different from 'id').

col_pal

A color palette for the node_colors.

NA_col

The color used for unknown node_color.

g_title

The title of the graph.

bg_col

The background color of graph.

label_col

The color of the graph title and labels of groups.

node_size

The sizes of graph nodes.

edge_size

The width of graph edges.

Value

An htmlwidget object that is displayed using the object's show or print method. (If you don't see your widget plot, try printing it with the print function.)

Note

All colors must be specified as color names like "red", "blue", etc. or as hexadecimal color values without opacity channel, for example "#FF0000", "#0a3e55" (upper or lower case hex digits are allowed).

Double-click or tap on the plot to reset the view.

Author(s)

Nistara Randhawa (nrandhawa@ucdavis.edu) Thibaut Jombart (thibautjombart@gmail.com) VP Nagraj (vpnagraj@virginia.edu)

References

Original rthreejs code by B. W. Lewis: https://github.com/bwlewis/rthreejs.

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$linelist,
                      contacts = mers_korea_2015$contacts,
                      directed = FALSE)

## Not run: 
graph3D(x)
graph3D(x, annot = FALSE)
graph3D(x, node_color = "sex", g_title = "MERS Korea 2014")
graph3D(x, node_color = "sex", annot = c("sex", "age"),
        g_title = "MERS Korea 2014")

## End(Not run)
}

reconhub/epicontacts documentation built on Feb. 28, 2024, 3:15 p.m.