problem with manipulating graphs created from dot files read by agread()
2
0
Entering edit mode
Alexis Dinno ▴ 20
@alexis-dinno-5665
Last seen 10.3 years ago
Hi, I would love to integrate interoperability with Rgraphviz in my LoopAnalyst package on CRAN. Unfortunately, Rgraphiz does not seem to behave well with graphs read from dot files. The dot file (http://doyenne.com/personal/files/Levins.dot) can be read an rendered by agread(), but does not turn out so nicely, presumably because of how node, edge and arrowhead attributes are handled. Here's how dot from graphviz renders my graph: http://doyenne.com/personal/files/Levins.png But if in R I type: g <- agread("/Users/Alexis/Desktop/Levins.dot") plot(g) I get: http://doyenne.com/personal/files/Levins2.png So I would like to edit the various parameters according to Rgraphviz, BUT, I get the following errors with the following commands: edgemode(g) <- "directed" Error in function (classes, fdef, mtable) : unable to find an inherited method for function ?edgemode<-? for signature ?"Ragraph", "character"? edgeRenderInfo(g) <- list(arrowhead=c("R~R"="dot", "R~H"="normal", "H~R"="dot", "H~x"="normal", "H~y"="normal", "x~H"="dot", "y~H"="dot", "y~y"="dot"), arrowtail="open") Error in function (classes, fdef, mtable) : unable to find an inherited method for function ?isDirected? for signature ?"Ragraph"? Can you help? Thank you! Alexis Here's the content of Levins.dot: digraph G { graph [bgcolor = "transparent", size = "18!,18!", nodesep="1", ranksep="1", rankdir="LR"]; node [fixedsize=true, fontname="Sans", fontsize="70.85", shape=circle, height="2", width="2", style="setlinewidth(5)"]; edge [style="setlinewidth(4)", arrowsize=3]; "R" [color="#8000BF"]; "R" -> "R" [color="#8000BF", arrowhead=dot]; "R" -> "H" [color="#8000BF"]; "H" [color="#0000BF"]; "H" -> "R" [color="#0000BF", arrowhead=dot]; "H" -> "x" [color="#0000BF"]; "H" -> "y" [color="#0000BF"]; "x" [color="#00BF00"]; "x" -> "H" [color="#00BF00", arrowhead=dot]; "y" [color="#BF0000"]; "y" -> "H" [color="#BF0000", arrowhead=dot]; "y" -> "y" [color="#BF0000", arrowhead=dot]; }
Rgraphviz Rgraphviz • 2.9k views
ADD COMMENT
0
Entering edit mode
@kasper-daniel-hansen-2979
Last seen 18 months ago
United States
The issue is that agread() returns an object of class Ragraph and not a standard graph. Ragraph is really an internal class. Unfortunately, you cannot convert from Ragraph to a standard graph (which is quite unfortunately). What you are doing, is using the edgeRenderInfo() paradigm as described in the vignette "newRgraphvizInterface". This works on graph objects, but not Ragraph. Instead, you need to use the old style layout functions, like plot( , nodeAttrs = list(), edgeAttrs = list()) Let me end by saying that your request is completely reasonable and it is unfortunate that it is not easy to do. Recently, I spent a lot of time fixing up the C code for Rgraphviz and the next step is cleaning up the R code. However, due to other commitments, this may take a while to materialize. Best, Kasper On Wed, Dec 19, 2012 at 4:32 PM, Alexis Dinno <alexis.dinno at="" pdx.edu=""> wrote: > Hi, > > I would love to integrate interoperability with Rgraphviz in my LoopAnalyst > package on CRAN. Unfortunately, Rgraphiz does not seem to behave well with > graphs read from dot files. The dot file > (http://doyenne.com/personal/files/Levins.dot) can be read an rendered by > agread(), but does not turn out so nicely, presumably because of how node, edge > and arrowhead attributes are handled. > > Here's how dot from graphviz renders my graph: > http://doyenne.com/personal/files/Levins.png > > > But if in R I type: > g <- agread("/Users/Alexis/Desktop/Levins.dot") > plot(g) > > I get: http://doyenne.com/personal/files/Levins2.png > > So I would like to edit the various parameters according to Rgraphviz, BUT, I > get the following errors with the following commands: > > edgemode(g) <- "directed" > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function ?edgemode<-? for > signature ?"Ragraph", "character"? > > > edgeRenderInfo(g) <- list(arrowhead=c("R~R"="dot", "R~H"="normal", > "H~R"="dot", "H~x"="normal", "H~y"="normal", "x~H"="dot", "y~H"="dot", > "y~y"="dot"), arrowtail="open") > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function ?isDirected? for > signature ?"Ragraph"? > > > Can you help? > > Thank you! > > Alexis > > > Here's the content of Levins.dot: > > > digraph G { > graph [bgcolor = "transparent", size = "18!,18!", nodesep="1", ranksep="1", > rankdir="LR"]; > node [fixedsize=true, fontname="Sans", fontsize="70.85", shape=circle, > height="2", width="2", style="setlinewidth(5)"]; > edge [style="setlinewidth(4)", arrowsize=3]; > "R" [color="#8000BF"]; > "R" -> "R" [color="#8000BF", arrowhead=dot]; > "R" -> "H" [color="#8000BF"]; > "H" [color="#0000BF"]; > "H" -> "R" [color="#0000BF", arrowhead=dot]; > "H" -> "x" [color="#0000BF"]; > "H" -> "y" [color="#0000BF"]; > "x" [color="#00BF00"]; > "x" -> "H" [color="#00BF00", arrowhead=dot]; > "y" [color="#BF0000"]; > "y" -> "H" [color="#BF0000", arrowhead=dot]; > "y" -> "y" [color="#BF0000", arrowhead=dot]; > } > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > 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
On 12/20/2012 03:07 PM, Kasper Daniel Hansen wrote: > The issue is that agread() returns an object of class Ragraph and not > a standard graph. Ragraph is really an internal class. > Unfortunately, you cannot convert from Ragraph to a standard graph > (which is quite unfortunately). > > What you are doing, is using the > edgeRenderInfo() > paradigm as described in the vignette "newRgraphvizInterface". This > works on graph objects, but not Ragraph. > > Instead, you need to use the old style layout functions, like > plot( , nodeAttrs = list(), edgeAttrs = list()) I played around with this just a little this morning and found toFile() to be useful, e.g., toFile(g, filename="/tmp/foo.svg", fileType="svg") to recreate the output from graphviz (fileType from graphvizCapabilities()$deviceType), and things like > edgeData(g, "R", "R", "arrowhead") R~R "dot" > edgeData(g, "R", "R", "arrowhead") <- "normal" (as documented on ?Ragraph) to manipulate. Martin > > Let me end by saying that your request is completely reasonable and it > is unfortunate that it is not easy to do. Recently, I spent a lot of > time fixing up the C code for Rgraphviz and the next step is cleaning > up the R code. However, due to other commitments, this may take a > while to materialize. > > Best, > Kasper > > On Wed, Dec 19, 2012 at 4:32 PM, Alexis Dinno <alexis.dinno at="" pdx.edu=""> wrote: >> Hi, >> >> I would love to integrate interoperability with Rgraphviz in my LoopAnalyst >> package on CRAN. Unfortunately, Rgraphiz does not seem to behave well with >> graphs read from dot files. The dot file >> (http://doyenne.com/personal/files/Levins.dot) can be read an rendered by >> agread(), but does not turn out so nicely, presumably because of how node, edge >> and arrowhead attributes are handled. >> >> Here's how dot from graphviz renders my graph: >> http://doyenne.com/personal/files/Levins.png >> >> >> But if in R I type: >> g <- agread("/Users/Alexis/Desktop/Levins.dot") >> plot(g) >> >> I get: http://doyenne.com/personal/files/Levins2.png >> >> So I would like to edit the various parameters according to Rgraphviz, BUT, I >> get the following errors with the following commands: >> >> edgemode(g) <- "directed" >> Error in function (classes, fdef, mtable) : >> unable to find an inherited method for function ?edgemode<-? for >> signature ?"Ragraph", "character"? >> >> >> edgeRenderInfo(g) <- list(arrowhead=c("R~R"="dot", "R~H"="normal", >> "H~R"="dot", "H~x"="normal", "H~y"="normal", "x~H"="dot", "y~H"="dot", >> "y~y"="dot"), arrowtail="open") >> Error in function (classes, fdef, mtable) : >> unable to find an inherited method for function ?isDirected? for >> signature ?"Ragraph"? >> >> >> Can you help? >> >> Thank you! >> >> Alexis >> >> >> Here's the content of Levins.dot: >> >> >> digraph G { >> graph [bgcolor = "transparent", size = "18!,18!", nodesep="1", ranksep="1", >> rankdir="LR"]; >> node [fixedsize=true, fontname="Sans", fontsize="70.85", shape=circle, >> height="2", width="2", style="setlinewidth(5)"]; >> edge [style="setlinewidth(4)", arrowsize=3]; >> "R" [color="#8000BF"]; >> "R" -> "R" [color="#8000BF", arrowhead=dot]; >> "R" -> "H" [color="#8000BF"]; >> "H" [color="#0000BF"]; >> "H" -> "R" [color="#0000BF", arrowhead=dot]; >> "H" -> "x" [color="#0000BF"]; >> "H" -> "y" [color="#0000BF"]; >> "x" [color="#00BF00"]; >> "x" -> "H" [color="#00BF00", arrowhead=dot]; >> "y" [color="#BF0000"]; >> "y" -> "H" [color="#BF0000", arrowhead=dot]; >> "y" -> "y" [color="#BF0000", arrowhead=dot]; >> } >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at r-project.org >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793
ADD REPLY
0
Entering edit mode
Paul Murrell ▴ 30
@paul-murrell-5669
Last seen 10.1 years ago
New Zealand
Hi There's a 'gridGraphviz' package on R-Forge that is in very early stages; it has lots of holes, but I have plugged a couple so that you get a reasonable result for your example below. With the latest version on ... https://r-forge.r-project.org/projects/gridgraph/ ... try the following code ... library(gridGraphviz) g <- agread("Levins.dot") grid.graph(g) ... which gets the edges better and the following ... grid.newpage() pushViewport(viewport(width=.9, height=.9, gp=gpar(lex=4))) grid.graph(g, newpage=FALSE, nodesOnTop=FALSE) ... makes the "arrows" look better. Paul On 20/12/12 10:32, Alexis Dinno wrote: > Hi, > > I would love to integrate interoperability with Rgraphviz in my LoopAnalyst > package on CRAN. Unfortunately, Rgraphiz does not seem to behave well with > graphs read from dot files. The dot file > (http://doyenne.com/personal/files/Levins.dot) can be read an rendered by > agread(), but does not turn out so nicely, presumably because of how node, edge > and arrowhead attributes are handled. > > Here's how dot from graphviz renders my graph: > http://doyenne.com/personal/files/Levins.png > > > But if in R I type: > g <- agread("/Users/Alexis/Desktop/Levins.dot") > plot(g) > > I get: http://doyenne.com/personal/files/Levins2.png > > So I would like to edit the various parameters according to Rgraphviz, BUT, I > get the following errors with the following commands: > > edgemode(g) <- "directed" > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function ?edgemode<-? for > signature ?"Ragraph", "character"? > > > edgeRenderInfo(g) <- list(arrowhead=c("R~R"="dot", "R~H"="normal", > "H~R"="dot", "H~x"="normal", "H~y"="normal", "x~H"="dot", "y~H"="dot", > "y~y"="dot"), arrowtail="open") > Error in function (classes, fdef, mtable) : > unable to find an inherited method for function ?isDirected? for > signature ?"Ragraph"? > > > Can you help? > > Thank you! > > Alexis > > > Here's the content of Levins.dot: > > > digraph G { > graph [bgcolor = "transparent", size = "18!,18!", nodesep="1", ranksep="1", > rankdir="LR"]; > node [fixedsize=true, fontname="Sans", fontsize="70.85", shape=circle, > height="2", width="2", style="setlinewidth(5)"]; > edge [style="setlinewidth(4)", arrowsize=3]; > "R" [color="#8000BF"]; > "R" -> "R" [color="#8000BF", arrowhead=dot]; > "R" -> "H" [color="#8000BF"]; > "H" [color="#0000BF"]; > "H" -> "R" [color="#0000BF", arrowhead=dot]; > "H" -> "x" [color="#0000BF"]; > "H" -> "y" [color="#0000BF"]; > "x" [color="#00BF00"]; > "x" -> "H" [color="#00BF00", arrowhead=dot]; > "y" [color="#BF0000"]; > "y" -> "H" [color="#BF0000", arrowhead=dot]; > "y" -> "y" [color="#BF0000", arrowhead=dot]; > } > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
ADD COMMENT
0
Entering edit mode
Hi Paul, > There's a 'gridGraphviz' package on R-Forge that is in very early stages; it > has lots of holes, but I have plugged a couple so that you get a reasonable > result for your example below. > > With the latest version on ... > > https://r-forge.r-project.org/projects/gridgraph/ It is not remotely clear how to install packages from this link. However, I found version 0.1 on CRAN. > ... try the following code ... > > library(gridGraphviz) > g <- agread("Levins.dot") > grid.graph(g) > > ... which gets the edges better and the following ... But which does not draw the nodes or their labels at all. > grid.newpage() > pushViewport(viewport(width=.9, height=.9, gp=gpar(lex=4))) > grid.graph(g, newpage=FALSE, nodesOnTop=FALSE) > > ... makes the "arrows" look better. Not on my system (v. 2.15.2 x86_64-apple-darwin9.8.0/x86_64 (64-bit)): > grid.graph(g, newpage=FALSE, nodesOnTop=FALSE) Error in grid.graph(g, newpage = FALSE, nodesOnTop = FALSE) : unused argument(s) (nodesOnTop = FALSE) But thank you for bringing your incipient package to my attention! :)
ADD REPLY
0
Entering edit mode
Dear Alexis when you open the URL below and follow the link "SCM Repository" you will see instruction for how to download it, via subversion. Works fine for me. Best wishes Wolfgang Il giorno Dec 21, 2012, alle ore 9:46 PM, alexis.dinno at pdx.edu ha scritto: > > Hi Paul, > >> There's a 'gridGraphviz' package on R-Forge that is in very early stages; it has lots of holes, but I have plugged a couple so that you get a reasonable result for your example below. >> >> With the latest version on ... >> >> https://r-forge.r-project.org/projects/gridgraph/ > > It is not remotely clear how to install packages from this link. However, I found version 0.1 on CRAN. > >> ... try the following code ... >> >> library(gridGraphviz) >> g <- agread("Levins.dot") >> grid.graph(g) >> >> ... which gets the edges better and the following ... > > But which does not draw the nodes or their labels at all. > >> grid.newpage() >> pushViewport(viewport(width=.9, height=.9, gp=gpar(lex=4))) >> grid.graph(g, newpage=FALSE, nodesOnTop=FALSE) >> >> ... makes the "arrows" look better. > > Not on my system (v. 2.15.2 x86_64-apple-darwin9.8.0/x86_64 (64-bit)): > >> grid.graph(g, newpage=FALSE, nodesOnTop=FALSE) > Error in grid.graph(g, newpage = FALSE, nodesOnTop = FALSE) : > unused argument(s) (nodesOnTop = FALSE) > > > But thank you for bringing your incipient package to my attention! :) > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
ADD REPLY

Login before adding your answer.

Traffic: 882 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