xA2Net: Function to visualise an igraph object in a ggplot style

Description Usage Arguments Value Note See Also Examples

View source: R/xA2Net.r

Description

xA2Net is supposed to visualise an igraph object in a ggplot style.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
xA2Net(g, node.label = NULL, label.wrap.width = NULL,
label.wrap.lineheight = 0.8, node.label.size = NULL,
node.label.fontface = "plain", node.label.color = "darkblue",
node.label.alpha = 0.8, node.label.padding = 1, node.label.arrow =
0.01,
node.label.force = 1, node.shape = 19, node.shape.title = NULL,
node.xcoord = NULL, node.ycoord = NULL, node.color = NULL,
node.color.title = NULL, colormap = "grey-orange-darkred", ncolors =
64,
zlim = NULL, na.color = "grey80", node.size = NULL,
node.size.title = NULL, node.size.range = c(1, 4), slim = NULL,
title = "", edge.size = 0.5, edge.color = "black",
edge.color.alpha = 0.5, edge.curve = 0.1, edge.arrow = 2,
edge.arrow.gap = 0.02)

Arguments

g

an object of class "igraph". For an advanced use, it can be a list of igraph objects; in this case, multiple panels will be shown (particularly useful when visualising the same network but color-coded differently)

node.label

either a vector labelling nodes or a character specifying which node attribute used for the labelling. If NULL (by default), no node labelling

label.wrap.width

a positive integer specifying wrap width of node labelling

label.wrap.lineheight

line height spacing for text in ggplot. By default it is 0.8

node.label.size

a character specifying which node attribute used for node label size

node.label.fontface

a character specifying which node attribute used for node label fontface ('plain', 'bold', 'italic', 'bold.italic')

node.label.color

a character specifying which node attribute used for the node label color

node.label.alpha

the 0-1 value specifying transparency of node labelling

node.label.padding

the padding around the labeled node

node.label.arrow

the arrow pointing to the labeled node

node.label.force

the repelling force between overlapping labels

node.shape

an integer specifying node shape or a character specifying which node attribute used for the node shape (no matter whether it is numeric or character)

node.shape.title

a character specifying the title for node shaping

node.xcoord

a vector specifying x coordinates. If NULL, it will be created using igraph::layout_with_kk

node.ycoord

a vector specifying y coordinates. If NULL, it will be created using igraph::layout_with_kk

node.color

a character specifying which node attribute used for node coloring

node.color.title

a character specifying the title for node coloring

colormap

short name for the colormap. It can be one of "jet" (jet colormap), "bwr" (blue-white-red colormap), "gbr" (green-black-red colormap), "wyr" (white-yellow-red colormap), "br" (black-red colormap), "yr" (yellow-red colormap), "wb" (white-black colormap), "rainbow" (rainbow colormap, that is, red-yellow-green-cyan-blue-magenta), and "ggplot2" (emulating ggplot2 default color palette). Alternatively, any hyphen-separated HTML color names, e.g. "lightyellow-orange" (by default), "blue-black-yellow", "royalblue-white-sandybrown", "darkgreen-white-darkviolet". A list of standard color names can be found in http://html-color-codes.info/color-names

ncolors

the number of colors specified over the colormap

zlim

the minimum and maximum values for which colors should be plotted

na.color

the color for NAs. By default, it is 'grey80'

node.size

either a vector specifying node size or a character specifying which node attribute used for the node size

node.size.title

a character specifying the title for node sizing

node.size.range

the range of actual node size

slim

the minimum and maximum values for which sizes should be plotted

title

a character specifying the title for the plot

edge.size

a numeric value specifying the edge size. By default, it is 0.5

edge.color

a character specifying which edge attribute defining the the edge colors

edge.color.alpha

the 0-1 value specifying transparency of edge colors

edge.curve

a numeric value specifying the edge curve. 0 for the straight line

edge.arrow

a numeric value specifying the edge arrow. By default, it is 2

edge.arrow.gap

a gap between the arrow and the node

Value

a ggplot object, appended with 'data_nodes' and 'data_edges'

Note

none

See Also

xA2Net

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Load the library
library(A2)
RData.location <- "http://galahad.well.ox.ac.uk/bigdata_dev/"

## Not run: 
# load REACTOME
# restricted to Immune System ('R-HSA-168256') or Signal Transduction ('R-HSA-162582')
g <- xRDataLoader(RData.customised='ig.REACTOME',
RData.location=RData.location)
neighs.out <- igraph::neighborhood(g, order=vcount(g),
nodes="R-HSA-168256", mode="out")
nodeInduced <- V(g)[unique(unlist(neighs.out))]$name
ig <- igraph::induced.subgraph(g, vids=nodeInduced)

# visualise the graph with vertices being color-coded
V(ig)$degree <- igraph::degree(ig)
gp <- xA2Net(g=ig, node.label='term_id', label.wrap.width=30,
node.label.size=2, node.label.color='black', node.label.alpha=0.8,
node.label.padding=0, node.label.arrow=0, node.label.force=1,
node.shape=19, node.xcoord='xcoord', node.ycoord='ycoord',
node.color='degree', node.color.title='Degree',
colormap='grey-orange-darkred', ncolors=64, zlim=c(0,10),
node.size.range=3,
edge.color="black",edge.color.alpha=0.3,edge.curve=0.05,edge.arrow.gap=0.02,
title='')
# advanced use: visualise the list of graphs
ls_ig <- list(ig, ig)
gp <- xA2Net(g=ls_ig, node.label='term_id', label.wrap.width=30,
node.label.size=2, node.label.color='black', node.label.alpha=0.8,
node.label.padding=0, node.label.arrow=0, node.label.force=1,
node.shape=19, node.xcoord='xcoord', node.ycoord='ycoord',
node.color='degree', node.color.title='Degree',
colormap='grey-orange-darkred', ncolors=64, zlim=c(0,10),
node.size.range=3,
edge.color="black",edge.color.alpha=0.3,edge.curve=0.05,edge.arrow.gap=0.02,
title='')

###########################
# visualise gene network
glayout <- igraph::layout_with_kk(g)
V(g)$xcoord <- glayout[,1]
V(g)$ycoord <- glayout[,2]
V(g)$degree <- igraph::degree(g)
gp <- xA2Net(g=g, node.label='name', node.label.size=2,
node.label.color='black', node.label.alpha=0.8, node.label.padding=0,
node.label.arrow=0, node.label.force=0.01, node.shape=19,
node.xcoord='xcoord', node.ycoord='ycoord', node.color='priority',
node.color.title='5-star\nrating', colormap='yellow-red', ncolors=64,
zlim=c(0,5), node.size='degree', node.size.title='Degree', slim=c(0,5),
edge.color="orange",edge.color.alpha=0.5,edge.curve=0,edge.arrow.gap=0.025,
title='')
gp_rating <- xA2Net(g=g, node.label='name', node.label.size=2,
node.label.color='black', node.label.alpha=0.8, node.label.padding=0.1,
node.label.arrow=0, node.label.force=0.01, node.shape=19,
node.xcoord='xcoord', node.ycoord='ycoord', node.color='priority',
node.color.title='5-star\nrating', colormap='white-yellow-red',
ncolors=64, zlim=c(0,5), node.size.range=5,
edge.color="orange",edge.color.alpha=0.3,edge.curve=0,edge.arrow.gap=0.02,
title='')

## End(Not run)

A2 documentation built on May 2, 2019, 5 p.m.

Related to xA2Net in A2...