从igraph中的图中删除未连接的短路径 [英] Delete unconnected short paths from a graph in igraph

查看:115
本文介绍了从igraph中的图中删除未连接的短路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用igraph中的网络进行工作,我有一个网络,其中有相互重叠的短连接节点,因此我们不夸张看到边缘.我想删除所有这样的短连接节点,因为它们未连接到主网络.度节点在这里不起作用,因为节点不是0度.它们连接到1个或多个基因,但仍然不在主网络中.即使主网络显示了一些重叠的基因,我也要纠正这一点.

I am working with networks in igraph, I have a network where there are short connected nodes that overlap eachother and so we donot exaclt see the edge. I want to delete al such short connected nodes as they are not connected to the main network. The degree thing doesnt work here as the nodes are not 0 degree., they are either connected to 1 or more genes but still not in the main network.Even the main network shows some overlapping genes, I want to correct that too.

 net <- simplify(InnatedGraph, remove.multiple = T, remove.loops = T, ) 
 bad.vs<-V(net)[degree(net) == 0] 
 net <-delete.vertices(net, bad.vs)
 plot(net,vertex.label=NA, edge.curved=.1, edge.width = 1,edge.arrow.width = 0.3,vertex.size = 3,asp=-1,edge.arrow.size = 0.5,vertex.label.cex = 0.3)

完成所有这些操作后,我得到一个像这样的网络

After doing all this i get a network like this

您在主网络中看到的基因不是孤立的节点,而是连接到其他重叠的节点.有没有办法删除这些基因并防止在主网络中重叠.

The genes you see around the main network are not isolated nodes but connected to other nodes that are overlapped. Is there are way to delete these genes and prevent overlapping in the main network.

推荐答案

您需要主要组件.首先,找到组件,然后基于这些组件对图形进行子集化. g是您的网络:

You want the main component. First, find the components and then subset the graph based on those components. Where g is your network:

V(g)$comp <- components(g)$membership
main <- induced_subgraph(g,V(g)$comp==1)

对于重叠的节点,请检查igraph中可用的不同布局. ?igraph::layout.

As far as overlapping nodes, check out the different layouts available in igraph. ?igraph::layout.

这篇关于从igraph中的图中删除未连接的短路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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