def setUp(self): '''Load single nuclear family test case.''' # Remove a key child to make problem more interesting for the IBD algorithm self.problem = im.io.read_npz(itu.FAMILY945_ONE_PARENT_STAGE2).remove_nodes([2]) self.family = self.problem.families(genotyped=False)[0] self.sibs = ig._filled_members(self.problem, self.family) self.ibd_computer = ig.GermlineIbdComputer(PhaseParam())
def setUp(self): '''Load single nuclear family test case.''' # Remove a key child to make problem more interesting for the IBD algorithm self.problem = im.io.read_npz( itu.FAMILY945_ONE_PARENT_STAGE2).remove_nodes([2]) self.family = self.problem.families(genotyped=False)[0] self.sibs = ig._filled_members(self.problem, self.family) self.ibd_computer = ig.GermlineIbdComputer(PhaseParam())
def setUp(self): '''Load single nuclear family test case.''' self.problem = im.io.read_npz(itu.FAMILY945_ONE_PARENT_STAGE2) self.family = self.problem.families(genotyped=False)[0] self.sibs = ig._filled_members(self.problem, self.family) self.ibd_computer = ig.GermlineIbdComputer(PhaseParam())
def setUp(self): '''Load single nuclear family test case.''' self.problem = im.io.read_npz(itu.SIB_FOUNDERS_STAGE3) self.family = self.problem.families(genotyped=False)[0] self.sibs = ig._filled_members(self.problem, self.family) self.ibd_computer = ig.GermlineIbdComputer(PhaseParam())
def setUp(self): '''Load single nuclear family test case.''' self.problem = im.io.read_npz(itu.FAMILY4_STAGE3) self.family = self.problem.first_family self.sibs = ig._filled_members(self.problem, self.family) self.ibd_computer = ig.GermlineIbdComputer(PhaseParam())
ibd.append(set([remaining])) return d def longest_segment(d): return max([(snp, len(ibd)) for (snp,ibd) in d.iteritems()], key=operator.itemgetter(1)) def hash_ibd_list(ibd): return dict(((sample, i) for (i, samples) in enumerate(ibd) for sample in samples)) def highest_degree_node(ibd): return max([(i,len(ibd[hap_index[(i,0)]])+len(ibd[hap_index[(i,1)]])) for i in sibs], key=operator.itemgetter(1))[0] p = im.io.read_npz(itu.SIB_FOUNDERS_STAGE3) f = p.families(genotyped=False)[0] sibs = ig._filled_members(p, f) h_mat = ig._HapMatrix(p, sibs) print h_mat c = ig.GermlineIbdComputer() segments = c.ibd_segments(h_mat) segments.group_to_disjoint() print segments haps = set(itertools.product(sibs, ALLELES)) d = compress(segments, haps) (best_segment, num_haps) = longest_segment(d) print best_segment, num_haps ibd = d[best_segment] print ibd hap_index = hash_ibd_list(ibd) template = highest_degree_node(ibd)