def makeClusters(self, chrom):
"""
yield all non-solo clusters
returns all of the BreakPoints that comprise the events within the
cluster
"""
#PARAM
MAXSPAN = self.maxSpan
MAXOVLS = self.maxOvl
intervalTree = self.genome[chrom]
overlaps = []
graph = nx.Graph()
#Find clusters on the chromosome
#By building a graph
for interval in intervalTree:
if abs(interval.end - interval.begin) > MAXSPAN:
continue
ovls = intervalTree.search(interval)
if len(ovls) == 1 or len(ovls) > MAXOVLS:
continue
for a,b in itertools.combinations(ovls, 2):
if abs(a.end - a.begin) > MAXSPAN \
or abs(b.end - b.begin) > MAXSPAN:
continue
graph.add_edge(a, b)
#clusters are sub graphs
for subG in nx.connected_component_subgraphs(graph):
if len(subG.edges()) == 0:
continue
lookup = [x.data for x in subG.nodes()]
ret = [x for x in self.points[chrom] if x.id in lookup]
#I need to merge points that are too close
if len(ret) <= 10:
yield ret
评论列表
文章目录