def test_simple_error(self): ts = msprime.simulate( 10, mutation_rate=10, recombination_rate=10, random_seed=2) self.assertTrue(ts.num_sites > 1) self.assertTrue(ts.num_trees > 1) tsp = tsinfer.insert_errors(ts, 0.1) # We should have some extra mutations self.assertGreater(tsp.num_mutations, ts.num_mutations) self.verify(ts, tsp)
def test_zero_error(self): ts = msprime.simulate( 10, mutation_rate=10, recombination_rate=10, random_seed=1) self.assertTrue(ts.num_sites > 1) self.assertTrue(ts.num_trees > 1) tsp = tsinfer.insert_errors(ts, 0) t1 = ts.tables t2 = tsp.tables self.assertEqual(t1.nodes, t2.nodes) self.assertEqual(t1.edges, t2.edges) self.assertEqual(t1.sites, t2.sites) self.assertEqual(t1.mutations, t2.mutations)
def test_zero_error(self): ts = msprime.simulate(10, mutation_rate=10, recombination_rate=10, random_seed=1) assert ts.num_sites > 1 assert ts.num_trees > 1 tsp = tsinfer.insert_errors(ts, 0) t1 = tsutil.mark_mutation_times_unknown(ts).tables t2 = tsp.tables assert t1.nodes == t2.nodes assert t1.edges == t2.edges assert t1.sites == t2.sites assert t1.mutations == t2.mutations
def run_viz( n, L, rate, seed, mutation_rate=0, engine="C", perfect_ancestors=True, perfect_mutations=True, path_compression=False, time_chunking=True, error_rate=0, ): recomb_map = msprime.RecombinationMap.uniform_map(length=L, rate=rate, num_loci=L) ts = msprime.simulate( n, recombination_map=recomb_map, random_seed=seed, model="smc_prime", mutation_rate=mutation_rate, ) if perfect_mutations: ts = tsinfer.insert_perfect_mutations(ts, delta=1 / 512) else: ts = tsinfer.strip_singletons( tsinfer.insert_errors(ts, error_rate, seed)) print("num_sites = ", ts.num_sites) with open("tmp__NOBACKUP__/edges.svg", "w") as f: f.write(draw_edges(ts)) with open("tmp__NOBACKUP__/ancestors.svg", "w") as f: f.write(draw_ancestors(ts)) visualise( ts, rate, 0, engine=engine, box_size=26, perfect_ancestors=perfect_ancestors, path_compression=path_compression, time_chunking=time_chunking, )