netmeta (version 0.9-5)

netgraph: Network graph

Description

This function generates a graph of the evidence network.

Usage

netgraph(x, seq = x$seq,
         labels = rownames(x$TE.fixed),
         cex = 1, col = "slateblue", offset = 0.0175, scale = 1.10,
         plastic, thickness, lwd = 5, lwd.min = lwd/2.5, lwd.max = lwd*4,
         dim = "2d",
         highlight = NULL, col.highlight = "red2", lwd.highlight = lwd,
         multiarm = any(x$narms > 2), col.multiarm = NULL,
         alpha.transparency = 0.5,
         points = FALSE, col.points = "red", cex.points = 1, pch.points = 20,
         number.of.studies = FALSE,
         cex.number.of.studies = cex,
         col.number.of.studies = "white",
         bg.number.of.studies = "black",
         start.layout = ifelse(dim  == "2d", "circle", "eigen"),
         eig1 = 2, eig2 = 3, eig3 = 4,
         iterate, tol = 0.0001, maxit = 500, allfigures = FALSE,
         A.matrix = x$A.matrix, N.matrix = sign(A.matrix),
	 D.matrix = netdistance(N.matrix),
         xpos = NULL, ypos = NULL, zpos = NULL,
         ...)

Arguments

x

An object of class netmeta (mandatory).

seq

A character or numerical vector specifying the sequence of treatments arrangement (anticlockwise if start.layout = "circle").

labels

An optional vector with treatment labels.

cex

The magnification to be used for treatment labels.

col

Color of lines connecting treatments if argument plastic = FALSE.

offset

Distance between edges (i.e. treatments) in graph and treatment labels (value of 0.0175 corresponds to a difference of 1.75% of the range on x- and y-axis).

scale

Additional space added outside of edges (i.e. treatments). Increase this value for larger treatment labels (value of 1.10 corresponds to an additional space of 10% around the network graph).

plastic

A logical indicating whether the appearance of the comparisons should be in '3D look' (not to be confused with argument dim).

thickness

Either a character variable to determine the method to plot line widths (see Details) or a matrix of the same dimension and row and column names as argument A.matrix with information on line width.

lwd

A numeric for scaling the line width of comparisons.

lwd.max

Maximum line width in network graph. The connection with the largest value according to argument thickness will be set to this value.

lwd.min

Minimum line width in network graph. All connections with line widths below this values will be set to lwd.min.

dim

A character string indicating whether a 2- or 3-dimensional plot should be produced, either "2d" or "3d".

highlight

A character vector identifying comparisons that should be marked in the network graph, e.g. highlight = "treat1:treat2".

col.highlight

Color for highlighting the comparisons given by highlight.

lwd.highlight

A numeric for the line width for highlighting the comparisons given by highlight.

multiarm

A logical indicating whether multi-arm studies should marked in plot.

col.multiarm

Either a function from R library colorspace or grDevice to define colors for multi-arm studies or a character vector with colors to highlight multi-arm studies.

alpha.transparency

The alpha transparency of colors used to highlight multi-arm studies (0 means transparent and 1 means opaque).

points

A logical indicating whether points should be printed at nodes (i.e. treatments) of the network graph.

col.points, cex.points, pch.points

Corresponding color, size, type for points.

number.of.studies

A logical indicating whether number of studies should be added to network graph.

cex.number.of.studies

The magnification to be used for number of studies.

col.number.of.studies

Color for number of studies.

bg.number.of.studies

Color for shadow around number of studies.

start.layout

A character string indicating which starting layout is used if iterate = TRUE. If "circle" (default), the iteration starts with a circular ordering of the vertices; if "eigen", eigenvectors of the Laplacian matrix are used, calculated via generic function eigen (spectral decomposition); if "prcomp", eigenvectors of the Laplacian matrix are calculated via generic function prcomp (principal component analysis); if "random", a random layout is used, drawn from a bivariate normal.

eig1

A numeric indicating which eigenvector is used as x coordinate if start = "eigen" or "prcomp" and iterate = TRUE. Default is 2, the eigenvector to the second-smallest eigenvalue of the Laplacian matrix.

eig2

A numeric indicating which eigenvector is used as y-coordinate if start = "eigen" or "prcomp" and iterate = TRUE. Default is 3, the eigenvector to the third-smallest eigenvalue of the Laplacian matrix.

eig3

A numeric indicating which eigenvector is used as z-coordinate if start = "eigen" or "prcomp" and iterate = TRUE. Default is 4, the eigenvector to the fourth-smallest eigenvalue of the Laplacian matrix.

iterate

A logical indicating whether the stress majorization algorithm is carried out for optimization of the layout.

tol

A numeric for the tolerance for convergence if iterate = TRUE.

maxit

An integer defining the maximum number of iteration steps if iterate = TRUE.

allfigures

A logical indicating whether all iteration steps are shown if iterate = TRUE. May slow down calculations if set to TRUE (especially if plastic = TRUE).

A.matrix

Adjacency matrix (nxn) characterizing the structure of the network graph. Row and column names must be the same set of values as provided by argument seq.

N.matrix

Neighborhood matrix (nxn) replacing A.matrix if neighborhood is to be specified differently from node adjacency in the network graph, for example content-based. Row and column names must be the same set of values as provided by argument seq.

D.matrix

Distance matrix (nxn) replacing A.matrix and N.matrix if distances should be provided directly. Row and column names must be the same set of values as provided by argument seq.

xpos

Vector (n) of x coordinates.

ypos

Vector (n) of y coordinates.

zpos

Vector (n) of z coordinates.

Additional graphical arguments.

Details

The network is laid out in the plane, where the nodes in the graph layout correspond to the treatments and edges display the observed treatment comparisons. For the default setting, nodes are placed on a circle. Other starting layouts are "eigen", "prcomp", and "random" (R<U+00FC>cker & Schwarzer 2015). If iterate = TRUE, the layout is further optimized using the stress majorization algorithm. This algorithm specifies an 'ideal' distance (e.g., the graph distance) between two nodes in the plane. In the optimal layout, these distances are best approximated in the sense of least squares. Starting from an initial layout, the optimum is approximated in an iterative process called stress majorization (Kamada and Kawai 1989, Michailidis and de Leeuw 2001, Hu 2012). The starting layout can be chosen as a circle or coming from eigenvectors of the Laplacian matrix (corresponding to Hall's algorithm, Hall 1970), calculated in different ways, or random. Moreover, it can be chosen whether the iteration steps are shown (argument allfigures = TRUE).

Argument thickness providing the line width of the nodes (comparisons) can be a matrix of the same dimension as argument A.matrix or any of the following character variables:

  • Same line width (argument lwd) for all comparisons (thickness = "equal")

  • Proportional to number of studies comparing two treatments (thickness = "number.of.studies")

  • Proportional to inverse standard error of fixed effect model comparing two treatments (thickness = "se.fixed")

  • Proportional to inverse standard error of random effects model comparing two treatments (thickness = "se.random")

  • Weight from fixed effect model comparing two treatments (thickness = "w.fixed")

  • Weight from random effects model comparing two treatments (thickness = "w.random")

Only evidence from direct treatment comparisons is considered to determine the line width if argument thickness is equal to any but the first method. By default, thickness = "se.fixed" is used if start.layout = "circle", iterate = FALSE, and plastic = TRUE. Otherwise, the same line width is used.

Further, a couple of graphical parameters can be specified, such as color and appearance of the edges (treatments) and the nodes (comparisons), whether special comparisons should be highlighted and whether multi-arm studies should be indicated as colored polygons. By default, if R package colorspace is available the sequential_hcl function is used to highlight multi-arm studies; otherwise the rainbow is used.

In order to generate 3-D plots (argument dim = "3d"), R package rgl is necessary. Note, under macOS the X.Org X Window System must be available (see https://www.xquartz.org).

References

Hall, K.M. (1970). An r-dimensional quadratic placement algorithm. Management Science, 17, 219--229.

Hu, Y. (2012). Combinatorial Scientific Computing, Chapter Algorithms for Visualizing Large Networks, pages 525--549. Chapman and Hall/CRC Computational Science.

Kamada, T. and Kawai, S. (1989). An algorithm for drawing general undirected graphs. Information Processing Letters, 31(1), 7--15.

Krahn U, Binder H, K<U+00F6>nig J (2013), A graphical tool for locating inconsistency in network meta-analyses. BMC Medical Research Methodology, 13, 35.

Michailidis, G. and de Leeuw, J. (2001). Data visualization through graph drawing. Computational Statistics, 16(3), 435--450.

R<U+00FC>cker G & Schwarzer G (2016), Automated drawing of network plots in network meta-analysis. Research Synthesis Methods, 7, 94--107.

See Also

netmeta

Examples

Run this code
# NOT RUN {
data(Senn2013)

# Generation of an object of class 'netmeta' with reference treatment 'plac'
#
net1 <- netmeta(TE, seTE, treat1, treat2, studlab,
        data = Senn2013, sm = "MD", reference = "plac")

# Network graph with default settings
#
netgraph(net1)

# Network graph with specified order of the treatments and one
# highlighted comparison
#
trts <- c("plac", "benf", "migl", "acar", "sulf",
          "metf", "rosi", "piog", "sita", "vild")
netgraph(net1, highlight = "rosi:plac", seq = trts)

# Same network graph using argument 'seq' in netmeta function
#
net2 <- netmeta(TE, seTE, treat1, treat2, studlab,
                data = Senn2013, sm = "MD", reference = "plac",
                seq = trts)
netgraph(net2, highlight = "rosi:plac")

# Network graph optimized, starting from a circle, with multi-arm
# study colored
#
netgraph(net1, start = "circle", iterate = TRUE, col.multiarm = "purple")

# Network graph optimized, starting from a circle, with multi-arm
# study colored and all intermediate iteration steps visible
#
# }
# NOT RUN {
netgraph(net1, start = "circle", iterate = TRUE, col.multiarm = "purple",
         allfigures = TRUE)
# }
# NOT RUN {
# Network graph optimized, starting from Laplacian eigenvectors, with
# multi-arm study colored
#
netgraph(net1, start = "eigen", col.multiarm = "purple")

# Network graph optimized, starting from different Laplacian
# eigenvectors, with multi-arm study colored
#
netgraph(net1, start = "prcomp", col.multiarm = "purple")

# Network graph optimized, starting from random initial layout, with
# multi-arm study colored
#
netgraph(net1, start = "random", col.multiarm = "purple")

# Network graph without plastic look and one highlighted comparison
#
netgraph(net1, plastic = FALSE, highlight = "rosi:plac")

# Network graph without plastic look and comparisons with same
# thickness
netgraph(net1, plastic = FALSE, thickness = FALSE)

# Network graph with changed labels and specified order of the
# treatments
#
netgraph(net1, seq = c(1, 3, 5, 2, 9, 4, 7, 6, 8, 10),
         labels = LETTERS[1:10])

# }
# NOT RUN {
# Network graph in 3-D (opens a new device, where you may rotate and
# zoom the plot using the mouse / the mouse wheel).
# The rgl package must be installed for 3-D plots.
#
netgraph(net1, dim = "3d")
# }

Run the code above in your browser using DataCamp Workspace