[BioC] fontsize in Rgraphviz

Mark W Kimpel mwkimpel at gmail.com
Thu Jan 31 04:41:59 CET 2008


Deepayan,

We are making progress. I just updated Rgraphviz-devel. Simply adjusting 
the way adjusting my parameters to "layoutGraph" as you suggested fixed 
the font size problem! I did not have to add it at the nodeRenderInfo 
stage. Attached is a postscript file documenting the results, which 
would look prettier if I had bothered to adjust the size of the output.

Unfortunately, now nAttrs$fillcolor is being ignored, even if it is 
added as an argument to noRenderInfo.

Also, I would very much like to use many of the other shapes available 
via graphviz. If I was willing to do some of the coding (I know some C), 
would you point me in the right direction so that I might provide a 
patch with more shapes?

Thanks,
Mark


Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 204-4202 Home (no voice mail please)

mwkimpel<at>gmail<dot>com

******************************************************************


Deepayan Sarkar wrote:
> On 1/30/08, Mark W Kimpel <mwkimpel at gmail.com> wrote:
>> Sorry for the complex prior example, I shouldn't write emails late at
>> night. Below is a self-contained, reproducible example.
>>
>> I've made some progress and can get the following script to flow without
>> error messages. The fontsize, however, is not varying as I believe it
>> should and when I substitute "ellipse" for circle the width and height
>> parameters do not appropriately effect the shape.
> 
> There are certain attributes which need to be supplied at the layout
> step, especially shape, width, and height, as without these the edges
> (which need to start from node boundaries) will not be placed
> properly. So, you need to supply nAttrs to layoutGraph as
> 
> x <- layoutGraph(g1, nodeAttrs = nAttrs)
> 
> Of course, it's not clear from the documentation that you can do this!
> 
>> I also do not understand where I can specify "neato" vs. "dot" for the
>> rendering layout.
> 
> Same goes for this; you can do
> 
> x <- layoutGraph(g1, nodeAttrs = nAttrs, layoutType = "neato")
> 
> The trick is to notice that the default layout function in
> 'layoutGraph' is 'layoutGraphviz', which is unexported, but you can
> get it's argument list by
> 
>> args(Rgraphviz:::layoutGraphviz)
> function (x, layoutType = "dot", name = "graph", recipEdges = "combined",
>     nodeAttrs = list(), edgeAttrs = list(), ...)
> 
> 
> Unfortunately, the fontsize doesn't seem to be retained in the result
> of layoutGraph, and I'm not sure yet if that's a bug in our wrapper or
> a limitation of the graphviz interface. We will look into it.
> 
>> Also, where to specify a title.
> 
> Generally speaking, our new model is that once the layout is done, you
> should be able to modify other attributes before rendering. These
> attributes are divided into three types: those for nodes, those for
> edges, and those for the whole graph, and these can be accessed and
> modified using nodeRenderInfo(), edgeRenderInfo(), and
> graphRenderInfo(), respectively.
> 
> So, to come back to your problem, once you have the layout done, you
> can modify the fontsize and title as follows:
> 
> nodeRenderInfo(x) <- list(fontsize = nAttrs$fontsize * 5)
> graphRenderInfo(x) <- list(main = "Main title")
> 
> and then finally render it with
> 
> renderGraph(x)
> 
> Obviously there are many warts still to be worked out.
> 
> -Deepayan
> 
>> Thanks, mark
>>
>>
>> ####################
>> require(Rgraphviz)
>> # Generate random graph
>> set.seed(123)
>> nodeNames <- letters[1:10]
>> M <- 1:4
>> g1 <- randomGraph(nodeNames, M, .2)
>>
>> nAttrs <- list()
>>
>> #node shapes
>> nAttrs$shape <- rep("circle", length(nodeNames))
>> names(nAttrs$shape )<- nodeNames
>>
>> #node width
>> nAttrs$width <-  rep(3, length(nodeNames))
>> names(nAttrs$width)<-nodeNames
>>
>> #node height
>> nAttrs$height <- rep(3, length(nodeNames))
>> names(nAttrs$height)<-nodeNames
>>
>> #node colors
>> nAttrs$fillcolor <-rep("black", length(nodeNames))
>> names(nAttrs$fillcolor) <- nodeNames
>>
>> #font color
>> nAttrs$fontcolor <- rep("white", length(nodeNames))
>> names(nAttrs$fontcolor)<-nodeNames
>>
>> #font size
>> nAttrs$fontsize <- rep(c(1, 2), (length(nodeNames)/2))
>> names(nAttrs$fontsize)<-nodeNames
>>
>> postscript(file="my.test.graph.ps", paper="special",width=4, height=5)
>> #set up graphics device
>> x <- layoutGraph(g1)
>> nodeRenderInfo(x) = nAttrs
>> renderGraph(x)
>> dev.off()## close the graphics device
>>
>>
>>
>> Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
>> Indiana University School of Medicine
>>
>> 15032 Hunter Court, Westfield, IN  46074
>>
>> (317) 490-5129 Work, & Mobile & VoiceMail
>> (317) 204-4202 Home (no voice mail please)
>>
>> mwkimpel<at>gmail<dot>com
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WS05 Acb.KEGG_SUBSET_Genes.FDR..Graph.ps
Type: application/postscript
Size: 22561 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/bioconductor/attachments/20080130/e431f4ab/attachment.ps 


More information about the Bioconductor mailing list