问题描述
我正在尝试使用igraph / ggraph绘制网络,其中某些边是定向的,而其他边则不是。
我的边缘列表中的一个小例子。在这里,我想将蛋白质位点的边缘表示为无向,而将磷酸化的边缘表示为有向。
df <- data.frame(
stringsAsFactors = FALSE,from = c("RPS6KA3","RPS6KA3","RPS6KA3"),to = c("RPS6KA3_Y529-p","RPS6KA3_S227-p","RPS6KA3_S369-p","RPS6KA3_T577-p","ATF4"),action = c("protein-site","protein-site","phosphorylation")
)
我尝试将无方向的边缘设置为子集并指定它们,但这种方法无效:
library(igraph)
nw <- graph_from_data_frame(df)
E(nw)[E(nw)$action == "protein-site"] <- as.undirected(subgraph.edges(nw,E(nw)[E(nw)$action == "protein-site"] ))
还有其他建议吗? 正如我所说的,我真的只想绘制该图形(使用ggraph)。
谢谢!