plot_directed: Extensions to iGraph for Customising plots

Description Usage Arguments Examples

View source: R/plot_directed.R

Description

Functions to plot_directed or graph structures including customised colors, layout, states, arrows. Uses graphs functions as an extension of igraph. Designed for plotting directed graphs.

Usage

1
2
3
4
5
6
plot_directed(graph, state = "activating", labels = NULL,
  layout = layout.fruchterman.reingold, cex.node = 1, cex.label = 0.75,
  cex.arrow = 1.25, cex.main = 0.8, arrow_clip = 0.075, pch = 21,
  border.node = "grey33", fill.node = "grey66", col.label = NULL,
  col.arrow = par("fg"), main = NULL, sub = NULL, xlab = "",
  ylab = "", frame.plot = F)

Arguments

graph

An igraph object. Must be directed with known states.

state

character or integer. Defaults to "activating". May be applied a scalar across all edges or as a vector for each edge respectively. Accepts non-integer values for weighted edges provided that the sign indicates whether links are activating (positive) or inhibiting (negative). May also be entered as text for "activating" or "inhibiting" or as integers for activating (0,1) or inhibiting (-1,2). Compatible with inputs for make_state_matrix or generate_expression_graph in the graphsim package https://github.com/TomKellyGenetics/graphsim.

labels

character vector. For labels to plot nodes. Defaults to vertex names in graph object. Entering "" would yield unlabelled nodes.

layout

function. Layout function as selected from layout_. Defaults to layout.fruchterman.reingold. Alternatives include layout.kamada.kawai, layout.reingold.tilford, layout.sugiyama, and layout.davidson.harel.

cex.node

numeric. Defaults to 1.

cex.label

numeric. Defaults to 0.75.

cex.arrow

numeric Defaults to 1.25. May take a scalar applied to all edges or a vector with values for each edge respectively.

cex.main

numeric. Defaults to 0.8.

arrow_clip

numeric Defaults to 0.075 (7.5%).

pch

parameter passed to plot. Defaults to 21. Recommends using selecting between 21-25 to preserve colour behaviour. Otherwise entire node will inherit border.node as it's colour, in which case a light colour is recommended to see labels.

border.node

character. Specfies the colours of node border passed to plot. Defaults to grey33. Applies to whole node shape if pch has only one colour.

fill.node

character. Specfies the colours of node fill passed to plot. Defaults to grey66.

col.label

character. Specfies the colours of node labels passed to plot. Defaults to par("fg").

col.arrow

character. Specfies the colours of arrows passed to plot. Defaults to par("fg"). May take a scalar applied to all edges or a vector with colours for each edge respectively.

main, sub, xlab, ylab

Plotting paramaters to specify plot titles or axes labels

frame.plot

logical. Whether to frame plot with a box. Defaults to FALSE.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#generate example graphs
library("igraph")
graph_test4_edges <- rbind(c("A", "C"), c("B", "C"), c("C", "D"), c("D", "E"),
                           c("D", "F"), c("F", "G"), c("F", "I"), c("H", "I"))
graph_test4 <- graph.edgelist(graph_test4_edges, directed = TRUE)

#plots with igraph defaults
plot(graph_test4, layout = layout.fruchterman.reingold)
plot(graph_test4, layout = layout.kamada.kawai)

#plots with scalar states
plot_directed(graph_test4, state="activating")
plot_directed(graph_test4, state="inhibiting")

#plots with vector states
plot_directed(graph_test4, state=c(1, 1, 1, 1, -1, 1, 1, 1))
plot_directed(graph_test4, state=c(1, 1, -1, 1, -1, 1, -1, 1))

#plot layout customised
plot_directed(graph_test4, state=c(1, 1, -1, 1, -1, 1, -1, 1), layout = layout.kamada.kawai)

TomKellyGenetics/plot.igraph documentation built on April 8, 2020, 2:46 p.m.