The following 124 words could not be found in the dictionary of 615 words (including 615 LocalSpellingWords) and are highlighted below:

algorithm   amorphous   Analysis   and   attributes   be   bit   Bj1   Borr   Bth   by   can   chunk   clust   clusters   color   cols   command   connected   contains   dah   decompose   decomposed   deconstruct   delimited   described   dg   directed   display   Draw   each   element   figure   file   find   For   for   force   found   frame   from   fruchterman   function   G6459   G6843   generate   get   graph   happens   highlighting   identify   If   igraph   in   instance   interact   interactions   interest   interpretable   into   itself   iv   layout   list   look   main   map   match   matching   Mcm3   membership   my   name   names   Network   network   node   nodes   object   of   or   other   pieces   plot   Rab11   rainbow   read   Read   red   reingold   returns   rst   see   sep   set   size   sub   sure   tab   table   that   the   them   This   this   thus   to   To   un   unconnected   use   using   various   vertex   Vertices   vertices   We   what   whereby   with   yet   you   You   your  

Clear message

Network Analysis in R with igraph

A network can be described by a list of nodes, or vertices that interact with each other, thus a tab-delimited list:

Bj1     dah
Bj1     rst
Borr    CG6459
Borr    Rab11
BthD    CG6843
BthD    Mcm3

Read a table into R and generate a network graph:

data <- read.table(file="my_interactions.txt",sep="\t")

# create a graph data object
g <- graph.data.frame(data, directed=F)

# draw the network!
plot(g)

It can look a bit amorphous and un interpretable. Draw it with a "force-directed algorithm:

plot(g,layout=layout.fruchterman.reingold)

If your network contains un-connected pieces, you can find them using the deconstruct function.

dg <- decompose.graph(g)

This returns a list, whereby each element is itself a graph data object. (If your network doesn't have any unconnected pieces, I'm not sure what happens yet.) You can use see the sub pieces in the main network figure by highlighting them in color.

To do this, you use the V() command to access and set various attributes of the Vertices. For instance, the first chunk of my decomposed network is found in dg[[1]]. We can get the node names from this and set a display color for the matching names in the main network object:

# take the sub network to a new variable for clarity
a <- dg[[1]]

# create an index vector to match names
iv <- match(V(a)$name, V(g)$name)

# set the vertex colors using the index vector
V(g)$color[iv] <- "red"

# draw the map
plot(g,layout=layout.fruchterman.reingold,vertex.size=5)

It can also be of interest to identify clusters in the network map.

# find clusters
clust <- clusters(g)

# get a list of colors equal in length to the number of clusters
cols <- rainbow(33)

# set the colors of each cluster based on membership
# member ship is counted from 0, whereas arrays are indexed from 1
# so use +1 in the array index
V(g)$color <- cols[clust$membership+1]

Network (last edited 2011-11-04 22:22:24 by ChrisSeidel)