Learn R Programming

XGR (version 1.1.5)

xLayout: Function to define graph node coordinates according to igraph- or sna-style layout

Description

xLayout is supposed to define graph node coordinates according to igraph- or sna-style layout.

Usage

xLayout(g, layout = c("layout_nicely", "layout_randomly",
"layout_in_circle", "layout_on_sphere", "layout_with_fr",
"layout_with_kk", "layout_as_tree", "layout_with_lgl",
"layout_with_graphopt", "layout_with_sugiyama", "layout_with_dh",
"layout_with_drl", "layout_with_gem", "layout_with_mds",
"layout_as_bipartite", "gplot.layout.adj", "gplot.layout.circle",
"gplot.layout.circrand", "gplot.layout.eigen",
"gplot.layout.fruchtermanreingold", "gplot.layout.geodist",
"gplot.layout.hall", "gplot.layout.kamadakawai", "gplot.layout.mds",
"gplot.layout.princoord", "gplot.layout.random", "gplot.layout.rmds",
"gplot.layout.segeo", "gplot.layout.seham", "gplot.layout.spring",
"gplot.layout.springrepulse", "gplot.layout.target"), seed = 825)

Arguments

g

an object of class "igraph" (or "graphNEL") for a graph

layout

a character specifying graph layout function. This character can be used to indicate igraph-style layout ("layout_nicely","layout_randomly","layout_in_circle","layout_on_sphere","layout_with_fr","layout_with_kk","layout_as_tree","layout_with_lgl","layout_with_graphopt","layout_with_sugiyama","layout_with_dh","layout_with_drl","layout_with_gem","layout_with_mds","layout_as_bipartite"), or sna-style layout ("gplot.layout.adj","gplot.layout.circle","gplot.layout.circrand","gplot.layout.eigen","gplot.layout.fruchtermanreingold","gplot.layout.geodist","gplot.layout.hall","gplot.layout.kamadakawai","gplot.layout.mds","gplot.layout.princoord","gplot.layout.random","gplot.layout.rmds","gplot.layout.segeo","gplot.layout.seham","gplot.layout.spring","gplot.layout.springrepulse","gplot.layout.target")

seed

an integer specifying the seed

Value

It returns an igraph object, appended by node attributes including "xcoord" for x-coordinates, "ycoord" for y-coordiates.

See Also

xGGnetwork

Examples

Run this code
# NOT RUN {
# Load the library
library(XGR)
RData.location <- "http://galahad.well.ox.ac.uk/bigdata/"

# load REACTOME
# restricted to Immune System ('R-HSA-168256') or Signal Transduction ('R-HSA-162582')
g <- xRDataLoader('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)

# compare Fruchterman and Reingold force-directed placement algorithm
## based on igraph layout
ig1 <- xLayout(ig, layout="layout_with_fr")
gp1 <- xGGnetwork(ig1, node.xcoord="xcoord", node.ycoord="ycoord")
## based on sna layout
ig2 <- xLayout(ig, layout="gplot.layout.fruchtermanreingold")
gp2 <- xGGnetwork(ig2, node.xcoord="xcoord", node.ycoord="ycoord")

# compare Kamada-Kawai force-directed placement algorithm
## based on igraph layout
ig1 <- xLayout(ig, layout="layout_with_kk")
gp1 <- xGGnetwork(ig1, node.xcoord="xcoord", node.ycoord="ycoord")
## based on sna layout
ig2 <- xLayout(ig, layout="gplot.layout.kamadakawai")
gp2 <- xGGnetwork(ig2, node.xcoord="xcoord", node.ycoord="ycoord")
# }

Run the code above in your browser using DataLab