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/

Metadata

Release files for mrpast 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mrpast 0.5
File Size Uploaded Provenance Actions
mrpast-0.5.tar.gz 5.1 MB Without provenance Details for mrpast-0.5.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mrpast 0.5
File Actions
mrpast-0.5-cp313-cp313-manylinux_2_24_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.24+ x86-64 Details for mrpast-0.5-cp313-cp313-manylinux_2_24_x86_64.whl
mrpast-0.5-cp312-cp312-manylinux_2_24_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64 Details for mrpast-0.5-cp312-cp312-manylinux_2_24_x86_64.whl
mrpast-0.5-cp311-cp311-manylinux_2_24_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64 Details for mrpast-0.5-cp311-cp311-manylinux_2_24_x86_64.whl
mrpast-0.5-cp310-cp310-manylinux_2_24_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64 Details for mrpast-0.5-cp310-cp310-manylinux_2_24_x86_64.whl
mrpast-0.5-cp39-cp39-manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64 Details for mrpast-0.5-cp39-cp39-manylinux_2_24_x86_64.whl

Total release size: 9.4 MB

Release files / mrpast-0.5.tar.gz

Download URL mrpast-0.5.tar.gz
Size 5.1 MB
Tags Source
SHA-256 checksum
How to use checksums
599a60197df14a612ef476e44cbbf900039194d1e0836f906cf9a1c0f3288a15
BLAKE2b-256 checksum
How to use checksums
db6b5a2f405dc01c2693faa2e6f188561fa54ab4375709d659a0a142d962734f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mrpast-0.5-cp313-cp313-manylinux_2_24_x86_64.whl

Download URL mrpast-0.5-cp313-cp313-manylinux_2_24_x86_64.whl
Size 866.9 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
7915c8f4582a3cc668d44319d519b57c944eab28776146326150cafbb0dddd77
BLAKE2b-256 checksum
How to use checksums
2340bb41d72a98fe2d3ada140328c03486e0de0ecb671697ad20c132f957ac50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mrpast-0.5-cp312-cp312-manylinux_2_24_x86_64.whl

Download URL mrpast-0.5-cp312-cp312-manylinux_2_24_x86_64.whl
Size 866.9 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
339fd62b7af59d2e340c010c4d58d3d1e51718b4cbee562b2488374e13e06617
BLAKE2b-256 checksum
How to use checksums
3c0223fe064eb9454653968706e9d5ebda3457888483046ae5ef10166f2b497a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mrpast-0.5-cp311-cp311-manylinux_2_24_x86_64.whl

Download URL mrpast-0.5-cp311-cp311-manylinux_2_24_x86_64.whl
Size 866.9 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
f6cfe8f6e15f17916a464eb7e48b4a16a1b4aad05fcf1422dc00789028a22405
BLAKE2b-256 checksum
How to use checksums
22aa227bfc17b2eb41651e50e42da8fb628cc0608dacb285844da6ffcb3936a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mrpast-0.5-cp310-cp310-manylinux_2_24_x86_64.whl

Download URL mrpast-0.5-cp310-cp310-manylinux_2_24_x86_64.whl
Size 866.9 kB
Tags CPython 3.10 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
100e0ef7c2ef622560e76c1de69ee686641622c33c91a1fdf0713cd52521d639
BLAKE2b-256 checksum
How to use checksums
b6a4149a5106bcadc21e6549d095785a3ec1821ddf8361a33866fb6d946e0972
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mrpast-0.5-cp39-cp39-manylinux_2_24_x86_64.whl

Download URL mrpast-0.5-cp39-cp39-manylinux_2_24_x86_64.whl
Size 866.9 kB
Tags CPython 3.9 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
f47c4ba381a2dced51c7edde91ff3b41f0c4133d6eac333570a6d3756b1a5ecb
BLAKE2b-256 checksum
How to use checksums
5972ddd173215869f47158d22dd278eb7847dc7f82ff7da50efa1d36b1d2760d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for mrpast 0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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