Ejemplo n.º 1
0
                         FIXED_COL_MAP,
                         c,
                         r,
                         m,
                         t,
                         prepare_matrices=zipHMM_prepare_matrices,
                         single_logL=zipHMM_single_logL)


current_model = 'I'

intervals_per_epoch = 10

from coalhmm.model import build_epoch_separated_model
if current_model == 'I':
    modelI = build_epoch_separated_model(2, [[0, 0]], [1, intervals_per_epoch])
elif current_model == 'IM':
    M_for_both = [[1], [0]]
    modelIM = build_epoch_separated_model(
        2, [[0, 1], [0, 0]], [1, intervals_per_epoch, intervals_per_epoch],
        [None, M_for_both, None])

names = ["hg18", "pantro2"]

from coalhmm.fasta_parser import readAlignment

from scipy import zeros, int32


def read_observations(filename, names):
    '''Reads in a single fasta file and converts it to a series of
Ejemplo n.º 2
0
# The migration is specified in a similar way, but instead of a single value
# each entry in the array is another array telling us what the branch can
# migrate to.
# If we have three branches and the middle one can migrate to either of its
# neighbours but not vice-versa it would look like this: [[],[0,2],[]].

# Finally coalhmm uses discretized time so we need to specify how finely each
# epoch is subdivided. The present won't benefit from more than 1 time interval
# since everything is separate.
intervals_per_epoch = 10

from coalhmm.model import build_epoch_separated_model
if current_model == 'I':
    modelI = build_epoch_separated_model(
            # With the isolation model we have two branches in the present:
            2,
            # We want to merge 0 and 1, so we map them both to 0:
            [[0,0]],
            [1,intervals_per_epoch])
elif current_model == 'IM':
    # Creating an isolation-with-migration model is similar to the plain
    # isolation model. We add an extra epoch (maintaining the two separate
    # branches) and allow migration from 0 to 1 and from 1 to 0 in it.
    M_for_both = [[1],[0]]
    modelIM = build_epoch_separated_model(
            2,
            [[0,1], [0,0]],
            [1,intervals_per_epoch,intervals_per_epoch],
            # None for no migration in the first and last epoch
            [None, M_for_both, None])

# Now we need some data to work on. 'example_data.fa' is a small chunk of an
Ejemplo n.º 3
0
# logLikelihood is changed to use our two new functions.
def logLikelihood(model, all_obs, c,r,m,t):
    return logL_multiseq(model, all_obs, FIXED_COL_MAP, c,r,m,t,
            prepare_matrices=zipHMM_prepare_matrices,
            single_logL=zipHMM_single_logL)


current_model = 'I'

intervals_per_epoch = 10

from coalhmm.model import build_epoch_separated_model
if current_model == 'I':
    modelI = build_epoch_separated_model(
            2,
            [[0,0]],
            [1,intervals_per_epoch])
elif current_model == 'IM':
    M_for_both = [[1],[0]]
    modelIM = build_epoch_separated_model(
            2,
            [[0,1], [0,0]],
            [1,intervals_per_epoch,intervals_per_epoch],
            [None, M_for_both, None])

names = ["hg18", "pantro2"]

from coalhmm.fasta_parser import readAlignment

from scipy import zeros, int32
def read_observations(filename, names):
Ejemplo n.º 4
0
# The migration is specified in a similar way, but instead of a single value
# each entry in the array is another array telling us what the branch can
# migrate to.
# If we have three branches and the middle one can migrate to either of its
# neighbours but not vice-versa it would look like this: [[],[0,2],[]].

# Finally coalhmm uses discretized time so we need to specify how finely each
# epoch is subdivided. The present won't benefit from more than 1 time interval
# since everything is separate.
intervals_per_epoch = 10

from coalhmm.model import build_epoch_separated_model
if current_model == 'I':
    modelI = build_epoch_separated_model(
        # With the isolation model we have two branches in the present:
        2,
        # We want to merge 0 and 1, so we map them both to 0:
        [[0, 0]],
        [1, intervals_per_epoch])
elif current_model == 'IM':
    # Creating an isolation-with-migration model is similar to the plain
    # isolation model. We add an extra epoch (maintaining the two separate
    # branches) and allow migration from 0 to 1 and from 1 to 0 in it.
    M_for_both = [[1], [0]]
    modelIM = build_epoch_separated_model(
        2,
        [[0, 1], [0, 0]],
        [1, intervals_per_epoch, intervals_per_epoch],
        # None for no migration in the first and last epoch
        [None, M_for_both, None])

# Now we need some data to work on. 'example_data.fa' is a small chunk of an