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