Questons about 'igraph' package

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Questons about 'igraph' package

karena
Hi,

I am using 'igraph' to make some plots. The problem I got is that I don't know how to label the nodes with gene names.

My sample code:

## suppose I have 100 gene (nodes) ##
---------------------------------------------------------------------------
graph <- set.vertex.attribute(graph, "color", value=c(rep(c('green','red'),50)))
graph <- set.vertex.attribute(graph, "name", value=genelist)
tkplot(graph)
----------------------------------------------------------------------------
The 'color' attribute does work, the nodes are red and green, but the 'name' attribute doesn't work, I still have the numeric id on each node (0-99).

Can anyone tell me how to solve this problem?

Thank you,

Karena
Reply | Threaded
Open this post in threaded view
|

Re: Questons about 'igraph' package

Gábor Csárdi-2
The 'name' attribute is not used for vertex labels by default. If you
want to use it, you need to set it as the 'label' attribute as well,
or supply them in the function call:

tkplot(graph, vertex.label=V(graph)$name)

Best,
Gabor

On Wed, Sep 14, 2011 at 7:11 PM, karena <[hidden email]> wrote:

> Hi,
>
> I am using 'igraph' to make some plots. The problem I got is that I don't
> know how to label the nodes with gene names.
>
> My sample code:
>
> ## suppose I have 100 gene (nodes) ##
> ---------------------------------------------------------------------------
> graph <- set.vertex.attribute(graph, "color",
> value=c(rep(c('green','red'),50)))
> graph <- set.vertex.attribute(graph, "name", value=genelist)
> tkplot(graph)
> ----------------------------------------------------------------------------
> The 'color' attribute does work, the nodes are red and green, but the 'name'
> attribute doesn't work, I still have the numeric id on each node (0-99).
>
> Can anyone tell me how to solve this problem?
>
> Thank you,
>
> Karena
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Questons-about-igraph-package-tp3814338p3814338.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Gabor Csardi <[hidden email]>     MTA KFKI RMKI

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Questons about 'igraph' package

karena
Thank you so much, Gabor.
It works well!