This is my graphNEL object
>mergedPathways_d
A graphNEL graph with undirected edges
Number of Nodes = 41
Number of Edges = 102
I have tried coerce
. It did not work out. It asks to pre-define the matrix and To and From didnot work correctly, I had NA as entries in my adj matrix
I tried using edgeL
. It did not work out. The edge list I got had numbers as edges and not the names of the genes. And I don't know how to map genes onto those numbers.
I tried converting it into igraph
using igraph.from.graphNEL
and then using as_adjacency_matrix
. It did not work out. I got a dgCMatrix and not a normal matrix with accessible rows and columns and I am unable to convert it into a data frame either.
So right now an adjacency matrix (41 x 41) with rows ans columns being 41 gene names from the graphNEL object. OR an edge list with 2 columns and 102 rows. Each edge on one row.
Any help would be highly appreciated. It has been whole day trying to extract data from KEGG and now trying to manipulate into desired form for further application.
Thanks!
Have you tried
coerce(mergedPathways_d,to="matrix")
?Error in as.character.default(from) : no method for coercing this S4 class to a vector In addition: Warning message: In coerce(mergedPathways_d, to = "matrix") : direct use of coerce() is deprecated: use as(from, class(to)) instead
You should probably post on the Bioconductor support site. I just noticed that you get a sparse matrix (dgCMatrix) from igraph so it seems that the igraph conversion is working. To get a normal matrix use as_adjacency_matrix(..., sparse = FALSE) or use as.matrix() on the dgCMatrix.
Thanks a lot! This was helpful!