So I am using all_shortest_paths to get an output, which looks like this:
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
I would like to turn this into a dataframe so that I can manipulate it. For reference, I would like the dataframe to look like this:
Prot1 Prot2 Prot3 Prot4
Pathway1 Sortilin GGA1 PLK1 PIMT
Pathway2 Sortilin TrkA PLK1 PIMT
Pathway3 Sortilin APP JAB1 PIMT
*I know how to change the axes names
I have tried
PathsDF<-as.data.frame(PathsE)
but I get this error:
Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ""igraph.vs"" to a data.frame
I also tried this:
PathDF <- as.data.frame(get.edgelist(PathsE))
but I get this error
Error in get.edgelist(PathsE) : Not a graph object
When I examine the data strture using
class(PathsEF)
it says it is a list. But when I use
str(PathsE)
it appears like this:
..$ :Class 'igraph.vs' atomic [1:4] 338 204 40 913
.. .. ..- attr(*, "env")=<weakref>
.. .. ..- attr(*, "graph")= chr "717e99fb-b7db-4e35-8fd3-1d8d741e6612"
etc
which looks like a matrix to me.
From this information, do any of you have any ideas about how to convert this into a dataframe. I am sorry if I am missing anything obvious- I am pretty new to R!
See Question&Answers more detail:os