【发布时间】:2017-12-17 12:25:39
【问题描述】:
所以我使用 all_shortest_paths 来获取输出,如下所示:
PathsE
$res[[1]]
+ 4/990 vertices, named:
[1] Sortilin GGA1 Ubiquitin PIMT
$res[[2]]
+ 4/990 vertices, named:
[1] Sortilin TrkA PLK1 PIMT
$res[[3]]
+ 4/990 vertices, named:
[1] Sortilin APP JAB1 PIMT
我想把它变成一个数据框,以便我可以操作它。 作为参考,我希望数据框看起来像这样:
Prot1 Prot2 Prot3 Prot4
Pathway1 Sortilin GGA1 PLK1 PIMT
Pathway2 Sortilin TrkA PLK1 PIMT
Pathway3 Sortilin APP JAB1 PIMT
*我知道如何更改坐标轴名称
我试过了
PathsDF<-as.data.frame(PathsE)
但我收到此错误:
as.data.frame.default(x[[i]], optional = TRUE) 中的错误: 无法将“igraph.vs”类强制转换为 data.frame
我也试过这个:
PathDF <- as.data.frame(get.edgelist(PathsE))
但我收到此错误
get.edgelist(PathsE) 中的错误:不是图形对象
当我检查数据结构时使用
class(PathsEF)
它说它是一个列表。但是当我使用
str(PathsE)
它看起来像这样:
..$ :Class 'igraph.vs' atomic [1:4] 338 204 40 913
.. .. ..- attr(*, "env")=<weakref>
.. .. ..- attr(*, "graph")= chr "717e99fb-b7db-4e35-8fd3-1d8d741e6612"
etc
在我看来,它就像一个矩阵。
根据这些信息,你们中是否有人对如何将其转换为数据框有任何想法。如果我遗漏了任何明显的东西,我很抱歉 - 我对 R 很陌生!
【问题讨论】:
-
你希望你的数据框是什么样子的?
-
请看我的编辑!