library("igraph") library("devtools") devtools::install_github("TomKellyGenetics/plot.igraph") library("plot.igraph")
graph_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 <- graph.edgelist(graph_edges, directed = T)
plot_directed
with default settings uses the layout.fruchterman.reingold
as does the default igraph::plot.igraph
.
plot(graph) plot_directed(graph)
plot_directed
supports customised layouts and colours:
plot_directed(graph, layout = layout.kamada.kawai) plot_directed(graph, fill.node = "lightblue", border.node = "royalblue")
Colours may also be entered as a vector for each node in V(graph)
:
names(V(graph)) colour_vector <- ifelse(names(V(graph)) %in% c("A", "D", "I"), 1, 2) plot_directed(graph, fill.node = c("lightblue", "grey")[colour_vector], border.node = c("royalblue", "black")[colour_vector])
The state
parameter controls whether the links are "activating" or "inhibiting". These may be applied globally as a character or numeric:
plot_directed(graph, state = "activating") plot_directed(graph, state = "inhibiting") plot_directed(graph, state = 1) plot_directed(graph, state = -1) plot_directed(graph, state = 0) plot_directed(graph, state = 2)
The state parameter may also apply as a vector to each edge in E(graph) respectively.
E(graph) plot_directed(graph, state = c(1, 1, -1, -1, 1, -1, 1, -1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.