[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] vertex colors/size and path

From: Gregory Ryslik
Subject: [igraph] vertex colors/size and path
Date: Thu, 11 Oct 2012 13:54:25 -0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1

Hi Everyone,

I'm using the igraph package to plot paths through protein structures and had 2 questions:

Q1) For each protein, I find the shortest path through the protein and then make a graph. I then want to plot the protein in circular form as follows:

mygraph <- graph(edge.list)
plot(mygraph, layout = layout.circle)

However, what often happens is that there are a lot of vertices and that they all overlap. Is there a convenient way I can do two things: scale the vertices to so they become easier to read and then color the vertex in an increasingly darker shade as we progress through the graph? Further, I want the color progression to follow the edges, NOT the numeric vertex number. For instance, if my path was

1 -> 2 -> 5-> 6->4->3

I would want the colors to get progressively darker over the path above, not over the path 1->2->3->4->5->6. I realize I can do this with some for loops but I was wondering if perhaps there's a smarter way to do it in iGraph. I've uploaded a sample graph at alrig.com/code using the dput command if someone wants to play with an actual example. Further, is there a way I can automatically size the vertices so that they don't overlap?

Q2) This question is about the actual plot function. For each amino acid in my protein, I have an x-y-z position. However, when I set the correct attributes and plot, it doesn't seem that the perspective is correct. The easiest way to see this is running the code below which is supposed to print a cube of length 1 starting at the origin (0,0,0). As you can see the vertices are placed directly on top of each other. Is there a way for an angled view similar to scatterplot3d?

myedges <- cbind(c(1,2,3,4,8,7,6,5,4,3,1,2),c(2,3,4 ,1,7,6,5,8,5,6,8,7))
mygraph <- graph.edgelist(myedges)

xcoords <- c(0,1,1,0,0,1,1,0)
ycoords <- c(0,0,1,1,1,1,0,0)
zcoords <- c(0,0,0,0,1,1,1,1)

mygraph<- set.vertex.attribute(mygraph, "x", index=V(mygraph), xcoords)
mygraph<-set.vertex.attribute(mygraph, "y", index=V(mygraph), ycoords)
mygraph<-set.vertex.attribute(mygraph,"z",index = V(mygraph),zcoords)


Thank you everyone for your help! I appreciate it!

Kind regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]