[Top][All Lists]

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

Re: [igraph] vertex colors/size and path

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

Hi Gabor,

Thank you for your comments. Re Q2, thanks for the information, I'll stop trying to get that to work then!

Re Q1:

The reason I want to do it as follows is that it becomes easy to see when the shortest path deviates from the linear path. Since each protein has a predetermined start -> end path (specifically, 1->2->3->...->N) by following the arrows (and if the colors follow the arrows) it's easy to see exactly where the jumps occur.

I'm having a bit of trouble recreating the exact code I had last night, but ideally, I would want the vertices to go in a circle from 1-167. As the first jump occurs from 10->13, I would want there to be an arrow from 10->13 and then the colors to hop over the 11-12. Thus even if the arrow is hidden behind another vertex, the colors would show the hop. In the end, by looking at the colors in the circle, one should be able to visualize where the jumps occur and where the contiguous blocks are without having to look for jumps in a table.

Thanks again for your help!

On 10/11/2012 2:23 PM, Gábor Csárdi wrote:
Hi Greg,

On Thu, Oct 11, 2012 at 1:54 PM, Gregory Ryslik <address@hidden> wrote:
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?
May I ask why you are plotting a graph that is a simple path? The
structure does not give you much information, in fact the only
information is the order of the vertices (i.e. labels), so you could
just list the labels in a table.

You have 166 vertices, so yes, you can make them smaller to avoid
overlap, but what will you see then? E.g. try

G <- dget("http://alrig.com/code/mygraph.RData";)
plot(G, layout=layout.circle, vertex.size=1, vertex.label.cex=.1,

it does not matter whether you color them or not IMHO.

Probably you could make the labels bigger and rotate them
individually, so that they would go around like a clock dial. But even
if you do this, a simple table of labels is better IMHO.

As for the darker colors, calculate the distance from the root node
and index a palette with this distance. E.g. darker layers in a tree:

tree <- graph.tree(10)
dist <- shortest.paths(tree, 1)+1
pal <- rev(gray(seq(1/2, 1, length=max(dist))))
plot(tree, layout=layout.reingold.tilford, vertex.color=pal[dist])

There is unfortunately no function to check if vertices 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?
plot.igraph does not support 3d plotting, unfortunately. You can try
rglplot(), although it is probably not what you want, if you are
interested in something similar to scatterplot3d.



reply via email to

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