Gene Ontology graphs: root at the top?
2
0
Entering edit mode
@de-bondt-an-7114-prdbe-1572
Last seen 9.7 years ago
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/bioconductor/attachments/20060118/ 54d5c51d/attachment.pl
• 303 views
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 9.7 years ago
On 18 Jan 2006, ADBONDT at prdbe.jnj.com wrote: > > Dear BioC users, > > Is it possible to make a hierarchical graph with the root at the > top? I'm not sure how easy it is to manipulate that aspect of the layout. However, you're best bet may be to search the mail archives for the graphviz project. This thread seems relevant: https://mailman.research.att.com/pipermail/graphviz- interest/2005q4/002839.html -- + seth
ADD COMMENT
0
Entering edit mode
@de-bondt-an-7114-prdbe-1572
Last seen 9.7 years ago
Dear Adrian, Thanks a lot for this efficient solution which results in exactly what I had in mind! Regards, An -----Original Message----- From: Adrian Alexa [mailto:adrian.alexa@gmail.com] Sent: Wednesday, 18 January 2006 9:50 To: De Bondt, An-7114 [PRDBE] Subject: Re: [BioC] Gene Ontology graphs: root at the top? Hi, I think what you need to do is to reverse the edges of the graph (to go from the root to more specific nodes) when plotting the graph. To change the direction of the edges in your graph you can use: > basic_graph <- GOGraph(goid, GOBPPARENTS) > basic_graph <- as(t(as(basic_graph, 'matrix')), 'graphNEL') that is, you compute the adjacency matrix and then by transposing it you change the direction of the edges. You should use the as() function for small graphs since this transformation depends quadratically on the number of nodes in the graph. For larger graphs you can use the graph2SparseM() and sparseM2Graph() functions from the SparseM package. I'm also working with GO graphs and I use the following function for changing the direction of the edges: reverseArch <- function(dirGraph, useAlgo = 'sparse', useWeights = T) { if(edgemode(dirGraph) != 'directed') stop('The graph is not directed. Nothing to do') if(numEdges(dirGraph) == 0) { cat('Nothing to do:\n') return(dirGraph) } if(useAlgo == 'sparse') { nodNames <- nodes(dirGraph) ret.gr <- sparseM2Graph(t(graph2SparseM(dirGraph, useWeights)), nodNames) edgemoderet.gr) <- 'directed' returnret.gr) } return(as(t(as(dirGraph, 'matrix')), 'graphNEL')) } I hope that this helped, Adrian Alexa On 1/18/06, De Bondt, An-7114 [PRDBE] <adbondt at="" prdbe.jnj.com=""> wrote: > > Dear BioC users, > > Is it possible to make a hierarchical graph with the root at the top? > > The code I used so far is something like: > > library(GOstats) > library(Rgraphviz) > goid <- c("GO:0006882", "GO:0016049") > basic_graph <- GOGraph(goid, GOBPPARENTS) > Attrs <- list() > node_color <- c(rep("red",length(nodes(basic_graph)))) > Attrs$fillcolor <- node_color > node_fontsize <- c(rep(40,length(nodes(basic_graph)))) > Attrs$fontsize <- node_fontsize > node_shape <- rep("ellipse", length(nodes(basic_graph))) > Attrs$shape <- node_shape > node_fixedsize <- rep(FALSE, length(nodes(basic_graph))) > Attrs$fixedsize <- node_fixedsize > Attrs <- lapply(Attrs, function(x) { > names(x) <- nodes(basic_graph) > x > }) > basic_nodes <- buildNodeList(basic_graph, nodeAttrs = Attrs) > basic_edges <- buildEdgeList(basic_graph) > colored_graph <- agopen(name = "foo", nodes = basic_nodes, edges = > basic_edges, edgeMode = "undirected") > plot(colored_graph) > This last line will show a graph with the root at the bottom and the most > specific GOs at the top. Also plot(basic_graph) will show such a graph (but > with the standard attributes like white nodes in the shape of a circle etc). > I would like to show it up side down (root at the top). > I can specify a layout when plotting the object called "basic_graph" using > the plot() function. The layouts I know are dot (default), neato, twopi, > circo and fdp. However, these options do not result in what I have in mind. > So far, I have not yet found the parameter(s) which define(s) the position > of a node (e.g. x,y coordinates) on the plot. Could anyone give me a hint? > Thanks in advance! > Best regards, > An > Scientist Functional Genomics > > > > > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > -- Adrian Alexa Max-Planck-Institut fuer Informatik Stuhlsatzenhausweg 85 / Room 513 66123 Saarbruecken, Germany
ADD COMMENT

Login before adding your answer.

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