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.

[!TIP] Biobank-Scale Execution & High K Values: For large-scale datasets (e.g., UK Biobank, All of Us) with high K values, we recommend the following parameter settings for optimal convergence and performance:

--patience_adam 5 \
--lr_decay 0.85 \
--lr 0.0075

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.2.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.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

adamixture-1.5.2-cp312-cp312-macosx_14_0_x86_64.whl (566.7 kB view details)

Uploaded CPython 3.12macOS 14.0+ x86-64

adamixture-1.5.2-cp312-cp312-macosx_14_0_arm64.whl (795.7 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

adamixture-1.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (660.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

adamixture-1.5.2-cp311-cp311-macosx_14_0_x86_64.whl (561.4 kB view details)

Uploaded CPython 3.11macOS 14.0+ x86-64

adamixture-1.5.2-cp311-cp311-macosx_14_0_arm64.whl (791.4 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

adamixture-1.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (667.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

adamixture-1.5.2-cp310-cp310-macosx_14_0_x86_64.whl (563.8 kB view details)

Uploaded CPython 3.10macOS 14.0+ x86-64

adamixture-1.5.2-cp310-cp310-macosx_14_0_arm64.whl (794.6 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: adamixture-1.5.2.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.2.tar.gz
Algorithm Hash digest
SHA256 188081ac9b3a6c1f1efdb7ee36ca48cbbb73aaa909b240ac99d573515568eae9
MD5 343ea2e2c7af9894bc737dd3a80b7b82
BLAKE2b-256 16d55f2b58b5081e8af224120f46c0d12c10c3025eced4dbb52d8056ea75b545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 103083ed25ab7465a717a670433ab763d3498782ea6b7d2d7e002d47f8ebcb2a
MD5 55e210c4c75d85632d9e10fb4ca00f3a
BLAKE2b-256 67405ba594c2cf29c9c50467b9ce47034b0defaa0881c1dcc10250d90c91298a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp312-cp312-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 5c8e1f674cab4e2e95d2247612495e72bcdc7fc5e715c9b9970fe20623efcde3
MD5 b5350355c33f04b1da33a5afa9a3eaf5
BLAKE2b-256 63fcce5ca77f8d73cf2f5e681e0350347fdddfc08bf20799c58b1ee4f9e2551e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c2b7a790741ef10ac43f9e9f6b92c39859d2306bfa100567f4863aff1af12f6a
MD5 72a90b45fdd6703bc5ac8e9dbdb943cb
BLAKE2b-256 fabb38839c81ea3fc28abc4a54ff9c56e5567880c5ab7cb3e5b984415678c50d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86dd672f2d0d34d9500b5f438621c6f1bced22d2a4db73defb5e72fb5063da21
MD5 1b8cd81c6f59a6448496781eb566c2d7
BLAKE2b-256 3c1e50cbe63cf0e14e731b0aa7c943fc7c7c5dcff41a30b37aabebe13218123c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp311-cp311-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 ff9cb80623deec1066ba6f8d94948c5eaece74d6a3ab58c74ba857a4e654d45d
MD5 ec512aefa33d92393a8846f1ec323b90
BLAKE2b-256 f391be190d435e02560d937c7b8313d888060fa2cbd63972569ed021e36d9a6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d934e33bbc4443a56dafcd4942626ccc8cb6ec5692dae320b8f2f77b09e39998
MD5 80d10d8c1cefa0527a696c8773d23027
BLAKE2b-256 9be4b410fb602c8815a3b9d92ba8e532fdc4d29680a7d43c2068f35d9037d376

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 429f304280007a1b4b2aeda0dcdec5a68cd201ab1d6d4e55bcab3ef07b8fa4a8
MD5 7d70c9c12051a08daf8afc81b0b90cdc
BLAKE2b-256 09f6ce5102a0da34b694e0cfd237c2fbf28cce1ee0463cc06a811942da12deff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp310-cp310-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 75162cc3b338adf132a919962bd14ae667aeb56a124fe98d0004926c698a8ac8
MD5 a0a989ba03037637dbe676272cb579fc
BLAKE2b-256 e49279d4bb90b2e36d3692876a9eb8e316837a06f5e5c715c0c9f8ae59ec20c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adamixture-1.5.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fa9343c8ac1df9371b8c644c33a6f224bf9e69314d5f721b153d477c6bc443e4
MD5 b88a36e5b2004a77c3549ab92208d67d
BLAKE2b-256 939e1102d6535c4e5544b666c56ce87111339715e5dfc09fbf8f5001861e17fd

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