GoogleSearch
이 블로그 검색
rBiopaxParser: igraph vs. graphNEL
라벨:
Informatics
이메일로 전송BlogThis!Twitter에서 공유Facebook에서 공유
library(rBiopaxParser)
## from layoutRegulatoryGraph()
f2= function (mygraph, label = "", node.fixedsize = FALSE, edge.weights = c("green",
"black", "red"), edge.arrowheads = c("normal", "tee"), subgraphs = list(),
subgraphs.colors = c("#B3E2CD", "#FDCDAC", "#F4CAE4", "#E6F5C9", "#FFF2AE"))
{
if (is.null(mygraph))
stop("Error: layoutRegulatoryGraph: supplied graph parameter was NULL.")
if (!("graphNEL" %in% class(mygraph)))
stop("Error: layoutRegulatoryGraph: supplied graph has to be of class graphNEL.")
if (length(nodes(mygraph)) == 0) {
warning("warning: layoutRegulatoryGraph: supplied graph has no nodes. No layout was done.")
return(mygraph)
}
if (!require(graph)) {
message("This functions needs the graph library installed, albeit it cannot be found. Check out the installation instructions!")
return(NULL)
}
if (!require(Rgraphviz)) {
message("This functions needs the Rgraphviz library installed, albeit it cannot be found. Check out the installation instructions!")
return(NULL)
}
# if (label != "")
graph::graphRenderInfo(mygraph) = list(label = label, labelJust = "l", labelLoc = "t")
graph::nodeRenderInfo(mygraph) = list(shape = "circle", fill = "#e0e0e0", fixedsize = node.fixedsize)
mygraph = Rgraphviz::layoutGraph(mygraph)
# if (label != "")
graph::graphRenderInfo(mygraph) = list(label = label, labelJust = "l", labelLoc = "t")
x = unlist(graph::edgeData(mygraph))
names(x) = gsub(".weight", "", names(x))
names(x) = gsub("|", "~", names(x), fixed = TRUE)
arrowhead = x
arrowhead[TRUE] = rep(edge.arrowheads[1], length(x))
arrowhead[x == 1] = edge.arrowheads[1]
arrowhead[x == -1] = edge.arrowheads[2]
graph::edgeRenderInfo(mygraph) = list(arrowhead = arrowhead)
color = x
color[TRUE] = rep(edge.weights[2], length(x))
color[x == 1] = edge.weights[1]
color[x == -1] = edge.weights[3]
graph::edgeRenderInfo(mygraph) = list(col = color)
graph::nodeRenderInfo(mygraph) = list(shape = "circle", fill = "#e0e0e0", fixedsize = node.fixedsize)
if (length(subgraphs) > 0) {
for (i in 1:length(subgraphs)) {
for (n in subgraphs[[i]]) {
graph::nodeRenderInfo(mygraph)$fill[n] = subgraphs.colors[i]
}
}
}
return(mygraph)
}
library(igraph)
p = igraph.from.graphNEL( graphNEL.object, name = TRUE, weight = TRUE, unlist.attrs = TRUE) # see weight E(p)$weight
pp = igraph.to.graphNEL( p )
unlist( graph::edgeData(pp) ) # P40|P11 --- P40~P11
Rgraphviz::renderGraph( f2(pp) )
이메일로 전송BlogThis!Twitter에서 공유Facebook에서 공유
라벨:
Informatics
Scientist. Husband. Daddy. --- TOLLE. LEGE
외부자료의 인용에 있어 대한민국 저작권법(28조)과 U.S. Copyright Act (17 USC. §107)에 정의된 "저작권물의 공정한 이용원칙 | the U.S. fair use doctrine" 을 따릅니다. 저작권(© 최광민)이 명시된 모든 글과 번역문들에 대해 (1) 복제-배포, (2) 임의수정 및 자의적 본문 발췌, (3) 무단배포를 위한 화면캡처를 금하며, (4) 인용 시 URL 주소 만을 사용할 수 있습니다. [후원 | 운영] [대문으로] [방명록] [옛 방명록] [티스토리 (백업)] [신시내티]
-