{"id":24076,"library":"msprime","title":"msprime","description":"msprime is a fast, scalable Python library for simulating genealogical trees and genomic sequence data under population genetic models using the coalescent with recombination. Current version 1.4.1 supports Python >=3.11. Released under GPL, maintained by the TSKIT team with regular updates.","status":"active","version":"1.4.1","language":"python","source_language":"en","source_url":"https://github.com/tskit-dev/msprime","tags":["population-genetics","coalescent","simulation","tree-sequences","genomics"],"install":[{"cmd":"pip install msprime","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for numerical operations.","package":"numpy","optional":false},{"reason":"Required for tree sequence data structures and analysis.","package":"tskit","optional":false}],"imports":[{"note":"simulate() is a top-level function in msprime. No common wrong import.","wrong":"simulate() after `from msprime import *` (no issue but discouraged)","symbol":"simulate","correct":"import msprime as ms\nms.simulate(...) or from msprime import simulate"}],"quickstart":{"code":"import msprime\n# Simulate a coalescent sample of 10 chromosomes\nrecombination_rate = 1e-8\nsequence_length = 1e4\nts = msprime.simulate(\n    sample_size=10,\n    recombination_rate=recombination_rate,\n    length=sequence_length,\n    random_seed=42\n)\nprint(ts.num_trees, ts.num_samples)","lang":"python","description":"Simulate a basic coalescent tree sequence with recombination."},"warnings":[{"fix":"Replace `Ne=X` with `population_size=X`. Ensure you use msprime 1.x imports.","message":"In msprime 1.0, the API was overhauled: `msprime.simulate()` replaces `msprime.simulate()` from older versions (no change in name but parameter changes). The `Ne` parameter is no longer accepted; use `population_size`.","severity":"breaking","affected_versions":">=0.7.0, <1.0"},{"fix":"Run `ts = msprime.simulate(...)` then `ts = msprime.mutate(ts, rate=1e-8)`. See docs for details.","message":"`msprime.simulate()` with mutation_rate parameter is deprecated in favor of `msprime.mutate()` applied to a tree sequence.","severity":"deprecated","affected_versions":">=1.0"},{"fix":"Use different seeds (e.g., derived from process ID) when running parallel simulations.","message":"Setting `random_seed` to the same value will produce identical results. For parallel simulations, ensure each process uses a unique seed.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass a list: `sample_size=[5,5]` for two populations. Do not pass total 10.","message":"When using `msprime.simulate()` with multiple populations, the `sample_size` parameter expects a list of sample sizes per population, not the total. Incorrect usage leads to confusing errors.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Upgrade Python to 3.11 or later.","message":"Support for Python 3.8 and 3.9 dropped in msprime 1.4.0. Requires Python >=3.11 as of 1.4.1.","severity":"breaking","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install msprime>=1.0: `pip install 'msprime>=1.0'`","cause":"Using an old msprime version (<1.0) that had a different API, or a typo.","error":"AttributeError: module 'msprime' has no attribute 'simulate'"},{"fix":"Replace `Ne` with `population_size`. See migration guide.","cause":"Old code using `Ne` parameter removed in msprime 1.0.","error":"TypeError: simulate() got an unexpected keyword argument 'Ne'"},{"fix":"Provide a list of sample sizes with length equal to number of populations.","cause":"Passing a single int for sample_size when multiple populations are defined.","error":"ValueError: sample_size must be a list if there is more than one population"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}