[BioC] Rgraphviz: flexible node sizes

Fraser Sim fjsim at buffalo.edu
Fri Jul 9 15:45:22 CEST 2010


This is my usual workflow, but should work with any graphNEL object. The
code looks complex because my node labels sometimes have new line characters
"\n". The function basically takes the fontscale (12) and scales fontsizes
down to take into the longest label. Hope this helps.

g <- new("graphNEL", nodes = myNodes, edgeL = myEdges, edgemode="directed")
names(labels) = labels = nodes(g)
fixedsize = rep(FALSE, times=length(nodes(g))
fontscale = 12
fontsize = fontscale * max(nchar(unlist(strsplit(labels,"\n", fixed=TRUE))))
/
 sapply(labels, function(x) {
   max(nchar(unlist(strsplit(x,"\n", fixed=TRUE))))
 })
fontsize[is.infinite(fontsize)] = fontscale
names(fill) = names(shape) = names(fontsize) = names(width) = names(height)
= nodes(g)

Note: fill, shape, width & height are all vectors which I set to get custom
node shapes, sizes, and fill color.

g <- layoutGraph(g, layoutType = "dot")
nodeRenderInfo(g) = list(label = labels, shape = shape, fontsize = fontsize,
 height = height, lWidth = width/2, rWidth = width/2,
 fill = fill)
g <- renderGraph(g)

Cheers,
Fraser

-----Original Message-----
From: bioconductor-bounces at stat.math.ethz.ch
[mailto:bioconductor-bounces at stat.math.ethz.ch] On Behalf Of Quin Wills
Sent: Thursday, July 08, 2010 8:44 PM
To: bioconductor at stat.math.ethz.ch
Subject: Re: [BioC] Rgraphviz: flexible node sizes

Anybody?

On 6 July 2010 23:21, Quin Wills <qilin at quinwills.net> wrote:

> Hi
>
> As a long-term R/BIOC user, I still find Rgraphviz quite a challenge.
> Could somebody please help me with a workflow to allow nodes that adjust
to
> label sizes. This won't work for me:
>
> gr <- new("graphAM", cor.object)
> nodeRenderInfo(gr) <- list(fixedsize=FALSE)
> gr <- layoutGraph(gr)
> renderGraph(gr)
>
> My R and packages are up to date. I'm Ubuntu 8.04 LTS
>
> Thanks
>

	[[alternative HTML version deleted]]

_______________________________________________
Bioconductor mailing list
Bioconductor at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/bioconductor
Search the archives:
http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list