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)

plot(mygraph)


Thank you everyone for your help! I appreciate it!

Kind regards,
Greg

_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to