Esempio n. 1
0
    containing the parameters to be estimated (alpha, beta), and the
    BinaryStateModel class instance as the second argument.
    """
    if model.model == 'ARD':
        model.alpha, model.beta = params
    else:
        model.alpha = params[0]        
    model.set_qmat()
    liks = model.pruning_algorithm()
    return -np.log(liks).sum()


if __name__ == "__main__":
    import ipcoal
    from hogtie.utils import set_loglevel
    set_loglevel("DEBUG")
    import os
#
    #print("important-------")
    #print('toytree', toytree.__version__)
    #print('ipcoal', ipcoal.__version__)
    #print("----------------")
#
    ## GENERATE SOME BINARY DATA
    TREE = toytree.rtree.baltree(ntips=12, treeheight=1e6)
    #MODEL = ipcoal.Model(TREE, Ne=20000, mut=1e-8, seed=123)
    #MODEL.sim_snps(10)
#
    ## DATA is in alphanumeric tipname order
    #DATA = MODEL.write_vcf().iloc[:, 9:]
    #DATA[(DATA == 2) | (DATA == 3)] = 1
Esempio n. 2
0
    if model.model == 'ARD':
        model.alpha, model.beta = params
        lik = model.pruning_algorithm()

    else:
        model.alpha = params[0]
        lik = model.pruning_algorithm()
    
    return -lik


if __name__ == "__main__":

    import time
    from hogtie.utils import set_loglevel
    set_loglevel("INFO")
    TREE = toytree.rtree.imbtree(ntips=10, treeheight=1000)

    DATA = np.array([1, 1, 0, 0, 1, 0, 0, 0, 0, 1])

    start = time.time()
    mod = BinaryStateModel(TREE, DATA, 'ER')
    mod.optimize()
    print(f"\n---- TIME: {time.time() - start:.5f} seconds")

    #DATA = np.array([1, 0, 1, 0, 1, 0, 1, 0, 1, 0])
    #od = BinaryStateModel(TREE, DATA, 'ARD')
    #mod.optimize()

    #DATA = np.array([1, 1, 1, 1, 1, 1, 0, 0, 0, 0])
    #mod = BinaryStateModel(TREE, DATA, 'ER')