示例#1
0
    def test_trans_switch_single(self):
        """
        Calculate transitions probabilities for switching between blocks

        Only calculate a single matrix
        """

        k = 5
        n = 1e4
        rho = 1.5e-8 * 100
        mu = 2.5e-8
        length = 1000
        arg = arglib.sample_arg(k, n, rho, start=0, end=length)
        #arglib.write_arg("tmp/a.arg", arg)
        #arg = arglib.read_arg("tmp/a.arg")
        #arg.set_ancestral()

        muts = arglib.sample_arg_mutations(arg, mu)
        seqs = arglib.make_alignment(arg, muts)

        times = arghmm.get_time_points(5)
        arghmm.discretize_arg(arg, times)

        new_name = "n%d" % (k - 1)
        arg = arghmm.remove_arg_thread(arg, new_name)

        model = arghmm.ArgHmm(arg, seqs, new_name=new_name, times=times)

        # get recombs
        recombs = list(x.pos for x in arghmm.iter_visible_recombs(arg))
        print "recomb", recombs

        pos = recombs[0] + 1
        tree = arg.get_marginal_tree(pos - .5)
        last_tree = arg.get_marginal_tree(pos - 1 - .5)

        print "states1>>", model.states[pos - 1]
        print "states2>>", model.states[pos]

        treelib.draw_tree_names(last_tree.get_tree(), minlen=5, maxlen=5)
        treelib.draw_tree_names(tree.get_tree(), minlen=5, maxlen=5)

        print "pos>>", pos
        recomb = [x for x in tree
                  if x.event == "recomb" and x.pos + 1 == pos][0]
        mat = arghmm.calc_transition_probs_switch(tree, last_tree, recomb.name,
                                                  model.states[pos - 1],
                                                  model.states[pos],
                                                  model.nlineages, model.times,
                                                  model.time_steps,
                                                  model.popsizes, rho)
        pc(mat)
示例#2
0
    def test_trans_switch_single(self):
        """
        Calculate transitions probabilities for switching between blocks

        Only calculate a single matrix
        """

        k = 5
        n = 1e4
        rho = 1.5e-8 * 100
        mu = 2.5e-8
        length = 1000
        arg = arglib.sample_arg(k, n, rho, start=0, end=length)
        #arglib.write_arg("tmp/a.arg", arg)
        #arg = arglib.read_arg("tmp/a.arg")
        #arg.set_ancestral()


        muts = arglib.sample_arg_mutations(arg, mu)
        seqs = arglib.make_alignment(arg, muts)

        times = arghmm.get_time_points(5)
        arghmm.discretize_arg(arg, times)

        new_name = "n%d" % (k-1)
        arg = arghmm.remove_arg_thread(arg, new_name)

        model = arghmm.ArgHmm(arg, seqs, new_name=new_name, times=times)

        # get recombs
        recombs = list(x.pos for x in arghmm.iter_visible_recombs(arg))
        print "recomb", recombs

        pos = recombs[0] + 1
        tree = arg.get_marginal_tree(pos-.5)
        last_tree = arg.get_marginal_tree(pos-1-.5)

        print "states1>>", model.states[pos-1]
        print "states2>>", model.states[pos]

        treelib.draw_tree_names(last_tree.get_tree(), minlen=5, maxlen=5)
        treelib.draw_tree_names(tree.get_tree(), minlen=5, maxlen=5)

        print "pos>>", pos
        recomb = [x for x in tree
                  if x.event == "recomb" and x.pos+1 == pos][0]
        mat = arghmm.calc_transition_probs_switch(
            tree, last_tree, recomb.name,
            model.states[pos-1], model.states[pos],
            model.nlineages, model.times,
            model.time_steps, model.popsizes, rho)
        pc(mat)
示例#3
0
    length = 1000
    
    arg = arglib.sample_arg(k, n, rho, start=0, end=length)
    arglib.write_arg("tmp/a.arg", arg)
    muts = arglib.sample_arg_mutations(arg, mu)
    seqs = arglib.make_alignment(arg, muts)

    #arg = arglib.read_arg("tmp/a.arg")
    #arg.set_ancestral()
    #find_recomb_coal(tree, last_tree, recomb_name=None, pos=None)

    times = arghmm.get_time_points(30, maxtime=60e3)
    arghmm.discretize_arg(arg, times)

    # get recombs
    recombs = list(x.pos for x in arghmm.iter_visible_recombs(arg))
    print "recomb", recombs

    pos = recombs[0] + 1
    tree = arg.get_marginal_tree(pos-.5)
    last_tree = arg.get_marginal_tree(pos-1-.5)
    
    r, c = arghmm.find_recomb_coal(tree, last_tree, pos=pos)

    #treelib.draw_tree_names(last_tree.get_tree(), minlen=5, maxlen=5)
    #treelib.draw_tree_names(tree.get_tree(), minlen=5, maxlen=5)

    model = arghmm.ArgHmm(arg, seqs, new_name="n%d" % (k-1), times=times)


    #================================================================
示例#4
0
    length = 1000

    arg = arglib.sample_arg(k, n, rho, start=0, end=length)
    arglib.write_arg("tmp/a.arg", arg)
    muts = arglib.sample_arg_mutations(arg, mu)
    seqs = arglib.make_alignment(arg, muts)

    #arg = arglib.read_arg("tmp/a.arg")
    #arg.set_ancestral()
    #find_recomb_coal(tree, last_tree, recomb_name=None, pos=None)

    times = arghmm.get_time_points(30, maxtime=60e3)
    arghmm.discretize_arg(arg, times)

    # get recombs
    recombs = list(x.pos for x in arghmm.iter_visible_recombs(arg))
    print "recomb", recombs

    pos = recombs[0] + 1
    tree = arg.get_marginal_tree(pos - .5)
    last_tree = arg.get_marginal_tree(pos - 1 - .5)

    r, c = arghmm.find_recomb_coal(tree, last_tree, pos=pos)

    #treelib.draw_tree_names(last_tree.get_tree(), minlen=5, maxlen=5)
    #treelib.draw_tree_names(tree.get_tree(), minlen=5, maxlen=5)

    model = arghmm.ArgHmm(arg, seqs, new_name="n%d" % (k - 1), times=times)

    #================================================================
    win = summon.Window()