Skip to main content

moments: population genetic analyses and inference using diversity statistics

Please see the documentation for more details, examples, tutorials and API usage.

moments provides a suite of methods for demographic history and selection inference from genetic data, based on diffusion approximations to the one- and two-locus allele frequency spectrum. moments is modeled after the ∂a∂i open source package developed by Ryan Gutenkunst. For SFS-based methods, we largely reuse ∂a∂i's API, but introduce a new simulation engine. This new method is based on the direct computation of the frequency spectrum without solving the diffusion system, removing the need for frequency grids as used in ∂a∂i. moments.LD, packaged within moments, implements methods for computing linkage disequilibrium statistics and running multi-population demographic inference using patterns of LD.

Getting started

moments requires Python 3.11 or newer (up to 3.15).

The simplest way to install moments is using pip:

pip install moments-popgen

moments can then be imported using import moments.

Important note: pip install moments installs a different package named moments, and our pypi package is named moments-popgen.

moments is also available from Bioconda:

conda install -c conda-forge -c bioconda moments

We can install the development branch directly from Github by running

pip install git+https://github.com/MomentsLD/moments.git@devel

Alternatively, you can clone the git repository and install from source (use pip install -e . for an editable, development install):

git clone https://github.com/MomentsLD/moments.git
cd moments
pip install .

Dependencies

Installing with pip installs the required dependencies automatically:

  • numpy (>= 2.0, < 3.0)
  • scipy (>= 1.13)
  • cython (>= 3.1)
  • mpmath (>= 1.0, < 1.4)
  • demes (>= 0.2)

Some features need additional packages:

  • Plotting: matplotlib
  • Parsing VCFs with moments.LD.Parsing: scikit-allel, h5py, and pandas

We also recommend installing ipython for interactive analyses.

For development, requirements.txt lists the dependencies along with the packages needed to build the documentation:

pip install -r requirements.txt

or, with conda:

conda install -c conda-forge --file requirements.txt

More details on installation can be found in the documentation. If you have trouble installing moments, please open an issue.

Citing moments

If you use moments in your research, please cite:

  • Jouganous, J., Long, W., Ragsdale, A. P., & Gravel, S. (2017). Inferring the joint demographic history of multiple populations: beyond the diffusion approximation. Genetics, 206(3), 1549-1567.

If you use moments.LD in your research, please cite:

  • Ragsdale, A. P. & Gravel, S. (2019). Models of archaic admixture and recent history from two-locus statistics. PLoS Genetics, 15(6), e1008204.

  • Ragsdale, A. P. & Gravel, S. (2020). Unbiased estimation of linkage disequilibrium from unphased data. Mol Biol Evol, 37(3), 923-932.

If you use moments.TwoLocus in your research, please cite:

  • Ragsdale, A. P. (2022). Local fitness and epistatic effects lead to distinct patterns of linkage disequilibrium in protein-coding genes. Genetics, 221(4), iyac097.

If you use the Godambe-based uncertainty methods (in moments.Godambe or moments.LD.Godambe), please cite:

  • Coffman, A. J., Hsieh, P. H., Gravel, S., & Gutenkunst, R. N. (2016). Computationally efficient composite likelihood statistics for demographic inference. Molecular biology and evolution, 33(2), 591-593.

moments is developed in the Simon Gravel and Aaron Ragsdale research groups, at McGill University and UW-Madison, respectively. For any issues, questions or bug reports, please open an issue on Github.

Changelog

All changes are detailed in the documentation.

Metadata

Release files for moments-popgen 1.7.0

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

Source distribution (sdist)

Source distribution for moments-popgen 1.7.0
File Size Uploaded Provenance Actions
moments_popgen-1.7.0.tar.gz 4.6 MB With provenance Details for moments_popgen-1.7.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for moments-popgen 1.7.0
File Actions
moments_popgen-1.7.0-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.0-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.0-cp315-cp315-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 macOS 11.0+ ARM64 Details for moments_popgen-1.7.0-cp315-cp315-macosx_11_0_arm64.whl
moments_popgen-1.7.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for moments_popgen-1.7.0-cp314-cp314-macosx_11_0_arm64.whl
moments_popgen-1.7.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for moments_popgen-1.7.0-cp313-cp313-macosx_11_0_arm64.whl
moments_popgen-1.7.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for moments_popgen-1.7.0-cp312-cp312-macosx_11_0_arm64.whl
moments_popgen-1.7.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for moments_popgen-1.7.0-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 39.8 MB

Release files / moments_popgen-1.7.0.tar.gz

Download URL moments_popgen-1.7.0.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
6576b0940e7045f7f1043ca9f264910d91ea49befc830ce186e136dc5248bef1
BLAKE2b-256 checksum
How to use checksums
5edc2d30969d192ae878be533e67b69b933a7834de29fed35ea58af28930e36a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.0-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 4.9 MB
Tags CPython 3.15 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b5802f79b0623dc541a2ca7b223b5521dd990fc3cb7630643f0a884bd6ce0cf9
BLAKE2b-256 checksum
How to use checksums
f3344882fad379c748fecd198eb37d4a4c026428f8b0ca939489186db64d236e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp315-cp315-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.0-cp315-cp315-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.15 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ca33f40c702c7321a3ebdf21953852483e2985c12166ead93b615fd480821a78
BLAKE2b-256 checksum
How to use checksums
47fb696bb29de6ffc6bece8d4849899e00d9955355a82b8c141caa822bd8fa4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 5.0 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
715988678a9780c2cae03a3389e68a094cfb034ec67ae105ad9b9f847a441dc9
BLAKE2b-256 checksum
How to use checksums
ce6807c4520dbd7fe802d9ae963854de52fb6a72eadc65a4129c5094430b485b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.0-cp314-cp314-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
363a1b0480bef23933e556eb51a0081422839327a05a657451fd19759116dcee
BLAKE2b-256 checksum
How to use checksums
dd94908caca39bbec7e5bd41af12b106b7c33be259b709012afe5b934cf4a899
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 5.0 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
51dc34909910a46d08e0fbc7b28c5534476ecd6fbc06e72cf503870263df0213
BLAKE2b-256 checksum
How to use checksums
3fa9dfb6953418c27b5c2c830ac1e5d153e50b4b3f84eadb911cea20f852845a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.0-cp313-cp313-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0589bf0e1060c6731aa9a5092e97a9125c06e5f6dd6ce5c8b7b14e006b3a8dd0
BLAKE2b-256 checksum
How to use checksums
021df4fb7304a4e0596528a573a65918a160a6bcac4c05e5da13a8116a751e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 5.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4ff627cf3d06636004a0e726c6f208a1c862133145735216c309f609171ea6c6
BLAKE2b-256 checksum
How to use checksums
d96b2894bba3eb9e675a0dbe67cc9405ece374ce5839dbf0e57a679318af7430
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.0-cp312-cp312-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1db822096bf8e8af7bf8c8d3f1fa18a13407df0aaee1fe9ce8613a17a2da05a4
BLAKE2b-256 checksum
How to use checksums
9ea6fa7e477005485bac2eccbb33f7e7a376116f20390474b88d783ebefe83b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 4.9 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
8ded0a1d81c954e95fe203d902d61d91fe0852048aa28915a543e82a056f6218
BLAKE2b-256 checksum
How to use checksums
b8d01ebe044ab20be12768178a0aeeed156aba608d3d17f6476a9d933b65f342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / moments_popgen-1.7.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.0-cp311-cp311-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c98f7e98b6aa02998cdd615f7df26371f289678502b5735d430e7a2f22a4db7a
BLAKE2b-256 checksum
How to use checksums
8371e4b8f1204c7c81cadcd4547766abfe44b49445a13b5efd2e48384a15736b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for moments-popgen 1.7.0

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.

Full provenance

All 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for moments_popgen-1.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

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