igraph arrow.mode似乎无效

时间:2020-05-06 14:39:36

标签: r igraph

我的网络中有一些有向边和一些无向边。我正在尝试使用igraph使用arrow.mode参数对其进行绘制,但是该图始终显示带有默认参数的箭头。这是一个例子

以下是一些数据:

spearRhoP_lagged4 <- structure(list(Var1 = c("ARISA_538.9", "ARISA_538.9", "ARISA_666.4", 
"ARISA_686.9", "ARISA_538.9", "ARISA_594.1"), Var2 = c("ARISA_666.4", 
"ARISA_686.9", "ARISA_686.9", "ARISA_666.4", "ARISA_561.8", "ARISA_561.8"
), rho = c(0.280885191364122, 0.415365287156247, 0.614493076574831, 
0.312630564055403, 0.295296877306726, 0.381890811408216), p = c(0.00206314544835896, 
2.9098006351119e-06, 1.35005674822095e-13, 0.000567475872663549, 
0.00116911931220592, 1.98010880043619e-05), delay = c(0, 0, 0, 
1, 0, 0), fdr = c(0.0135393920048557, 7.97032347878478e-05, 2.83511917126399e-11, 
0.00503534929264839, 0.00898225813036257, 0.000366902513022), 
    arrow = c("-", "-", "-", ">", "-", "-")), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L), groups = structure(list(
    Var1 = c("ARISA_538.9", "ARISA_538.9", "ARISA_538.9", "ARISA_594.1", 
    "ARISA_666.4", "ARISA_686.9"), Var2 = c("ARISA_561.8", "ARISA_666.4", 
    "ARISA_686.9", "ARISA_561.8", "ARISA_686.9", "ARISA_666.4"
    ), .rows = list(5L, 1L, 2L, 6L, 3L, 4L)), row.names = c(NA, 
-6L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE))

然后我建立图

LaggedSpearGraph <- graph_from_data_frame(spearRhoP_lagged4)

最后我绘制了图形,告诉它我希望通过参数arrow指定箭头方向

plot(LaggedSpearGraph,
      vertex.size=2,
      arrow.mode = E(LaggedSpearGraph)$arrow)

我得到的输出看起来像这样。

GraphWithTooManyArrows

但是我想要的是一个只有一个边缘带有箭头的网络。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您需要添加edge作为前缀:

LaggedSpearGraph <- graph_from_data_frame(spearRhoP_lagged4, directed=T)

plot(LaggedSpearGraph,
     vertex.size=10,
     edge.arrow.mode = E(LaggedSpearGraph)$arrow)

enter image description here

请参阅此处: https://github.com/igraph/igraph/issues/954