Rgraphviz edge weight question
5
0
Entering edit mode
@kimpel-mark-w-727
Last seen 9.6 years ago
I am visualizing graphNEL objects using Rgraphviz. I would like to set the thickness of the edge lines, in points, proportional to the edge weights. Is this an attribute that can be set? I have looked through the Rgraphviz documentation as well as the Graphviz website without finding an answer. Thanks, Mark Mark W. Kimpel MD ? Official Business Address: ? Department of Psychiatry Indiana University School of Medicine Biotechnology, Research, & Training Center 1345 W. 16th Street Indianapolis, IN ?46202 ? Preferred Mailing Address: ? 15032 Hunter Court Westfield, IN? 46074 ? (317) 490-5129 Home, Work, & Mobile 1-(317)-536-2730 FAX
Rgraphviz Rgraphviz • 1.1k views
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 3 months ago
EMBL European Molecular Biology Laborat…
Hi Mark, I believe that is not currently possible (Rgraphviz 1.11.0) without changing some of the code in Rgraphviz (or overwriting exisitings methods with your own ones). Seth, Jeff, please correct me if I am wrong. The method "lines" for "AgEdge" objects (defined in Rgraphviz/R/Ragraph.R) has and honours a parameter "lwd". Its default is the global option par("lwd"). However, that parameter is not set (or read from any kind of graph attribute or function call parameter) by the plot method for the "graphNEL" class (which in turn calls the plot method for the class "Ragraph"). Both of these are defined in Rgraphviz/R/graph.R. It should be relatively straightforward to modify these latter two methods to honor an element "lwd" in the edgeAttrs list and pass it on to "lines" (for "AgEdge"). Mark, if you feel adventurous, you could try to contribute a patch for doing this? Also, in the Bioconductor book on p.368 and Fig. 21.15 there is an example how can really do anything you want... Best wishes Wolfgang PS - for the purists, when I said method for class X, I meant a method whose signature contains X in the first position. Kimpel, Mark William wrote: > I am visualizing graphNEL objects using Rgraphviz. I would like to set the thickness of the edge lines, in points, proportional to the edge weights. Is this an attribute that can be set? I have looked through the Rgraphviz documentation as well as the Graphviz website without finding an answer. > > Thanks, > > Mark > > Mark W. Kimpel MD > > > Official Business Address: > > Department of Psychiatry > Indiana University School of Medicine > Biotechnology, Research, & Training Center > 1345 W. 16th Street > Indianapolis, IN 46202 > > Preferred Mailing Address: > > 15032 Hunter Court > Westfield, IN 46074 > > (317) 490-5129 Home, Work, & Mobile > 1-(317)-536-2730 FAX > > _______________________________________________ > 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 -- ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 9.6 years ago
"Kimpel, Mark William" <mkimpel at="" iupui.edu=""> writes: > Well, I got it figured out after all. The patch to "agopen", which > allows the slots "lwd" and "lty" to be passed from a graph to an Ragraph > object, is below. Turned out to be pretty simple once I understood what > I was doing! Excellent! Can you send me the complete .R file(s) you've modified (off list as attachement)? I'd like to apply your changes to the devel branch. In the future, or even now if you are feeling interested, the easiest way to send such improvements or fixes is via "patch files" also known as "diffs". And the easiest way to produce them is to use the version control software we use, Subversion (svn). There is info on how to get and use svn on the BioC wiki: http://wiki.fhcrc.org/bioc/SvnHowTo After installing it, you could obtain a working copy of the Rgraphviz devel source code like this: svn checkout --username=readonly --password=readonly https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Rgraphviz Then make changes right in that working copy. To produce a diff, use 'svn diff' and capture the output into a file. By sending diffs, the developer on the other end doesn't have to hand edit files to recreate your changes and that makes things faster and less error-prone. But if the above maxes out your programmer geek allowance, I understand and encourage you and others to send fixes via email as you just did. Best Wishes, + seth
ADD COMMENT
0
Entering edit mode
@kimpel-mark-w-727
Last seen 9.6 years ago
Wolfgang, I spent some time today trying to figure out how to accomplish what you outlined below and I believe there is a roadblock with the C code of .Call("Rgraphviz_agopen"....) . In agopen, the lwd slot of edgeAttrs looks like $lwd Ace~Cat Ace~Cs Adcyap1~Avp Adcyap1~Gal Adcyap1~Ghrh Akt1~Igf1 Akt1~Insr Akt1~Src Akt1~Vegfa Avp~Gal Avp~Gast Avp~Ghrh 4 4 4 4 4 4 4 4 4 4 4 4 Which is correct for the test code I am using. Once the C function is called, attr(attr(g,"AgEdge")[[1]], "lwd") numeric(0) which indicates to me that the C code is not translating the "lwd" parameter from the graph to the Ragraph object. Jeff, am I correct? If so, is this something that you can address? If so, while you are at it, could you also get the function to pass along the "lty" parameter as well? If I'm all wet here, please pardon my ignorance, I'm a novice programmer! Mark Mark W. Kimpel MD (317) 490-5129 Home, Work, & Mobile 1-(317)-536-2730 FAX -----Original Message----- From: Wolfgang Huber [mailto:huber@ebi.ac.uk] Sent: Sunday, June 11, 2006 1:22 PM To: Kimpel, Mark William Cc: Bioconductor Newsgroup Subject: Re: [BioC] Rgraphviz edge weight question Hi Mark, I believe that is not currently possible (Rgraphviz 1.11.0) without changing some of the code in Rgraphviz (or overwriting exisitings methods with your own ones). Seth, Jeff, please correct me if I am wrong. The method "lines" for "AgEdge" objects (defined in Rgraphviz/R/Ragraph.R) has and honours a parameter "lwd". Its default is the global option par("lwd"). However, that parameter is not set (or read from any kind of graph attribute or function call parameter) by the plot method for the "graphNEL" class (which in turn calls the plot method for the class "Ragraph"). Both of these are defined in Rgraphviz/R/graph.R. It should be relatively straightforward to modify these latter two methods to honor an element "lwd" in the edgeAttrs list and pass it on to "lines" (for "AgEdge"). Mark, if you feel adventurous, you could try to contribute a patch for doing this? Also, in the Bioconductor book on p.368 and Fig. 21.15 there is an example how can really do anything you want... Best wishes Wolfgang PS - for the purists, when I said method for class X, I meant a method whose signature contains X in the first position. Kimpel, Mark William wrote: > I am visualizing graphNEL objects using Rgraphviz. I would like to set the thickness of the edge lines, in points, proportional to the edge weights. Is this an attribute that can be set? I have looked through the Rgraphviz documentation as well as the Graphviz website without finding an answer. > > Thanks, > > Mark > > Mark W. Kimpel MD > > > Official Business Address: > > Department of Psychiatry > Indiana University School of Medicine > Biotechnology, Research, & Training Center > 1345 W. 16th Street > Indianapolis, IN 46202 > > Preferred Mailing Address: > > 15032 Hunter Court > Westfield, IN 46074 > > (317) 490-5129 Home, Work, & Mobile > 1-(317)-536-2730 FAX > > _______________________________________________ > 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 -- ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber
ADD COMMENT
0
Entering edit mode
@kimpel-mark-w-727
Last seen 9.6 years ago
Well, I got it figured out after all. The patch to "agopen", which allows the slots "lwd" and "lty" to be passed from a graph to an Ragraph object, is below. Turned out to be pretty simple once I understood what I was doing! Mark agopen<-function (graph, name, nodes, edges, kind = NULL, layout = TRUE, layoutType = c("dot", "neato", "twopi", "circo", "fdp"), attrs = list(), nodeAttrs = list(), edgeAttrs = list(), subGList = list(), edgeMode = edgemode(graph), recipEdges = c("combined", "distinct")) { layoutType <- match.arg(layoutType) recipEdges <- match.arg(recipEdges) attrs <- getDefaultAttrs(attrs, layoutType) checkAttrs(attrs) if ((missing(graph)) && (missing(edgeMode))) stop("Must pass in either 'graph' or 'edgeMode'") if (((graphvizVersion() == "2.4") || (graphvizVersion() == "2.6")) && (layoutType == "neato")) { singletonGraph <- any(sapply(connComp(graph), function(x) length(x) <= 1)) if (singletonGraph == TRUE) stop("There is a bad interaction between ", "Rgraphviz and Graphviz 2.4 involving ", "graphs with singleton nodes laid out with neato.\n", "Hopefully we can find a workaround for ", "this situation, but until then you can ", "use Graphviz versions earlier or later than 2.4.") } if (missing(nodes)) { if (missing(graph)) stop("Must supply either parameter 'graph' or 'nodes'") nodes <- buildNodeList(graph, nodeAttrs, subGList, attrs$node) } if (missing(edges)) { if (missing(graph)) stop("Must supply either parameter 'graph' or 'edges'") edges <- buildEdgeList(graph, recipEdges, edgeAttrs, subGList, attrs$edge) } if (is.null(kind)) { outK <- switch(edgeMode, undirected = 0, directed = 1, 0) } else { outK <- switch(kind, AGRAPH = 0, AGDIGRAPH = 1, AGRAPHSTRICT = 2, AGDIGRAPHSTRICT = 3, stop(paste("Incorrect kind parameter:", kind))) } g <- .Call("Rgraphviz_agopen", as.character(name), as.integer(outK), as.list(nodes), as.list(edges), as.list(attrs), as.list(subGList), PACKAGE = "Rgraphviz") g at layoutType <- layoutType g at edgemode <- edgeMode ###################################################################### # #Below is a patch that allows lwd (line width) and lty (line type) to be set in same manner color is set if (layout) {g<-layoutGraph(g)} if (!is.null(edgeAttrs$lwd)) { for (i in 1:length(edgeAttrs$lwd)) { attr(attr(g,"AgEdge")[[i]], "lwd")<-edgeAttrs$lwd[i] } } if (!is.null(edgeAttrs$lty)) { for (i in 1:length(edgeAttrs$lty)) { attr(attr(g,"AgEdge")[[i]], "lty")<-edgeAttrs$lty[i] } } return(g) } Mark W. Kimpel MD (317) 490-5129 Home, Work, & Mobile 1-(317)-536-2730 FAX -----Original Message----- From: Wolfgang Huber [mailto:huber@ebi.ac.uk] Sent: Sunday, June 11, 2006 1:22 PM To: Kimpel, Mark William Cc: Bioconductor Newsgroup Subject: Re: [BioC] Rgraphviz edge weight question Hi Mark, I believe that is not currently possible (Rgraphviz 1.11.0) without changing some of the code in Rgraphviz (or overwriting exisitings methods with your own ones). Seth, Jeff, please correct me if I am wrong. The method "lines" for "AgEdge" objects (defined in Rgraphviz/R/Ragraph.R) has and honours a parameter "lwd". Its default is the global option par("lwd"). However, that parameter is not set (or read from any kind of graph attribute or function call parameter) by the plot method for the "graphNEL" class (which in turn calls the plot method for the class "Ragraph"). Both of these are defined in Rgraphviz/R/graph.R. It should be relatively straightforward to modify these latter two methods to honor an element "lwd" in the edgeAttrs list and pass it on to "lines" (for "AgEdge"). Mark, if you feel adventurous, you could try to contribute a patch for doing this? Also, in the Bioconductor book on p.368 and Fig. 21.15 there is an example how can really do anything you want... Best wishes Wolfgang PS - for the purists, when I said method for class X, I meant a method whose signature contains X in the first position. Kimpel, Mark William wrote: > I am visualizing graphNEL objects using Rgraphviz. I would like to set the thickness of the edge lines, in points, proportional to the edge weights. Is this an attribute that can be set? I have looked through the Rgraphviz documentation as well as the Graphviz website without finding an answer. > > Thanks, > > Mark > > Mark W. Kimpel MD > > > Official Business Address: > > Department of Psychiatry > Indiana University School of Medicine > Biotechnology, Research, & Training Center > 1345 W. 16th Street > Indianapolis, IN 46202 > > Preferred Mailing Address: > > 15032 Hunter Court > Westfield, IN 46074 > > (317) 490-5129 Home, Work, & Mobile > 1-(317)-536-2730 FAX > > _______________________________________________ > 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 -- ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 9.6 years ago
Seth Falcon <sfalcon at="" fhcrc.org=""> writes: > "Kimpel, Mark William" <mkimpel at="" iupui.edu=""> writes: > >> Well, I got it figured out after all. The patch to "agopen", which >> allows the slots "lwd" and "lty" to be passed from a graph to an Ragraph >> object, is below. Turned out to be pretty simple once I understood what >> I was doing! > > Excellent! Can you send me the complete .R file(s) you've modified > (off list as attachement)? I'd like to apply your changes to the > devel branch. Mark's changes have been added to Rgraphviz 1.11.1 which should be available from the 1.9 repository tomorrow afternoon. Please test. We should also update the documentation to describe how to set lty and lwd and possible consider adding to one of the Rgraphviz vignettes so that this gets demonstrated. + seth
ADD COMMENT

Login before adding your answer.

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