plot_modules: Visualize a network and its modules

Description Usage Arguments Value Examples

View source: R/plotting.R

Description

This function plots a network and highlights the individual modules. An attempt is made to layout the nodes so that any visual overlaps among modules correspond to true overlaps in the network, however it is possible that a node may appear to be in multiple modules in the visualization when it does not actually belong to multiple modules. If the result of another plot is provided using the compare_graph argument, then the layout of this network will be based on that plot and convex hulls are drawn to trace out the modules; in this case it is likely that the displayed modules will contain extraneous nodes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
plot_modules(
  network,
  compare_graph = NULL,
  as_subgraph = TRUE,
  modules = NULL,
  node_scale = 4,
  edge_scale = 1,
  node_color = adjustcolor("orange", 0.5),
  group_color = palette.colors(9, "Set 1"),
  generate_layout = igraph::nicely,
  include_vertex_labels = TRUE,
  show_legend = FALSE,
  legend_position = "topright",
  legend_horizontal = FALSE,
  display_plot = TRUE,
  ...
)

Arguments

network

A 'network' object to plot. Alternatively, an adjacency or association matrix can be provided, in which case the 'modules' argument should be specified.

compare_graph

The plot of another network to use for comparison.

as_subgraph

If TRUE, only nodes of positive degree will be shown.

modules

A list of modules for the network; this is used to provide a member list of each module when the network argument is not a 'network' object. To get this list from a network, use get_network_modules.

node_scale

Used for scaling of nodes.

edge_scale

Used for scaling of edges.

node_color

The color used for the nodes.

group_color

A vector of colors used for the modules.

generate_layout

A function to generate the layout of a graph; used if coords is NULL. See layout_ from igraph for details. Other options include as_star, in_circle, and with_fr, among many others.

include_vertex_labels

If TRUE, the verticies will be labeled.

show_legend

If TRUE, a legend for the modules is shown. Default is FALSE

legend_position

The location of the legend. Can be any one of "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" or "center".

legend_horizontal

If TRUE, the legend will be displayed horizontally.

display_plot

If TRUE (default), the plot will be generated and displayed.

...

Additional arguments passed to plot.igraph.

Value

A 'network_plot' object for the network. This object can be passed back into a future call of plot.network through the compare_graph argument, which will setup the plot for easier comparison between the old graph and the new graph of network.

Examples

1
2
3
4
5
set.seed(1)
# Networks can be plotted with modules highlighted.
nw <- random_network(100)
g <- plot_network(nw)
plot_modules(nw, g) # Overlay convex hulls around modules in previous layout.

SeqNet documentation built on July 9, 2021, 9:08 a.m.