R:如何将graphNEL对象转换为Adjacency Matrix [英] R: How to convert graphNEL object into Adjacency Matrix

查看:609
本文介绍了R:如何将graphNEL对象转换为Adjacency Matrix的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的graphNEL对象

 > mergedPathways_d 
带有无向边的graphNEL图
Number节点数= 41
边数= 102

我试过裹胁。它没有解决。
它要求预先定义矩阵,并且To和From没有正常工作,我在NA矩阵中有NA作为条目



我尝试使用 edgeL 。它没有解决。
我得到的边界列表有数字作为边缘,而不是基因的名称。我不知道如何将基因映射到这些数字上。我试图用 igraph.from将它转换为igraph。

graphNEL ,然后使用 as_adjacency_matrix 。它没有解决。我得到了一个dgCMatrix,而不是一个可访问的行和列的正常矩阵,我也无法将它转换为数据框。



所以现在是一个邻接矩阵(41 x 41),其中行和列是来自graphNEL对象的41个基因名称。或具有2列和102行的边缘列表。每一条边上的一行。



任何帮助将不胜感激。它已经整天试图从KEGG中提取数据,现在试图将其操作为所需的形式以供进一步应用。

谢谢!

  as(mergedPathways_d,matrix=h2_lin>解决方案



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:

as(mergedPathways_d, "matrix")

这篇关于R:如何将graphNEL对象转换为Adjacency Matrix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆