Question: Rgraphviz: flexible node sizes
0
gravatar for Quin Wills
8.9 years ago by
Quin Wills80
Quin Wills80 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]]
rgraphviz • 991 views
ADD COMMENTlink modified 8.9 years ago • written 8.9 years ago by Quin Wills80
Answer: Rgraphviz: flexible node sizes
0
gravatar for Quin Wills
8.9 years ago by
Quin Wills80
Quin Wills80 wrote:
Anybody? On 6 July 2010 23:21, Quin Wills <qilin@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]]
ADD COMMENTlink written 8.9 years ago by Quin Wills80
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@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
ADD REPLYlink written 8.9 years ago by Fraser Sim270
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 125 users visited in the last hour