fontsize in Rgraphviz
2
0
Entering edit mode
Mark W Kimpel ▴ 830
@mark-w-kimpel-2027
Last seen 10.3 years ago
I would like to vary the font size of node labels in Rgraphviz as I have been varying node size by fold change magnitude. Unfortunately, many attempts have failed and I continue to get the same font size. Here is my code followed by sessionInfo() nAttrs$fontsize<-floor(22 * nodeWidth) nodeWidth is a vector of widths which vary by node according to fold change. This works nicely, but font size does not. help? thanks, Mark > sessionInfo() R version 2.6.1 (2007-11-26) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US .UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US. UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8 ;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Rgraphviz_1.16.0 graph_1.16.1 loaded via a namespace (and not attached): [1] cluster_1.11.9 tools_2.6.1 -- 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
Rgraphviz Rgraphviz • 2.7k views
ADD COMMENT
0
Entering edit mode
@lilongisb-sibch-1725
Last seen 10.3 years ago
hits=-2.5 tests=BAYES_00,FORGED_RCVD_HELO,SPF_HELO_PASS,SPF_PASS,UNPAR SEABLE_RELAY X-USF-Spam-Flag: NO Here are a few things to check: (1) fontsize is of "point size", so I'd check "floor(22*nodeWidth)" really yealds different values; (2) it depends on how you render the graph, if you render via graphviz, e.g., output to files, this attribute is honored by graphviz; if you render interactively, it's done by R; (3) for testing purpose, you can try this value on edges to see if it makes any difference. Li > I would like to vary the font size of node labels in Rgraphviz as I have > been varying node size by fold change magnitude. Unfortunately, many > attempts have failed and I continue to get the same font size. Here is > my code followed by sessionInfo() > > nAttrs$fontsize<-floor(22 * nodeWidth) > > nodeWidth is a vector of widths which vary by node according to fold > change. This works nicely, but font size does not. > > help? > > thanks, > Mark > > > sessionInfo() > R version 2.6.1 (2007-11-26) > x86_64-unknown-linux-gnu > > locale: > LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_ US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_U S.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF -8;LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] Rgraphviz_1.16.0 graph_1.16.1 > > loaded via a namespace (and not attached): > [1] cluster_1.11.9 tools_2.6.1 > -- > > 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 > > _______________________________________________ > 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 COMMENT
0
Entering edit mode
Li, I am outputting to a ps file and viewing in Adobe Illustrator. Here are the actual values that are set for fontsize but which are being ignored in the output. As a test, I have also set all fontsize to "48" as I know this is a common fontsize, it also was ignored. Mark Browse[1]> nAttrs$fontsize Tgfb3 Kdr Dusp5 Mapt Dusp1 Ptpn5 Map3k1 Ntrk1 Insr Mapk1 14 14 12 12 16 11 12 13 11 13 Flt1 Prkcc Ccr5 Stk3 Crk Cxcr4 Il11ra1 Pdgfa Ntrk2 Pdgfra 12 11 16 13 13 13 12 12 29 12 Il6st Fgfr2 Fos Mapk8 Elk1 Nr4a1 Dusp6 Ctf1 Taok2 Ntf3 16 12 28 12 11 19 12 11 12 12 Akt2 Pla2g4a Max Jund Pik3cb Jun Tgfb2 Crkl Kitl Pak2 11 12 11 58 11 12 18 11 15 11 Mapk12 13 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 ****************************************************************** Li Long wrote: > Here are a few things to check: > > (1) fontsize is of "point size", so I'd check "floor(22*nodeWidth)" really > yealds different values; > (2) it depends on how you render the graph, if you render via graphviz, > e.g., output to files, this attribute is honored by graphviz; if you > render interactively, it's done by R; > (3) for testing purpose, you can try this value on edges to see if it > makes any difference. > > Li > > >> I would like to vary the font size of node labels in Rgraphviz as I have >> been varying node size by fold change magnitude. Unfortunately, many >> attempts have failed and I continue to get the same font size. Here is >> my code followed by sessionInfo() >> >> nAttrs$fontsize<-floor(22 * nodeWidth) >> >> nodeWidth is a vector of widths which vary by node according to fold >> change. This works nicely, but font size does not. >> >> help? >> >> thanks, >> Mark >> >> > sessionInfo() >> R version 2.6.1 (2007-11-26) >> x86_64-unknown-linux-gnu >> >> locale: >> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en _US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_ US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UT F-8;LC_IDENTIFICATION=C >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> other attached packages: >> [1] Rgraphviz_1.16.0 graph_1.16.1 >> >> loaded via a namespace (and not attached): >> [1] cluster_1.11.9 tools_2.6.1 >> -- >> >> 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 >> >> _______________________________________________ >> 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 REPLY
0
Entering edit mode
@deepayan-sarkar-1436
Last seen 14 months ago
United States
On 1/25/08, Mark W Kimpel <mwkimpel at="" gmail.com=""> wrote: > I would like to vary the font size of node labels in Rgraphviz as I have > been varying node size by fold change magnitude. Unfortunately, many > attempts have failed and I continue to get the same font size. Here is > my code followed by sessionInfo() > > nAttrs$fontsize<-floor(22 * nodeWidth) > > nodeWidth is a vector of widths which vary by node according to fold > change. This works nicely, but font size does not. We have been playing an alternative rendering interface. With bioc-devel, I get varying node sizes and label size using set.seed(123) V <- letters[1:10] M <- 1:4 g1 <- randomGraph(V, M, .2) cex.list <- runif(length(nodes(g1))) names(cex.list) <- nodes(g1) width.list <- seq(0.2, 2, length = length(nodes(g1))) names(width.list) <- nodes(g1) x <- layoutGraph(g1, nodeAttrs = list(width = width.list)) nodeRenderInfo(x) = list(fontsize = 50 * cex.list) renderGraph(x) I'm not sure if this will work with Bioc 2.1. -Deepayan
ADD COMMENT
0
Entering edit mode
Deepayan, Thanks for your efforts, it looks like you are working on major changes to Rgraphviz for BioC 2.2. Your example worked for me (with R-devel), but I can't get my own function to work. Below is my code, or what I hope is the relevant part, with the error output. It looks to me like layoutGraph is looking for a way to render a "neato" graph and can't find it, but I'm probably wrong. It also looks to me like you are making some major changes to the way node and edge attributes are passed to the rendering engine, so maybe the parameters I used to pass to plot(my.graphNEL) are not working. Let me know what you think I am doing wrong. Mark [1] "created graphAM" [1] "created graphNEL" Error in layoutGraphresult.gN, layout.param, layoutfun = "dot", nodeAttrs = nAttrs, : could not find function "layoutFun" Enter a frame number, or 0 to exit 1: result.matrix.graph.func(result.matrix = cocite.mat.sig, no.edges = TRUE, m 2: switch(file.output, ps = { 3: layoutGraphresult.gN, layout.param, layoutfun = "dot", nodeAttrs = nAttrs, Selection: #font size if(file.output != "screen"){ #cex.vec <-floor(22 * nodeAttrsresult.gN)$nodeWidth) cex.vec <- rep(48, lengthnodesresult.gN))) } else {cex.vec <-rep(18, lengthnodeAttrsresult.gN)$nodeWidth))} names(cex.vec) <- nodesresult.gN) fileName<-paste(experiment, contrast, "FDR", FDR, "Graph", "ps", sep=".") postscript(file=fileName, paper="special",width=width, height=height) #set up graphics device x <- layoutGraphresult.gN, layout.param, layoutfun = "dot", nodeAttrs = nAttrs, edgeAttrs = eAttrs, main=paste("Experiment:", experiment, "; Contrast:", contrast,"; FDR:", FDR, ";Total Genes:", lengthnodesresult.gN)), "; Total Connections:", roundaveNumEdgesresult.gN)*lengthnodesresult.gN)), digits=0),"; Min. connections ==", min.edges, "; Min. citations per connection ==", min.cites, "; Additional search criteria:", termAdditional, sep=" ")) nodeRenderInfo(x) = list(fontsize = cex.vec) 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 ****************************************************************** Deepayan Sarkar wrote: > On 1/25/08, Mark W Kimpel <mwkimpel at="" gmail.com=""> wrote: >> I would like to vary the font size of node labels in Rgraphviz as I have >> been varying node size by fold change magnitude. Unfortunately, many >> attempts have failed and I continue to get the same font size. Here is >> my code followed by sessionInfo() >> >> nAttrs$fontsize<-floor(22 * nodeWidth) >> >> nodeWidth is a vector of widths which vary by node according to fold >> change. This works nicely, but font size does not. > > We have been playing an alternative rendering interface. With > bioc-devel, I get varying node sizes and label size using > > > set.seed(123) > V <- letters[1:10] > M <- 1:4 > g1 <- randomGraph(V, M, .2) > > cex.list <- runif(length(nodes(g1))) > names(cex.list) <- nodes(g1) > > width.list <- seq(0.2, 2, length = length(nodes(g1))) > names(width.list) <- nodes(g1) > > x <- layoutGraph(g1, nodeAttrs = list(width = width.list)) > nodeRenderInfo(x) = list(fontsize = 50 * cex.list) > renderGraph(x) > > > > I'm not sure if this will work with Bioc 2.1. > > -Deepayan >
ADD REPLY
0
Entering edit mode
On 1/29/08, Mark W Kimpel <mwkimpel at="" gmail.com=""> wrote: > Deepayan, > > Thanks for your efforts, it looks like you are working on major changes > to Rgraphviz for BioC 2.2. > > Your example worked for me (with R-devel), but I can't get my own > function to work. Below is my code, or what I hope is the relevant part, > with the error output. It looks to me like layoutGraph is looking for a > way to render a "neato" graph and can't find it, but I'm probably wrong. > It also looks to me like you are making some major changes to the way > node and edge attributes are passed to the rendering engine, so maybe > the parameters I used to pass to plot(my.graphNEL) are not working. > > Let me know what you think I am doing wrong. Mark The error messages are not telling me much. Can you provide a reproducible example (preferably something simple)? -Deepayan > > [1] "created graphAM" > [1] "created graphNEL" > Error in layoutGraphresult.gN, layout.param, layoutfun = "dot", > nodeAttrs = nAttrs, : > could not find function "layoutFun" > > Enter a frame number, or 0 to exit > > 1: result.matrix.graph.func(result.matrix = cocite.mat.sig, no.edges = > TRUE, m > 2: switch(file.output, ps = { > 3: layoutGraphresult.gN, layout.param, layoutfun = "dot", nodeAttrs = > nAttrs, > > Selection: > > #font size > if(file.output != "screen"){ > #cex.vec <-floor(22 * nodeAttrsresult.gN)$nodeWidth) > cex.vec <- rep(48, lengthnodesresult.gN))) > } else {cex.vec <-rep(18, lengthnodeAttrsresult.gN)$nodeWidth))} > names(cex.vec) <- nodesresult.gN) > > fileName<-paste(experiment, contrast, "FDR", FDR, "Graph", > "ps", sep=".") > postscript(file=fileName, paper="special",width=width, > height=height) #set up graphics device > x <- layoutGraphresult.gN, layout.param, layoutfun = "dot", > nodeAttrs = nAttrs, edgeAttrs = eAttrs, > main=paste("Experiment:", experiment, "; Contrast:", > contrast,"; FDR:", FDR, > ";Total Genes:", lengthnodesresult.gN)), "; Total > Connections:", > roundaveNumEdgesresult.gN)*lengthnodesresult.gN)), > digits=0),"; Min. connections ==", > min.edges, "; Min. citations per connection ==", > min.cites, "; Additional search criteria:", > termAdditional, sep=" ")) > nodeRenderInfo(x) = list(fontsize = cex.vec) > 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 > > ****************************************************************** > > > Deepayan Sarkar wrote: > > On 1/25/08, Mark W Kimpel <mwkimpel at="" gmail.com=""> wrote: > >> I would like to vary the font size of node labels in Rgraphviz as I have > >> been varying node size by fold change magnitude. Unfortunately, many > >> attempts have failed and I continue to get the same font size. Here is > >> my code followed by sessionInfo() > >> > >> nAttrs$fontsize<-floor(22 * nodeWidth) > >> > >> nodeWidth is a vector of widths which vary by node according to fold > >> change. This works nicely, but font size does not. > > > > We have been playing an alternative rendering interface. With > > bioc-devel, I get varying node sizes and label size using > > > > > > set.seed(123) > > V <- letters[1:10] > > M <- 1:4 > > g1 <- randomGraph(V, M, .2) > > > > cex.list <- runif(length(nodes(g1))) > > names(cex.list) <- nodes(g1) > > > > width.list <- seq(0.2, 2, length = length(nodes(g1))) > > names(width.list) <- nodes(g1) > > > > x <- layoutGraph(g1, nodeAttrs = list(width = width.list)) > > nodeRenderInfo(x) = list(fontsize = 50 * cex.list) > > renderGraph(x) > > > > > > > > I'm not sure if this will work with Bioc 2.1. > > > > -Deepayan > > >
ADD REPLY
0
Entering edit mode
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. I also do not understand where I can specify "neato" vs. "dot" for the rendering layout. Also, where to specify a title. 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 ****************************************************************** Deepayan Sarkar wrote: > On 1/29/08, Mark W Kimpel <mwkimpel at="" gmail.com=""> wrote: >> Deepayan, >> >> Thanks for your efforts, it looks like you are working on major changes >> to Rgraphviz for BioC 2.2. >> >> Your example worked for me (with R-devel), but I can't get my own >> function to work. Below is my code, or what I hope is the relevant part, >> with the error output. It looks to me like layoutGraph is looking for a >> way to render a "neato" graph and can't find it, but I'm probably wrong. >> It also looks to me like you are making some major changes to the way >> node and edge attributes are passed to the rendering engine, so maybe >> the parameters I used to pass to plot(my.graphNEL) are not working. >> >> Let me know what you think I am doing wrong. Mark > > The error messages are not telling me much. Can you provide a > reproducible example (preferably something simple)? > > -Deepayan > >> [1] "created graphAM" >> [1] "created graphNEL" >> Error in layoutGraphresult.gN, layout.param, layoutfun = "dot", >> nodeAttrs = nAttrs, : >> could not find function "layoutFun" >> >> Enter a frame number, or 0 to exit >> >> 1: result.matrix.graph.func(result.matrix = cocite.mat.sig, no.edges = >> TRUE, m >> 2: switch(file.output, ps = { >> 3: layoutGraphresult.gN, layout.param, layoutfun = "dot", nodeAttrs = >> nAttrs, >> >> Selection: >> >> #font size >> if(file.output != "screen"){ >> #cex.vec <-floor(22 * nodeAttrsresult.gN)$nodeWidth) >> cex.vec <- rep(48, lengthnodesresult.gN))) >> } else {cex.vec <-rep(18, lengthnodeAttrsresult.gN)$nodeWidth))} >> names(cex.vec) <- nodesresult.gN) >> >> fileName<-paste(experiment, contrast, "FDR", FDR, "Graph", >> "ps", sep=".") >> postscript(file=fileName, paper="special",width=width, >> height=height) #set up graphics device >> x <- layoutGraphresult.gN, layout.param, layoutfun = "dot", >> nodeAttrs = nAttrs, edgeAttrs = eAttrs, >> main=paste("Experiment:", experiment, "; Contrast:", >> contrast,"; FDR:", FDR, >> ";Total Genes:", lengthnodesresult.gN)), "; Total >> Connections:", >> roundaveNumEdgesresult.gN)*lengthnodesresult.gN)), >> digits=0),"; Min. connections ==", >> min.edges, "; Min. citations per connection ==", >> min.cites, "; Additional search criteria:", >> termAdditional, sep=" ")) >> nodeRenderInfo(x) = list(fontsize = cex.vec) >> 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 >> >> ****************************************************************** >> >> >> Deepayan Sarkar wrote: >>> On 1/25/08, Mark W Kimpel <mwkimpel at="" gmail.com=""> wrote: >>>> I would like to vary the font size of node labels in Rgraphviz as I have >>>> been varying node size by fold change magnitude. Unfortunately, many >>>> attempts have failed and I continue to get the same font size. Here is >>>> my code followed by sessionInfo() >>>> >>>> nAttrs$fontsize<-floor(22 * nodeWidth) >>>> >>>> nodeWidth is a vector of widths which vary by node according to fold >>>> change. This works nicely, but font size does not. >>> We have been playing an alternative rendering interface. With >>> bioc-devel, I get varying node sizes and label size using >>> >>> >>> set.seed(123) >>> V <- letters[1:10] >>> M <- 1:4 >>> g1 <- randomGraph(V, M, .2) >>> >>> cex.list <- runif(length(nodes(g1))) >>> names(cex.list) <- nodes(g1) >>> >>> width.list <- seq(0.2, 2, length = length(nodes(g1))) >>> names(width.list) <- nodes(g1) >>> >>> x <- layoutGraph(g1, nodeAttrs = list(width = width.list)) >>> nodeRenderInfo(x) = list(fontsize = 50 * cex.list) >>> renderGraph(x) >>> >>> >>> >>> I'm not sure if this will work with Bioc 2.1. >>> >>> -Deepayan >>> >
ADD REPLY
0
Entering edit mode
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
ADD REPLY
0
Entering edit mode
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
ADD REPLY
0
Entering edit mode
hits=-2.5 tests=BAYES_00,FORGED_RCVD_HELO,SPF_HELO_PASS,SPF_PASS,UNPAR SEABLE_RELAY X-USF-Spam-Flag: NO > 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. This should be honored if you render the graph via graphviz, instead of R. > 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), Again, if you render the graph via graphviz, you can use any of the shapes for nodes that graphviz supports (more than 30 of them). At this time, you can specify your own node shapes if you render it via R, but not via graphviz. just the opposite to the above. > would you point me in the right direction so that I might provide a > patch with more shapes? Li
ADD REPLY
0
Entering edit mode
Hi Mark, to get you all the way, take a look at this: require(Rgraphviz) # Generate random graph set.seed(123) nodeNames <- letters[1:10] M <- 1:4 g1 <- randomGraph(nodeNames, M, .2) nAttrs <- list() #node width nAttrs$width <- rep(3, length(nodeNames)) names(nAttrs$width)<-nodeNames #node height nAttrs$height <- rep(3, length(nodeNames)) names(nAttrs$height)<-nodeNames #font size fontsize <- rep(c(1, 2), (length(nodeNames)/2)) names(fontsize)<-nodeNames #layout and render x <- layoutGraph(g1, nodeAttr=nAttrs) nodeRenderInfo(x) <- list(cex=fontsize) renderGraph(x, graph.pars=list(nodes=list(fill="black", textCol="white"))) I didn't set the node shape at all, because the default for dot is to use "ellipse", and since you fix your node widths and node heights to the same size, this boils down to a circle. I also set the fill and text color as attributes in the graph.pars argument to renderGraph, but Deepayan's suggestion works, too. The only difference is, that the latter permanently assigns the colors to the graph object x, while the former takes effect only for the current rendering operation. nodeRenderInfo(x) <- list(cex=fontsize, fill="black", textCol="white") renderGraph(x) fillcolor is ignored in your example because in the new rendering API this parameter is called fill (we tried to stay closer to R's base graphic parameter names, and thinking of that now, maybe we should rename textCol to font.col or something similar). I just uploaded a much more detailed vignette and some bug fixes, and these changes should be available soon in Rgraphviz version 1.17.12. If you know how to access the svn repository you can get this update immediately. In the Vignette there are also tables of the available parameters for nodes, edges and the whole graph and I will update the documentation accordingly ASAP. Everything that affects the graph layout can still be passed on to Graphviz as nodeAttrs, edgeAttrs or attrs arguments. For instance, the following would change the node shapes: nAttrs$shape <- c("circle", "rect", rep(c("ellipse", "box"), 4)) names(nAttrs$shape )<- nodeNames x <- layoutGraph(g1, nodeAttr=nAttrs) renderGraph(x) Again, since widths and heights of the nodes are constant, there's no difference between ellipse and circle (box and rect are synonyms, anyways). You can see the difference here: nAttrs$width <- rep(6, length(nodeNames)) names(nAttrs$width)<-nodeNames x <- layoutGraph(g1, nodeAttr=nAttrs) renderGraph(x) Another Graphviz parameter that I find quite useful is fixedsize. If this is set to TRUE (the default) all nodes will be forced to have the same size unless manually changed. For FALSE, the node sizes will be computed from the labels, so longer labels will create larger nodes. As far as I remeber, this has to be given to the attrs argument, something like this: attrs <- list(node=list(fixedsize=FALSE)) x <- layoutGraph(g1, nodeAttr=nAttrs, attrs=attrs) I'm affaid I can't really point you to the C code for the Graphviz interaction (we tried to stay clear of that, it's so easy to break things there...), but agopen is the workhorse in Rgraphviz to talk to the Graphviz library. Starting there and working your way though the code should quickly get you to the interesting C calls. Once you've figured out a way to access the different shapes in Graphviz and how to get the coordinates back into R, it is straightforward to render them. Everything that is stored in the Ragraph object (the return value of agopen) can be accessed by our rendering API. Cheers, Florian Mark W Kimpel schrieb: > 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 >> > -------------------------------------------------------------------- ---- > > _______________________________________________ > 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 -- Florian Hahne, PhD Computational Biology Program Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-3148 fhahne at fhcrc.org
ADD REPLY

Login before adding your answer.

Traffic: 1038 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6