Entering edit mode
daniel jupiter
▴
80
@daniel-jupiter-3011
Last seen 10.2 years ago
Hi all,
I'm attempting to use Rgraphviz to do some plotting.
There is no problem in producing the plots, but I would like to modify
font
sizes in the resulting graph, and this appears tricky.
The simple fontsize setting in makeNodeAttrs seems to have no effect.
There appear to have been some changes to Rgraphviz itself, recently,
but I
have no concept of how these changes might impact the Ragraph related
objects and code.
Any suggestions as to how to get fonts to change size, while also
setting
fixedsize to FALSE?
Note: I have looked at documentation for Rgraphviz, and its new
interface. I
have looked at the old interface as well. And I appear to be lost.
Best regards,
Dan Jupiter.
library(GO.db)
library(GOstats)
library(KEGG.db)
library(annotate)
library(org.Rn.eg.db)
library("Rgraphviz")
library("RBGL")
library("graph")
library("RColorBrewer")
library("geneplotter")
library("RbcBook1")
# Just some dummy genes to play with.
bkg=dbGetQuery(org.Rn.eg_dbconn(), "SELECT * from genes")
bkg=bkg$gene_id[1:1000]
test=bkg[1:10]
# Builds hypergparams object.
params <- new("GOHyperGParams", geneIds = test,
universeGeneIds = bkg,annotation="org.Rn.eg.db",
conditional = FALSE, categoryName="GO", ontology="CC")
# Runs the test
MyHyperG=hyperGTest(params)
# Collect all GO IDs and terms
xx <- as.list(GOTERM)
GOIDS=0
GOTERMS=0
# Place them into easily accessible arrays.
for(i in 1:length(xx)){
GOIDS[i]=GOID(xx[[i]])
GOTERMS[i]=Term(xx[[i]])
}
# NEL graph object
gGO <- goDag( MyHyperG )
# Graph NEL attributes (node attribute graph object)
nAgo <- makeNodeAttrs(gGO, shape="ellipse", label=nodes(gGO),
fillcolor =
"white" , fontsize=30)
# Ragraph object
agGO <- agopen(gGO, recipEdges="distinct", layoutType="dot",
nodeAttrs=nAgo,
name="")
# Get node info from Ragraph object and store as agraph node object
agNO <- AgNode(agGO)
# Color nodes below p-value cutoff
for(i in seq(along=agNO)) {
# Grab the current node name,
nm <- labelText(txtLabel(agNO[[i]]))
# Search for that name within the list of pvalues.
mn <- match(nm, names(pvalues(MyHyperG)))
# Also find the term in the lists of terms and IDs.
termMatch=match(nm, GOIDS)
# If we've found a match in our pvalue list.
if(!is.na(mn)) { # match
# If we're below pvalue, color red, otherwise color white.
agNO[[i]]@fillcolor <- ifelse( as.vector(pvalues(MyHyperG))[mn] <
MyHyperG@pvalueCutoff, "#e31a1c", "#edf8fb")
#agNO[[i]]@txtLabel@labelText <-
paste(signif(pvalues(MyHyperG)[mn],
2)) # print pvalue node labels
# agNO[[i]]@txtLabel@labelText <- substr(
names(pvalues(MyHyperG))[mn],
7, 10 ) # print GOid node labels
# agNO[[i]]@txtLabel@labelText <- paste(GOIDS[termMatch], "Number
of
genes", as.character(counter),sep=" ")
# If we're below the pvalue, we want the number of genes annotated by
the
term.
if(as.vector(pvalues(MyHyperG))[mn] < MyHyperG@pvalueCutoff){
# This is a list of all gene IDs in the universe annotated by
this
term.
x=gGO@nodeData@data[[i]][1]$geneIds
counter=0
for(j in 1:length(x)){
ifis.na(match(x[j], test))){
counter=counter+1
}
}
# Build the label.
agNO[[i]]@txtLabel@labelText <-paste(GOIDS[termMatch], "Number
of
genes", as.character(counter),sep=" ")
}
else{
agNO[[i]]@txtLabel@labelText <- GOIDS[termMatch]
}
}
else { # no match
agNO[[i]]@fillcolor <- "white"
agNO[[i]]@txtLabel@labelText <- ""
}
}
# Update Ragraph object's AgNode slot with agNO
agGO@AgNode <- agNO
# Plot
pdf("~/Desktop/test.pdf", width=20, height=20, paper="special",
pagecentre=TRUE)
plot(agGO)
dev.off()
sessionInfo()
R version 2.7.1 (2008-06-23)
i386-apple-darwin8.10.1
locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] grid splines tools stats graphics
[6] grDevices utils datasets methods base
other attached packages:
[1] RbcBook1_1.8.0 geneplotter_1.18.0
[3] lattice_0.17-8 RColorBrewer_1.0-2
[5] Rgraphviz_1.18.1 org.Rn.eg.db_2.2.0
[7] KEGG.db_2.2.0 GOstats_2.6.0
[9] Category_2.6.0 genefilter_1.20.0
[11] survival_2.34-1 RBGL_1.16.0
[13] annotate_1.18.0 xtable_1.5-2
[15] graph_1.18.1 GO.db_2.2.0
[17] AnnotationDbi_1.2.2 RSQLite_0.6-9
[19] DBI_0.2-4 Biobase_2.0.1
loaded via a namespace (and not attached):
[1] KernSmooth_2.22-22 cluster_1.11.11
--
Daniel C. Jupiter, Ph.D.
Postdoctoral Research Associate
Department of Systems Biology and Translational Medicine
College of Medicine
Texas A&M Health Science Center
702 SW H.K. Dodgen Loop
Temple, TX 76504
979.997.2106 | Fax 254.742.7145
djupiter@tamu.edu | www.tamhsc.edu
[[alternative HTML version deleted]]