How to use the tsinfer.insert_perfect_mutations function in tsinfer

To help you get started, we’ve selected a few tsinfer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tskit-dev / tsinfer / tests / test_evaluation.py View on Github external
def test_small_smc(self):
        for seed in range(1, 10):
            ts = get_smc_simulation(5, L=1, recombination_rate=10, seed=seed)
            ts = tsinfer.insert_perfect_mutations(ts)
            self.assertGreater(ts.num_trees, 1)
            self.verify_perfect_mutations(ts)
github tskit-dev / tsinfer / tests / test_inference.py View on Github external
def test_five_samples(self):
        for seed in range(5):
            ts = msprime.simulate(
                5,
                recombination_rate=0.1,
                random_seed=seed + 100,
                length=10,
                model="smc_prime",
            )
            ts = tsinfer.insert_perfect_mutations(ts, delta=1 / 8192)
            self.verify(ts)
github tskit-dev / tsinfer / tests / test_evaluation.py View on Github external
def test_single_tree_perfect_mutations(self):
        ts = msprime.simulate(5, random_seed=234)
        ts = tsinfer.insert_perfect_mutations(ts)
        self.verify_single_tree_dense_mutations(ts)
github tskit-dev / tsinfer / tests / test_inference.py View on Github external
def test_twenty_samples(self):
        for seed in range(5):
            ts = msprime.simulate(
                20,
                recombination_rate=0.1,
                random_seed=seed + 500,
                length=10,
                model="smc_prime",
            )
            ts = tsinfer.insert_perfect_mutations(ts, delta=1 / 8192)
            self.verify(ts)
github tskit-dev / tsinfer / tests / test_evaluation.py View on Github external
def test_single_tree_perfect_mutations(self):
        ts = msprime.simulate(5, random_seed=234)
        ts = tsinfer.insert_perfect_mutations(ts)
        A = tsinfer.get_ancestral_haplotypes(ts)
        B = self.get_matrix(ts)
        self.assertTrue(np.array_equal(A, B))
        self.verify_single_tree(ts, A)
github tskit-dev / tsinfer / tests / test_inference.py View on Github external
def test_three_samples(self):
        for seed in range(10):
            ts = msprime.simulate(
                3, recombination_rate=1, random_seed=seed + 1, model="smc_prime"
            )
            ts = tsinfer.insert_perfect_mutations(ts)
            self.verify(ts)
github tskit-dev / tsinfer / tests / test_evaluation.py View on Github external
def test_single_tree(self):
        ts = msprime.simulate(5, random_seed=234)
        ts = tsinfer.insert_perfect_mutations(ts)
        self.verify_perfect_mutations(ts)
github tskit-dev / tsinfer / tests / test_inference.py View on Github external
def test_ten_samples(self):
        for seed in range(5):
            ts = msprime.simulate(
                10,
                recombination_rate=0.1,
                random_seed=seed + 200,
                length=10,
                model="smc_prime",
            )
            ts = tsinfer.insert_perfect_mutations(ts, delta=1 / 8192)
            self.verify(ts)
github tskit-dev / tsinfer / visualisation.py View on Github external
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,