igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] vertex colors/size and path

 From: Gábor Csárdi Subject: Re: [igraph] vertex colors/size and path Date: Thu, 11 Oct 2012 14:23:37 -0400

```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

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

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.

Best,
Gabor

[...]

--
Gabor Csardi <address@hidden>     MTA KFKI RMKI

```

reply via email to

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