Skip to main content

install with bioconda

mrpast

Infer demographic parameters from Ancestral Recombination Graphs (ARGs), by extracting pairwise coalescence counts for use in a maximum likelihood model. For detail on the method and results, see the preprint:

DeHaas, Drew, Zhibai Jia, Leo Speidel, and Xinzhu Wei. "Inference of complex demographic history using composite likelihood based on whole-genome genealogies." bioRxiv (2025): 2025-10.

See the documentation for commands, examples, and concepts.

See PAPER_EXPERIMENTS.md for the configurations that were used in the paper.

Install

Python 3.8 or newer is supported.

Install from PyPi:

pip install mrpast

On Linux, this will use prebuilt binaries. On MacOS, this will trigger a source code build, which requires CMake and gcc or clang (C++17 support required).

You can also install the conda package via the bioconda channel: conda install mrpast.

Build/Install from repository

Recommend using a virtual environment, the below creates and activates one:

python3 -m venv MyEnv
source MyEnv/bin/activate

Clone repo, then build and install:

git clone --recursive https://github.com/aprilweilab/mrpast.git
pip install mrpast/

Usage

There are three primary subcommands to mrpast, and they are usually run in this order:

  1. mrpast simulate
  2. mrpast process
  3. mrpast solve

These steps describe the "Simulated ARG" workflow, where no ARG inference is performed. See the documentation for workflows making use of inferred ARGs.

Simulation

In order to test out a demographic model, it is recommended that you start out by simulating that model and verifying that mrpast can recover the model parameters with the necessary accuracy. The simulation is done via msprime and produces ancestral recombination graphs (ARGs) in the form of a tskit tree-sequence file (.trees).

Example:

# Simulate the model 10 times, using a DNA sequence length of 100Kbp and the default recombination rate (1e-8)
mrpast simulate --replicates 10 --seq-len 100000 --debug-demo examples/5deme1epoch.yaml 5de1

This creates 10 tree-sequence files (ARGs) that are named like 5de1*.trees, using the given model.

Processing

Given an ARG in tree-sequence format, either from simulation (see above) or from ARG inference, we then extract coalescence information.

Example:

# Use 10 CPU threads to process the data and produce 10 replicates (expanded models) to be solved (later).
# `--bootstrap` creates 100 bootstrap samples by default, the average of which is used for input the maximum
# likelihood function
mrpast process --jobs 10 --replicates 10 --suffix trial1 --bootstrap coalcounts examples/5deme1epoch.yaml 5de1

See mrpast process --help for more options that control time discretization, distance between sampled trees, etc.

If we want, we could use --solve to run the solver as soon as processing completed. Otherwise, see the next section.

Solving

If you didn't pass --solve to mrpast process then you can run the solver via:

mrpast solve --jobs 10 5deme1epoch.*.solve_in.*.json

The resulting output files will be listed, and the best output (maximum likelihood) will be listed as well. The JSON files for the output contains the parameter values, their bounds, their initialized values, and (if present) their ground truth values. Assuming the best result was 5deme1epoch.trial1.solve_in.0.out.json, we can quickly view the results via

mrpast show -n 5deme1epoch.trial1.solve_in.0.out.json

Other workflows

Simulated Data, Inferred ARG

The simulated data, inferred ARG workflow is:

  1. mrpast simulate: Simulate your model with some ground-truth parameter values.
  2. mrpast sim2vcf -p: Convert all .trees files with the given prefix to VCF files, and emit the corresponding .popmap.json files (which maps each sample to a population).
  3. mrpast arginfer: Infer ARG from the VCF files, and then attach the population IDs to the ARG (.trees files) using the .popmap.json
  4. mrpast process: Process and solve the inferred ARGs

Real Data, Inferred ARG

The real data workflow is:

  1. Manually create a .popmap.json file for your VCF dataset. See the documentation for more details.
  2. mrpast arginfer: Infer ARG from the VCF files, and then attach the population IDs to the ARG (.trees files) using the .popmap.json
  3. mrpast process: Process and solve the inferred ARGs

Modeling

The demographic model is specified via YAML. See the examples directory for example models. See the documentation for details on model syntax and behavior.

Alternative installation options

  1. Compile for the native CPU; this can speed up the numerical solver, but makes the resulting package less portable.
MRPAST_ENABLE_NATIVE=1 pip install mrpast/
  1. Build the solver in debug mode, so GDB can be attached.
MRPAST_DEBUG=1 pip install mrpast/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mrpast-0.4.tar.gz (5.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mrpast-0.4-cp313-cp313-manylinux_2_24_x86_64.whl (866.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64

mrpast-0.4-cp312-cp312-manylinux_2_24_x86_64.whl (866.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64

mrpast-0.4-cp311-cp311-manylinux_2_24_x86_64.whl (866.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64

mrpast-0.4-cp310-cp310-manylinux_2_24_x86_64.whl (866.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64

mrpast-0.4-cp39-cp39-manylinux_2_24_x86_64.whl (866.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

File details

Details for the file mrpast-0.4.tar.gz.

File metadata

  • Download URL: mrpast-0.4.tar.gz
  • Upload date:
  • Size: 5.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mrpast-0.4.tar.gz
Algorithm Hash digest
SHA256 01743dc8133c35f3bb7f3bfdc584275b6ff57eaa62c270560beea699e24bcf12
MD5 345ddd0cd6c5cef7070b68f5806d7334
BLAKE2b-256 9a965f1ef2651c3c0df69198ee0b1bf6b44eac2dc2e551f09128ef85309580b2

See more details on using hashes here.

File details

Details for the file mrpast-0.4-cp313-cp313-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for mrpast-0.4-cp313-cp313-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e5f55999a032981a171bba2152ef78808a52ba0efe17ef2a1dc97ca323c717a5
MD5 cc3668151d1611eacf3ad1ecbf039bbd
BLAKE2b-256 855db95fef40bc8896f413ddc554766a0d4c021ee9609c54d18b82208ad46a33

See more details on using hashes here.

File details

Details for the file mrpast-0.4-cp312-cp312-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for mrpast-0.4-cp312-cp312-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 db050d3ebac413313f9f7f51587bc1f5b5da25d6bb1615f6b99b43a2e490c16a
MD5 a7868f61c25c195e5557a5434cd34564
BLAKE2b-256 74a34061dc0b92089263a4988c953f97bd108efae54a7566d2e02a4f2dd86153

See more details on using hashes here.

File details

Details for the file mrpast-0.4-cp311-cp311-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for mrpast-0.4-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 47732eb8775bf7c0139e22383ff53861f6b0aaf51b866efabf7f373090d2a17c
MD5 f3214d22f631f1af84c4404d165d37a7
BLAKE2b-256 cf8753c87048b0dd44df60a98fdc455a03e5bc89cd70cfe41c80db4b57921e65

See more details on using hashes here.

File details

Details for the file mrpast-0.4-cp310-cp310-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for mrpast-0.4-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 ec169e59572ee2f1ac0d7c8195fb7ce8b11b14338116b05baf3dfed839ae5809
MD5 68c66a862c7583ab1a53700bc7fae9b3
BLAKE2b-256 0e86a4605fdf08ac3a26b3650a902c7d2a76ccf296688456aa22d4cf7fa75137

See more details on using hashes here.

File details

Details for the file mrpast-0.4-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: mrpast-0.4-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 866.1 kB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mrpast-0.4-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 86d62660d64231b8a301181e1d0125092b79326b4f8ff5b3125f3b46a96cd536
MD5 62993117d00fecae339b6e73cb6311a7
BLAKE2b-256 76e40b3547213ed68f8f58b300f14161584a1ec5e8f08184dcf41cebed1a5141

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5

6 files

This release

0.4 This release

6 files

0.3

7 files

0.2

7 files

0.1

7 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page