xLayout | R Documentation |
xLayout
is supposed to define graph node coordinates according
to igraph- or sna-style layout.
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", "graphlayouts.layout_with_stress", "graphlayouts.layout_as_backbone", "gephi.forceatlas2"), seed = 825, flip = F )
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"), or graphlayouts-style layout ("graphlayouts.layout_with_stress","graphlayouts.layout_as_backbone"), or ForeceAtlas2 layout used in Dephi ("gephi.forceatlas2") |
seed |
an integer specifying the seed |
flip |
logical to indicate whether x- and y-coordiates flip. By default, it sets to false |
It returns an igraph object, appended by node attributes including "xcoord" for x-coordinates, "ycoord" for y-coordiates.
xGGnetwork
## 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") ## do together layouts <- c("layout_with_fr","gplot.layout.fruchtermanreingold","layout_with_kk","gplot.layout.kamadakawai", "gephi.forceatlas2") ls_ig <- lapply(layouts, function(x) xLayout(ig, layout=x)) names(ls_ig) <- layouts gp <- xGGnetwork(ls_ig, node.xcoord='xcoord', node.ycoord='ycoord', ncolumns=5) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.