graph_from_links_nodes: Display a graph from a list of links and nodes

Description Usage Arguments Value References See Also Examples

View source: R/graph_from_links_nodes.R

Description

Given a list of links and nodes (e.g. from extract_links_nodes func) Uses igraph and ggraph to display the network plots Must have the proper structure OR use extract_links_nodes(), which automatically returns this structure when given an adjacency matrix and its legend (see documentation for this function) network_data should be a list of 2 : edges, nodes For edges (data.frame) : from, to, weight, width, sign (of the weight: neg/pos) For nodes (data.frame) : name, title, family, family_color (optional)

Usage

1
2
3
4
5
6
graph_from_links_nodes(network_data, main_title = "",
  node_type = c("point", "label"), node_label_title = TRUE,
  family_palette = NULL, layout = "nicely", remove_null = TRUE,
  edge_alpha = TRUE, edge_color = c("#6DBDE6", "#FF8C69"),
  edge_width_range = c(0.2, 2), edge_alpha_range = c(0.4, 1),
  node_label_size = 3, legend_label_size = 10, ...)

Arguments

network_data

(list of two) : links, nodes with the proper structure

main_title

(string, optional) : the title of the network

node_type

: point (default) for the graph to display points and the label outside the point, or label to have a node which is the label itself (the text size will then be associated to the node degree)

node_label_title

(bool, default F) : should the node labels be the names or title column? (e.g. names : CRUDSAL_cat, title : Raw vegetables)

family_palette

(list of key = value) : the keys are the family codes (from family column in the legend), and the values are the corresponding colors. Can be generated using the family_palette func. USEFUL if there is a need to compare multiple graphs of the same families, so the color is consistent. If NULL (default), the palette will be automatically generated using viridis

layout

(chr) : the layout to be used to construct the graph

remove_null

(bool) : should the nodes with 0 connections (degree 0) be removed from the graph. default is TRUE.

edge_alpha

(bool) : should the edges have a transparent scale? In addition to the width scale.

edge_color

(list) : list of 2. The first element is the color of the negative edges, the second the positive. Default is c("#6DBDE6", "#FF8C69").

edge_width_range

: range of the edges width. (default is 0.2 to 2)

edge_alpha_range

: if edge_alpha is TRUE, the range of the alpha values (between 0 and 1). Default is 0.4 to 1.

node_label_size

: the size of the node labels. Default is 3.

legend_label_size

: the size of the legend labels. Default is 10.

...

: other parameters to pass to ggraph create_layout

Value

a list of 3 : igraph : the igraph object, net the graph, deg the degree table.

References

Csardi et al. (2006) <https://igraph.org>

Perdersen (2019) <https://ggraph.data-imaginist.com>

See Also

graph_from_matrix

Examples

1
2
3
4
5
adj_matrix <- cor(iris[,-5])
legend <- data.frame(name = colnames(iris[,-5]),
                     title = colnames(iris[,-5]))
graph_iris <- links_nodes_from_mat(adj_matrix, legend)
graph_from_links_nodes(graph_iris, main_title = "Iris graph")

vgasque/foodingraph documentation built on Nov. 5, 2019, 12:01 p.m.