Skip to main content

ADAMIXTURE: Adaptive First-Order Optimization for Biobank-Scale Ancestry Inference

Project description

PyPI - Python Version PyPI - Version PyPI - License PyPI - Status PyPI - Downloads DOI

ADAMIXTURE: Adaptive First-Order Optimization for Biobank-Scale Genetic Clustering

ADAMIXTURE is an unsupervised global ancestry inference method that scales the ADMIXTURE model to biobank-sized datasets. It combines the Expectation–Maximization (EM) framework with the ADAM first-order optimizer, enabling parameter updates after a single EM step. This approach accelerates convergence while maintaining comparable or improved accuracy, substantially reducing runtime on large genotype datasets. For more information, we recommend reading our pre-print.

The software can be invoked via CLI and has a similar interface to ADMIXTURE (e.g. the output format is completely interchangeable).

nadm_mna

System requirements

Hardware requirements

The successful usage of this package requires a computer with enough RAM to be able to handle the large datasets the network has been designed to work with. Due to this, we recommend using compute clusters whenever available to avoid memory issues.

Software requirements

We recommend creating a fresh Python 3.10 virtual environment using virtualenv (or conda), and then install the package adamixture there. As an example, for virtualenv, one should launch the following commands:

$ virtualenv --python=python3.10 ~/venv/nadmenv
$ source ~/venv/nadmenv/bin/activate
(nadmenv) $ pip install adamixture

[!IMPORTANT] macOS Users: ADAMIXTURE requires OpenMP for parallel processing. You must install libomp (e.g., via Homebrew) before installing the package, otherwise the compilation will fail:

$ brew install libomp

Installation Guide

The package can be easily installed in at most a few minutes using pip (make sure to add the --upgrade flag if updating the version):

(nadmenv) $ pip install adamixture

Running ADAMIXTURE

To train a model, simply invoke the following commands from the root directory of the project. For more info about all the arguments, please run adamixture --help. Note that BED, VCF and PGEN are supported:

[!TIP] GPU Acceleration: Using GPUs greatly speeds up processing and is highly recommended for large datasets. You can specify the hardware to use with the --device parameter:

  • For NVIDIA GPUs, use --device gpu (requires CUDA).
  • For macOS users with Apple Silicon (M1/M2/M3/M4/M5), use --device mps to enable Metal Performance Shaders (MPS) acceleration.
  • Note that biobank-scale datasets are best handled on dedicated CUDA-capable GPUs due to high RAM requirements.

As an example, the following ADMIXTURE call

$ ./admixture snps_data.bed 8 -s 42

would be mimicked in ADAMIXTURE by running

$ adamixture --k 8 --data_path snps_data.bed --save_dir SAVE_PATH --name snps_data --seed 42

Two files will be output to the SAVE_PATH directory (the name parameter will be used to create the whole filenames):

  • A .P file, similar to ADMIXTURE.
  • A .Q file, similar to ADMIXTURE.

Logs are printed to the stdout channel by default. If you want to save them to a file, you can use the command tee along with a pipe:

$ adamixture --k 8 ... | tee run.log

Running with GPU acceleration

To leverage GPU acceleration (highly recommended for large datasets), use the --device flag:

  • NVIDIA GPU (CUDA):
    $ adamixture --k 8 --data_path data.bed --save_dir out/ --name test --device gpu
    
  • macOS Apple Silicon (MPS):
    $ adamixture --k 8 --data_path data.bed --save_dir out/ --name test --device mps
    

[!NOTE]
Biobank-scale datasets are best handled on dedicated CUDA-capable GPUs.

Multi-K Sweep

Instead of running ADAMIXTURE for a single K, you can automatically sweep over a range of K values using --min_k and --max_k. The data is loaded once, and each K is trained sequentially:

$ adamixture --min_k 2 --max_k 10 --data_path snps_data.bed --save_dir SAVE_PATH --name snps_sweep

Other options

  • --lr (float, default: 0.005):
    Learning rate used by the Adam optimizer in the EM updates.

  • --min_lr (float, default: 1e-6):
    Minimum learning rate used by the Adam optimizer in the EM updates.

  • --lr_decay (float, default: 0.5):
    Learning rate decay factor.

  • --beta1 (float, default: 0.80):
    Exponential decay rate for the first moment estimates in Adam.

  • --beta2 (float, default: 0.88):
    Exponential decay rate for the second moment estimates in Adam.

  • --reg_adam (float, default: 1e-8):
    Numerical stability constant (epsilon) for the Adam optimizer.

  • --patience_adam (int, default: 2):
    Patience for reducing the learning rate in Adam-EM.

  • --tol_adam (float, default: 0.1):
    Tolerance for stopping the Adam-EM algorithm.

  • --data_path (str, required):
    Path to the genotype data (BED, VCF or PGEN).

  • --save_dir (str, required):
    Directory where the output files will be saved.

  • --name (str, required):
    Experiment/model name used as prefix for output files.

  • --device (str, default: cpu):
    Target hardware for computation. Choices: cpu, gpu (NVIDIA/CUDA), or mps (Apple Metal).

  • --seed (int, default: 42):
    Random number generator seed for reproducibility.

  • --k (int):
    Number of ancestral populations (clusters) to infer. Required if --min_k/--max_k are not specified.

  • --min_k (int):
    Minimum K for a multi-K sweep (inclusive). Must be used together with --max_k.

  • --max_k (int):
    Maximum K for a multi-K sweep (inclusive). Must be used together with --min_k.

  • --no_freqs (flag):
    If set, the P (allele frequencies) matrix is not saved to disk. Only the Q (admixture proportions) file will be written.

  • --max_iter (int, default: 1500):
    Maximum number of Adam-EM iterations.

  • --check (int, default: 5):
    Frequency (in iterations) at which the log-likelihood is evaluated.

  • --max_als (int, default: 1000):
    Maximum number of iterations for the ALS solver.

  • --tol_als (float, default: 1e-4):
    Convergence tolerance for the ALS optimization.

  • --power (int, default: 5):
    Number of power iterations used in randomized SVD.

  • --tol_svd (float, default: 1e-1):
    Convergence tolerance for the SVD approximation.

  • --chunk_size (int, default: 4096):
    Number of SNPs in chunk operations for SVD.

  • --threads (int, default: 1):
    Number of CPU threads used during execution.

License

NOTICE: This software is available for use free of charge for academic research use only. Academic users may fork this repository and modify and improve to suit their research needs, but also inherit these terms and must include a licensing notice to that effect. Commercial users, for profit companies or consultants, and non-profit institutions not qualifying as "academic research" should contact the authors for a separate license. This applies to this repository directly and any other repository that includes source, executables, or git commands that pull/clone this repository as part of its function. Such repositories, whether ours or others, must include this notice.

Troubleshooting

CUDA issues

If you get an error similar to the following when using the GPU:

OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

Simply installing nvcc using conda or mamba should fix it:

$ conda install -c nvidia nvcc

macOS compilation issues

If you get errors related to OpenMP (OMP) during installation on macOS, ensure you have libomp installed via Homebrew:

$ brew install libomp

Cite

When using this software, please cite the following pre-print:

@article{saurina2026adamixture,
  title={ADAMIXTURE: Adaptive First-Order Optimization for Biobank-Scale Genetic Clustering},
  author={Saurina-i-Ricos, Joan and Mas Monserrat, Daniel and Ioannidis, Alexander G.},
  journal={bioRxiv},
  year={2026},
  doi={10.64898/2026.02.13.700171},
  url={https://doi.org/10.64898/2026.02.13.700171}
}

Project details


Download files

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

Source Distribution

adamixture-1.5.0.tar.gz (3.1 MB view details)

Uploaded Source

Built Distributions

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

adamixture-1.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (653.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

adamixture-1.5.0-cp312-cp312-macosx_14_0_x86_64.whl (548.9 kB view details)

Uploaded CPython 3.12macOS 14.0+ x86-64

adamixture-1.5.0-cp312-cp312-macosx_14_0_arm64.whl (789.3 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

adamixture-1.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (654.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

adamixture-1.5.0-cp311-cp311-macosx_14_0_x86_64.whl (546.2 kB view details)

Uploaded CPython 3.11macOS 14.0+ x86-64

adamixture-1.5.0-cp311-cp311-macosx_14_0_arm64.whl (786.6 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

adamixture-1.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (661.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

adamixture-1.5.0-cp310-cp310-macosx_14_0_x86_64.whl (549.5 kB view details)

Uploaded CPython 3.10macOS 14.0+ x86-64

adamixture-1.5.0-cp310-cp310-macosx_14_0_arm64.whl (789.3 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file adamixture-1.5.0.tar.gz.

File metadata

  • Download URL: adamixture-1.5.0.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for adamixture-1.5.0.tar.gz
Algorithm Hash digest
SHA256 fb6bd0c9532175f28bb9886e8eef6069351aef6ef11340fcc866be35a3a0000b
MD5 5c84f358527f349e609cc4f5189a164e
BLAKE2b-256 dde3b2d44dd2641dd95374c9b09a4fbfb0d36a9f714f477361ec0444b2ff77fb

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f64f1ee7335444bcc0f257115fd7e43895502a5c1d7e410f3fb2ea96a8bcbeec
MD5 76342b2e2d318696392e6c0c22aa83c7
BLAKE2b-256 50f52b4d3b5a005263333cf8f6ec8235eb53770703aac4a19370221bf3bb23c1

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp312-cp312-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp312-cp312-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 ba37e890b4f3bef55873b0b87d1d5c432cb4d315bae401175baae1061c8d67ef
MD5 0b7337f84d7d9498ffa267684eeefe25
BLAKE2b-256 c89d9776e93727908fcab0d5841d8a6e9477e0286d729188007b518d0ebcfd46

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d47d252d681b5730e0c93eeed6ffacb5ab8db94caa8f9daea8867588e3e4c8ea
MD5 edfbe2160804aedbfc4cd39f8c00a604
BLAKE2b-256 c69f8a66d2b8700cfb6d1de342717bf39f837178c4f0e077b0aa53b80f5a225e

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8da2dc2fb5f18863b7ced28365ab873a4b8909cc21a164a18f108c0d12a79a2
MD5 3931cd93386ac38b721282bc309b5eee
BLAKE2b-256 89d7d8dd1a3753e1927000ede2254394ee2d6429b41581fd1fe4c52f63898ca9

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp311-cp311-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp311-cp311-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 333a641bbf9e38a2cdf695d2d0b06349086f17297229e04e347f57bb85ce0a20
MD5 42cafe21f404dc8e2e3b68a793d46953
BLAKE2b-256 5d1ff66795e3ac1bb4019dfbd378aed0caeb1c78556cc88d1909ae52635bb59a

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 98a1c3d12608a931481f6aa56a277893fbf7c3d2bd0f8f5531add55784b88200
MD5 a6869e461c5c39f4b16766b6d6baff3b
BLAKE2b-256 c7ed1ff3ef97a57c6b10a85f7c6426a4de0935dba33a0c0cc9da376d8bfe8ba0

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1449a9a8322f8abf87251e811d14806e422af45f0f14f6063c1effeba783db48
MD5 a10fd8516a809175717d24e83dfa8728
BLAKE2b-256 b8fdce1c744e4b953da7ba82a2370edda817d69404be7fa41ecd36dcbde8dd7c

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp310-cp310-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp310-cp310-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 05d08fefe4c50ebda660183ea0aa7632566ba36b28e5327cb69a80000935dd4b
MD5 9c45fccb5037dfacf33f512d984dbba2
BLAKE2b-256 83db65e62837fa333089914cfb2b85bdd32f1b9d45637c82665c113bbb7a4ea2

See more details on using hashes here.

File details

Details for the file adamixture-1.5.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for adamixture-1.5.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0d5e1397d7d498c1a6bede0ddcfcb7995d4e4c0f99011f14721a8c14c602803a
MD5 f4b8b075f5e98b828a04ba7497045d68
BLAKE2b-256 7faaa8a2d8f4224e320c278743e2a07db1557c2703bba658ff76768130d902d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page