Hello List

Is is possible to place node labels below nodes rather than within them in Rgraphiviz? In the graph below I would like to plot labels below the nodes because many labels are too long to fit within the nodes.


library(GO.db)
library(GOstats)
library(Rgraphviz)

GOlist <- c('GO:0031994', 'GO:0043559', 'GO:0048186', 'GO:0048185', 'GO:0016362', 'GO:0070411', 'GO:0019838') # get interesting GOMF cats

# plot the sig GOMF and ancestors
testG <- GOGraph(GOlist, GOMFPARENTS)

# Put root node on the top, transpose adjacency matrix
testG <- as(t(as(testG, 'matrix')), 'graphNEL')

#plot the graph (coloured to show sig) with ancestors

# 1. get terms for labels
theTerms = as.character(sapply(mget(nodes(testG), GOTERM), Term)) #get the terms
names(theTerms) = nodes(testG) #name the terms

# 2. set up graph parameters
graph.par(list(nodes=list(label=theTerms, shape='rect', fontsize=36.0), edges=list(lwd=1)))


# 3. set up sig node pars
sigCol <- rep('lightgrey', length(GOlist)) # set a colour for the sigCats
sigShape <- rep('ellipse', length(GOlist)) # set a shape for the sigCats
sizeList <- rep(42, length(GOlist)) # set a character size for the sigCats

names(sigCol) <- names(sigShape) <- names(sizeList) <- GOlist # make named lists

#info for the nodes
width <- rep(14, length(nodes(testG)))#define a custom width
height <- rep(6, length(nodes(testG)))#define a custom height
names(width) = names(height) = nodes(testG)#make named vectors 

nodeAttrs <- list(label=theTerms, width=width, height=height)#use width & height for nodes and terms for labels

nodeRenderInfo(testG) <- list(label=theTerms, fill=sigCol, shape=sigShape, width=width, height=height, fontsize=sizeList) # put together in a list of lists

# render the plot
testLayout <- layoutGraph(testG, layoutType='dot')
renderGraph(testLayout)


best & thanks

iain

> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
 [5] LC_MONETARY=en_GB.utf8    LC_MESSAGES=en_GB.utf8   
 [7] LC_PAPER=C                LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] Rgraphviz_1.32.0      GOstats_2.20.0        graph_1.32.0         
[4] Category_2.20.0       GO.db_2.6.1           RSQLite_0.11.1       
[7] DBI_0.2-5             AnnotationDbi_1.16.13 Biobase_2.14.0       

loaded via a namespace (and not attached):
 [1] annotate_1.32.1   genefilter_1.36.0 GSEABase_1.16.0   IRanges_1.12.6   
 [5] RBGL_1.30.1       splines_2.14.2    survival_2.36-12  tools_2.14.2     
 [9] XML_3.9-4         xtable_1.7-0     
> 
	[[alternative HTML version deleted]]

