Skip to content

ms to msprime code conversion #1897

Answered by grahamgower
David-Peede asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @David-Peede.

Demes-python has an ms -> Demes converter: see the demes.from_ms() function. The demes model can then be imported to msprime using msprime.Demography.from_demes().

import demes
import msprime

cmd = (
    "-I 3 1 1 1 "
    "-n 1 1.682020 "
    "-n 2 3.736830 "
    "-n 3 7.292050 "
    "-eg 0 2 116.010723 "
    "-eg 0 3 160.246047 "
    "-ma x 0.881098 0.561966 0.881098 x 2.797460 0.561966 2.797460 x "
    "-ej 0.028985 3 2 "
    "-en 0.028985 2 0.287184 "
    "-ema 0.028985 3 x 7.293140 x 7.293140 x x x x x "
    "-ej 0.197963 2 1 "
    "-en 0.303501 1 1"
)
graph = demes.from_ms(cmd, N0=7310, deme_names=["YRI", "CEU", "CHB"])
demography = msprime.Demography.from_demes(graph)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@David-Peede
Comment options

@David-Peede
Comment options

@molpopgen
Comment options

@grahamgower
Comment options

@David-Peede
Comment options

Answer selected by David-Peede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants