fastmixture2 2.2.0__tar.gz → 2.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/MANIFEST.in +1 -1
  2. {fastmixture2-2.2.0/fastmixture2.egg-info → fastmixture2-2.3.0}/PKG-INFO +89 -42
  3. fastmixture2-2.3.0/README.md +231 -0
  4. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/__init__.py +1 -1
  5. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/em.pyx +124 -53
  6. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/fastmixture2.py +269 -227
  7. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/functions.py +232 -91
  8. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/gpu.py +2918 -908
  9. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/kernels.py +47 -18
  10. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/main.py +5 -1
  11. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/math.pxd +60 -43
  12. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/packed.pxd +243 -58
  13. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/plink.py +200 -98
  14. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/shared.pyx +1557 -435
  15. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/sqp.pyx +602 -262
  16. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/svd.pyx +477 -38
  17. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/utils.py +861 -345
  18. {fastmixture2-2.2.0 → fastmixture2-2.3.0/fastmixture2.egg-info}/PKG-INFO +89 -42
  19. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/setup.py +27 -15
  20. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_adversarial_io.py +414 -8
  21. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_bootstrap.py +68 -6
  22. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_cli.py +325 -44
  23. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_convergence.py +108 -0
  24. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_cpu_scaling.py +805 -34
  25. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_cross_validation.py +229 -1
  26. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_genotypes.py +169 -1
  27. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_gpu_init.py +181 -2
  28. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_gpu_kernels.py +510 -7
  29. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_gpu_planning.py +333 -21
  30. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_gpu_streaming.py +1 -1
  31. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_initialization.py +95 -4
  32. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_likelihoods.py +163 -1
  33. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_numerical_equivalence.py +231 -1
  34. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_plink_files.py +83 -0
  35. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_restarts.py +54 -21
  36. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_sample_subset.py +4 -4
  37. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_sqp_solver.py +64 -33
  38. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_threads.py +30 -0
  39. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/validate_distribution.py +57 -13
  40. fastmixture2-2.2.0/README.md +0 -184
  41. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/LICENSE +0 -0
  42. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2/defaults.py +0 -0
  43. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2.egg-info/SOURCES.txt +0 -0
  44. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2.egg-info/dependency_links.txt +0 -0
  45. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2.egg-info/entry_points.txt +0 -0
  46. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2.egg-info/requires.txt +0 -0
  47. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/fastmixture2.egg-info/top_level.txt +0 -0
  48. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/pyproject.toml +0 -0
  49. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/setup.cfg +0 -0
  50. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/check_portable.py +0 -0
  51. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/helpers.py +0 -0
  52. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/run_tests.py +0 -0
  53. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_gpu_modes.py +0 -0
  54. {fastmixture2-2.2.0 → fastmixture2-2.3.0}/tests/test_optimizers.py +0 -0
@@ -7,4 +7,4 @@ prune releases
7
7
  prune tmp
8
8
  prune .agents
9
9
  prune .codex
10
- global-exclude .DS_Store *.py[cod] *.so
10
+ global-exclude .DS_Store *.py[cod] *.so *.pyd *.dylib
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastmixture2
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Biobank-scale ancestry estimation in unrelated individuals
5
5
  Author-email: "J. Meisner" <meisnerucph@gmail.com>, "L. Thunegard" <lisathunegard@icloud.com>
6
6
  License-Expression: GPL-3.0-only
@@ -29,10 +29,10 @@ Provides-Extra: gpu-cuda13
29
29
  Requires-Dist: cupy-cuda13x[ctk]>=14.0; extra == "gpu-cuda13"
30
30
  Dynamic: license-file
31
31
 
32
- # fastmixture2 (v2.2.0)
32
+ # fastmixture2 (v2.3.0)
33
33
 
34
34
  <p align="center">
35
- <img src="assets/fastmixture2-logo-small-wordmark.png" alt="fastmixture2 logo" width="300">
35
+ <img src="https://raw.githubusercontent.com/MeisnerLab/fastmixture2/main/assets/fastmixture2-logo-small-wordmark.png" alt="fastmixture2 logo" width="300">
36
36
  </p>
37
37
 
38
38
  <p align="center">
@@ -46,6 +46,9 @@ frequencies (`P`) by maximum likelihood from PLINK genotypes or ANGSD Beagle
46
46
  genotype likelihoods. It supports unsupervised, supervised and projection modes
47
47
  on CPU and NVIDIA CUDA.
48
48
 
49
+ ## Citation
50
+ Please cite our preprint on [BioRxiv](https://www.biorxiv.org/content/10.64898/2026.11.30.770199v1).
51
+
49
52
  ## Installation
50
53
 
51
54
  Use Python 3.11+. PyPI wheels support Linux (glibc) and macOS 15+ on x86-64
@@ -94,11 +97,27 @@ contribute no information. Unsupervised fits use SVD/ALS by default.
94
97
  `--random-init` uses random P/Q starts for the fit and any `--exact-cv` folds.
95
98
 
96
99
  Defaults are `--threads 1`, `--seed 42`, `--iter 1000` and `--tole 1e-10`.
97
- Match `--threads` to your CPU allocation; on streamed `--gpu` runs, extra
100
+ Match `--threads` to your CPU allocation. On streamed `--gpu` runs, extra
98
101
  threads also stage host tiles asynchronously. Iteration limits and likelihood
99
102
  tolerances apply per fit stage. The tolerance is mean likelihood gain per
100
103
  informative entry. See `fastmixture2 --help` for all options.
101
104
 
105
+ ## Modes and options
106
+
107
+ `fastmixture2` runs in one of three mutually exclusive estimation modes (unsupervised
108
+ by default), with optional cross-validation, bootstrap standard errors and
109
+ checkpointing.
110
+
111
+ | Mode | Trigger | Mode-specific options | Compatible add-ons |
112
+ | --- | --- | --- | --- |
113
+ | **Unsupervised** | *(default)* | `--random-init`, `--restarts`, `--cv`, `--exact-cv`, `--cv-tole` | `--bootstrap`, `--checkpoint` / `--resume` |
114
+ | **Supervised** | `--supervised FILE` | — | `--bootstrap`, `--checkpoint` / `--resume` |
115
+ | **Projection** | `--projection FILE` | `--allow-ambiguous` | `--bootstrap`, `--checkpoint` / `--resume` |
116
+
117
+ All modes accept `--bfile` or `--beagle`, `--K` (`1`–`128`), `--threads`, `--seed`,
118
+ `--gpu`, `--iter`, `--tole`, `--out`, `--write-info` and `--no-freqs` (projection
119
+ always omits `P`).
120
+
102
121
  ### Scratch and Beagle caches
103
122
 
104
123
  Use `TMPDIR` or `SLURM_TMPDIR` for disk-backed scratch with space for input,
@@ -107,11 +126,12 @@ node-local disk and use its local prefixes. Recognized bucket mounts stage
107
126
  mapped input once per command and publish each fit's outputs after it finishes.
108
127
  Bucket output requires file replacement support.
109
128
 
110
- Use `--gl-cache FILE` to reuse parsed Beagle data across commands or
111
- `--save-gl-cache` to use `OUTPUT.gl.npy`. The cache uses about
112
- `12 × variants × samples` bytes and stores sample and variant metadata
113
- alongside it so `--write-info`, `--supervised` and `--projection` avoid
114
- rereading the gzipped Beagle input. Invalid caches are rebuilt.
129
+ - `--gl-cache FILE` — Read or write an explicit parsed Beagle cache (`--beagle` only).
130
+ - `--save-gl-cache` — Reuse or create `OUTPUT.gl.npy` as the Beagle cache (`--beagle` only).
131
+
132
+ The cache uses about `12 × variants × samples` bytes and stores sample, variant
133
+ and pooled-frequency metadata alongside it so `--write-info`, `--supervised` and
134
+ `--projection` avoid rereading the gzipped Beagle input. Invalid caches are rebuilt.
115
135
 
116
136
  ### Supervised estimation
117
137
 
@@ -122,16 +142,18 @@ fastmixture2 --bfile cohort --K 5 --threads 8 \
122
142
  --supervised populations.txt --out cohort.supervised
123
143
  ```
124
144
 
125
- Use labels `1` through `K` for references and `0` for unassigned samples.
126
- Provide at least one reference. Supply labels in sample order or use
127
- `FID IID POP` columns to validate the order. Use each Beagle sample label
128
- as both FID and IID.
145
+ - `--supervised FILE` — Population assignment file with labels `1`..`K` for
146
+ references and `0` for unassigned samples (at least one reference required).
147
+ - Supply labels in sample order or use `FID IID POP` columns to validate order
148
+ (use each Beagle sample label as both `FID` and `IID`).
149
+ - Supports `--bootstrap` (fixed reference rows have zero standard error) and
150
+ `--checkpoint` / `--resume`. Not compatible with `--random-init`, `--restarts`
151
+ or `--cv`.
129
152
 
130
153
  ### Projection
131
154
 
132
- Estimate Q for new samples with fixed reference P. Use `--write-info` when
155
+ Estimate Q for new samples against fixed reference P. Use `--write-info` when
133
156
  fitting the reference panel so projection can check marker IDs and alleles.
134
- Projection accepts multiple seeds with the K of the reference P.
135
157
 
136
158
  ```bash
137
159
  fastmixture2 --bfile reference --K 5 --threads 8 --write-info --out reference
@@ -139,60 +161,85 @@ fastmixture2 --bfile new_samples --K 5 --threads 8 \
139
161
  --projection reference.K5.s42.P --out new_samples.projected
140
162
  ```
141
163
 
142
- Use the same markers in order. Annotated P files include `SNP A1 A2` and
143
- support allele swaps and strand complements. Remove ambiguous A/T and C/G
144
- variants or use `--allow-ambiguous` when both panels share a strand convention.
145
- Numeric P files assume matching alleles.
164
+ - `--projection FILE` — Fixed reference P file matching the target markers in
165
+ order. Accepts multiple `--seed` values at the single `K` of `P`.
166
+ - `--allow-ambiguous` — Trust listed allele order for strand-ambiguous A/T and
167
+ C/G variants in annotated `P` files (otherwise remove them).
168
+ - Annotated `P` files (`SNP A1 A2`) handle allele swaps and strand complements,
169
+ while plain numeric `P` files assume matching counted alleles.
170
+ - Omits `P` output and supports `--bootstrap` (conditioned on `P`) and
171
+ `--checkpoint` / `--resume`. Not compatible with `--random-init`, `--restarts`
172
+ or `--cv`.
146
173
 
147
174
  ### Cross-validation
148
175
 
149
- Compare K values using the same seed and number of folds. Lower scores are better.
176
+ Compare K values in unsupervised mode using the same seed and number of folds.
177
+ Lower scores are better.
150
178
 
151
179
  ```bash
152
180
  fastmixture2 --bfile cohort --K 4 5 6 --threads 8 --seed 42 --cv 5 --out cohort.cv
153
181
  ```
154
182
 
155
- CV for unsupervised fits starts from the full-data estimates by default.
156
- Use `--exact-cv` for independent training-only starts, `--cv-tole` for fold
157
- tolerance and `--K 1` for a pooled-frequency baseline. PLINK scores use half
158
- binomial deviance and Beagle scores use mean negative log marginal likelihood.
159
- Check fold convergence in the log. Mapped CPU CV can use an extra BED-sized
160
- scratch file.
183
+ - `--cv INT` — Number of entry-masked folds (at least `2`, unsupervised only,
184
+ cannot be combined with `--bootstrap`). Starts from full-data estimates by default.
185
+ - `--exact-cv` — Fit each fold independently from training-only starts instead of
186
+ warm-starting from the full-data fit (respects `--random-init`).
187
+ - `--cv-tole FLOAT` — Fold convergence tolerance (default `1e-7`).
188
+
189
+ Use `--K 1` for a pooled-frequency baseline. PLINK scores use half binomial
190
+ deviance and Beagle scores use mean negative log marginal likelihood. Check fold
191
+ convergence in the log. Mapped CPU CV can use an extra BED-sized scratch file.
161
192
 
162
193
  ### Bootstrap uncertainty
163
194
 
164
- Estimate Q standard errors by resampling blocks of neighboring SNPs.
195
+ Estimate Q standard errors in any mode by resampling blocks of neighboring SNPs.
165
196
 
166
197
  ```bash
167
198
  fastmixture2 --bfile cohort --K 5 --threads 8 \
168
199
  --bootstrap 200 --bootstrap-block 1500 --out cohort
169
200
  ```
170
201
 
171
- `--bootstrap` defaults to 200 replicates with up to three iterations each.
172
- Use `--bootstrap-iter` and `--bootstrap-tole` to control refits. PLINK blocks
173
- stay within chromosomes and average 10 cM with a usable BIM map.
174
- `--bootstrap-block` sets the length in SNPs and is required for PLINK without
175
- a usable map and for Beagle. Projection conditions on P. Fixed reference
176
- rows have zero standard error. Run bootstrap and CV separately.
202
+ - `--bootstrap [INT]` — Number of moving-block replicates (default `200`, at
203
+ least `2`, cannot be combined with `--cv`).
204
+ - `--bootstrap-block INT` — Block length in SNPs. Defaults to ~10 cM within
205
+ chromosomes when PLINK `.bim` has a usable genetic map, and is required for
206
+ unmapped PLINK and for `--beagle`.
207
+ - `--bootstrap-iter INT` — Maximum SQP/ZAL iterations per replicate (default `3`).
208
+ - `--bootstrap-tole FLOAT` — Optional early-stopping likelihood tolerance per
209
+ replicate (disabled by default).
210
+
211
+ Projection conditions on fixed `P`. Fixed supervised reference rows have zero
212
+ standard error.
177
213
 
178
214
  ### Restarts
179
215
 
180
- `--restarts N` (default 0) applies independently to every unsupervised K and
181
- seed. Each round tries a Q permutation and, at K ≥ 3, a merge/split proposal.
182
- K = 1 skips restarts. Each fit keeps its best full-data likelihood and records
183
- the choice in its log.
216
+ Escape local optima in unsupervised fits by running structured perturbation rounds.
217
+
218
+ - `--restarts INT` — Restart rounds per unsupervised `K` and seed (default `0`,
219
+ skipped at `K = 1`, unsupervised only).
220
+ - Each round tests a `Q` permutation and, at `K ≥ 3`, a merge/split proposal,
221
+ keeping the highest full-data log-likelihood and recording the selection in the log.
184
222
 
185
223
  ### Checkpointing
186
224
 
187
- Save accepted estimates and resume an interrupted fit.
225
+ Save accepted optimizer states and resume an interrupted single fit or
226
+ multi-K/multi-seed batch.
188
227
 
189
228
  ```bash
190
- fastmixture2 --bfile cohort --K 5 --threads 8 --checkpoint run.ckpt --out cohort
191
- fastmixture2 --bfile cohort --K 5 --threads 8 --resume run.ckpt --out cohort
229
+ fastmixture2 --bfile cohort --K 4 5 --seed 42 43 --threads 8 \
230
+ --checkpoint run.ckpt --out cohort
231
+ fastmixture2 --bfile cohort --K 4 5 --seed 42 43 --threads 8 \
232
+ --resume run.ckpt --out cohort
192
233
  ```
193
234
 
194
- Checkpoint and resume require one K and seed. Resume with the same input files,
195
- mode, K and seed. Use `--restarts` to add rounds after the resumed fit.
235
+ - `--checkpoint FILE` — Atomically save accepted state every `25` iterations or
236
+ `10` minutes. Multi-fit batches store a manifest in `FILE` and active fit state
237
+ in `FILE.fit.npz`.
238
+ - `--resume FILE` — Continue from a saved checkpoint or batch manifest (skipping
239
+ verified completed fits) using the same inputs, mode, options, `--K` and `--seed`.
240
+ Updates `FILE` in place unless a new `--checkpoint` path is also given.
241
+ - Use `--restarts` on a single resumed fit to run additional restart rounds after
242
+ convergence.
196
243
 
197
244
  ## Output
198
245
 
@@ -0,0 +1,231 @@
1
+ # fastmixture2 (v2.3.0)
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/MeisnerLab/fastmixture2/main/assets/fastmixture2-logo-small-wordmark.png" alt="fastmixture2 logo" width="300">
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://github.com/MeisnerLab/fastmixture2/actions/workflows/ci.yml"><img src="https://github.com/MeisnerLab/fastmixture2/actions/workflows/ci.yml/badge.svg" alt="Tests"></a>
9
+ <a href="https://pypi.org/project/fastmixture2/"><img src="https://img.shields.io/pypi/v/fastmixture2.svg" alt="PyPI"></a>
10
+ <a href="https://github.com/MeisnerLab/fastmixture2/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="License: GPL v3"></a>
11
+ </p>
12
+
13
+ `fastmixture2` estimates ancestry proportions (`Q`) and ancestral allele
14
+ frequencies (`P`) by maximum likelihood from PLINK genotypes or ANGSD Beagle
15
+ genotype likelihoods. It supports unsupervised, supervised and projection modes
16
+ on CPU and NVIDIA CUDA.
17
+
18
+ ## Citation
19
+ Please cite our preprint on [BioRxiv](https://www.biorxiv.org/content/10.64898/2026.11.30.770199v1).
20
+
21
+ ## Installation
22
+
23
+ Use Python 3.11+. PyPI wheels support Linux (glibc) and macOS 15+ on x86-64
24
+ and ARM64, with AVX-512, AVX2, and NEON where available. For CUDA, use
25
+ `python -m pip install 'fastmixture2[gpu-cuda13]'` with a compatible NVIDIA
26
+ driver and pass `--gpu` when fitting.
27
+
28
+ ```bash
29
+ python -m pip install fastmixture2
30
+ ```
31
+
32
+ Build from source for native CPU tuning. Install a C compiler and OpenMP
33
+ (`brew install libomp` on macOS).
34
+
35
+ ```bash
36
+ git clone https://github.com/MeisnerLab/fastmixture2.git
37
+ cd fastmixture2
38
+ python -m pip install .
39
+ ```
40
+
41
+ Use `python -m pip install '.[gpu-cuda13]'` for a CUDA source build.
42
+ For Conda, run `conda env create -f environment-cpu.yml` or use
43
+ `environment-gpu.yml` and activate `fastmixture2-cpu` or `fastmixture2-gpu`.
44
+ With [uv](https://docs.astral.sh/uv/), use `uv pip install` with the same arguments.
45
+
46
+ ## Quick start
47
+
48
+ ```bash
49
+ fastmixture2 --bfile cohort --K 5 --threads 8 --out cohort
50
+ fastmixture2 --beagle cohort.beagle.gz --K 5 --threads 8 --out cohort.gl
51
+ fastmixture2 --bfile chr{1..22} --K 4 5 6 --seed 42 43 --restarts 2 --threads 8 --out cohort
52
+ ```
53
+
54
+ `--bfile` accepts one SNP-major PLINK prefix or ordered chromosome prefixes.
55
+ The FAM files must have the same FID/IID pairs in the same order. `--beagle`
56
+ accepts gzipped ANGSD Beagle likelihoods.
57
+
58
+ Lists of K values and seeds run every combination sequentially. Fits share
59
+ the loaded data and reuse common initialization work where possible. Each
60
+ fit has its own outputs and log. For each K, keep the converged fit with the
61
+ highest log-likelihood and align components before comparing Q or P.
62
+
63
+ Both devices support K from 1 to 128. Remove monomorphic and uninformative
64
+ variants before fitting. Missing calls and uniform likelihood triplets
65
+ contribute no information. Unsupervised fits use SVD/ALS by default.
66
+ `--random-init` uses random P/Q starts for the fit and any `--exact-cv` folds.
67
+
68
+ Defaults are `--threads 1`, `--seed 42`, `--iter 1000` and `--tole 1e-10`.
69
+ Match `--threads` to your CPU allocation. On streamed `--gpu` runs, extra
70
+ threads also stage host tiles asynchronously. Iteration limits and likelihood
71
+ tolerances apply per fit stage. The tolerance is mean likelihood gain per
72
+ informative entry. See `fastmixture2 --help` for all options.
73
+
74
+ ## Modes and options
75
+
76
+ `fastmixture2` runs in one of three mutually exclusive estimation modes (unsupervised
77
+ by default), with optional cross-validation, bootstrap standard errors and
78
+ checkpointing.
79
+
80
+ | Mode | Trigger | Mode-specific options | Compatible add-ons |
81
+ | --- | --- | --- | --- |
82
+ | **Unsupervised** | *(default)* | `--random-init`, `--restarts`, `--cv`, `--exact-cv`, `--cv-tole` | `--bootstrap`, `--checkpoint` / `--resume` |
83
+ | **Supervised** | `--supervised FILE` | — | `--bootstrap`, `--checkpoint` / `--resume` |
84
+ | **Projection** | `--projection FILE` | `--allow-ambiguous` | `--bootstrap`, `--checkpoint` / `--resume` |
85
+
86
+ All modes accept `--bfile` or `--beagle`, `--K` (`1`–`128`), `--threads`, `--seed`,
87
+ `--gpu`, `--iter`, `--tole`, `--out`, `--write-info` and `--no-freqs` (projection
88
+ always omits `P`).
89
+
90
+ ### Scratch and Beagle caches
91
+
92
+ Use `TMPDIR` or `SLURM_TMPDIR` for disk-backed scratch with space for input,
93
+ initialization and outputs. For shared filesystems, copy the panel once to
94
+ node-local disk and use its local prefixes. Recognized bucket mounts stage
95
+ mapped input once per command and publish each fit's outputs after it finishes.
96
+ Bucket output requires file replacement support.
97
+
98
+ - `--gl-cache FILE` — Read or write an explicit parsed Beagle cache (`--beagle` only).
99
+ - `--save-gl-cache` — Reuse or create `OUTPUT.gl.npy` as the Beagle cache (`--beagle` only).
100
+
101
+ The cache uses about `12 × variants × samples` bytes and stores sample, variant
102
+ and pooled-frequency metadata alongside it so `--write-info`, `--supervised` and
103
+ `--projection` avoid rereading the gzipped Beagle input. Invalid caches are rebuilt.
104
+
105
+ ### Supervised estimation
106
+
107
+ Estimate P jointly with Q for unassigned samples, keeping reference Q rows fixed.
108
+
109
+ ```bash
110
+ fastmixture2 --bfile cohort --K 5 --threads 8 \
111
+ --supervised populations.txt --out cohort.supervised
112
+ ```
113
+
114
+ - `--supervised FILE` — Population assignment file with labels `1`..`K` for
115
+ references and `0` for unassigned samples (at least one reference required).
116
+ - Supply labels in sample order or use `FID IID POP` columns to validate order
117
+ (use each Beagle sample label as both `FID` and `IID`).
118
+ - Supports `--bootstrap` (fixed reference rows have zero standard error) and
119
+ `--checkpoint` / `--resume`. Not compatible with `--random-init`, `--restarts`
120
+ or `--cv`.
121
+
122
+ ### Projection
123
+
124
+ Estimate Q for new samples against fixed reference P. Use `--write-info` when
125
+ fitting the reference panel so projection can check marker IDs and alleles.
126
+
127
+ ```bash
128
+ fastmixture2 --bfile reference --K 5 --threads 8 --write-info --out reference
129
+ fastmixture2 --bfile new_samples --K 5 --threads 8 \
130
+ --projection reference.K5.s42.P --out new_samples.projected
131
+ ```
132
+
133
+ - `--projection FILE` — Fixed reference P file matching the target markers in
134
+ order. Accepts multiple `--seed` values at the single `K` of `P`.
135
+ - `--allow-ambiguous` — Trust listed allele order for strand-ambiguous A/T and
136
+ C/G variants in annotated `P` files (otherwise remove them).
137
+ - Annotated `P` files (`SNP A1 A2`) handle allele swaps and strand complements,
138
+ while plain numeric `P` files assume matching counted alleles.
139
+ - Omits `P` output and supports `--bootstrap` (conditioned on `P`) and
140
+ `--checkpoint` / `--resume`. Not compatible with `--random-init`, `--restarts`
141
+ or `--cv`.
142
+
143
+ ### Cross-validation
144
+
145
+ Compare K values in unsupervised mode using the same seed and number of folds.
146
+ Lower scores are better.
147
+
148
+ ```bash
149
+ fastmixture2 --bfile cohort --K 4 5 6 --threads 8 --seed 42 --cv 5 --out cohort.cv
150
+ ```
151
+
152
+ - `--cv INT` — Number of entry-masked folds (at least `2`, unsupervised only,
153
+ cannot be combined with `--bootstrap`). Starts from full-data estimates by default.
154
+ - `--exact-cv` — Fit each fold independently from training-only starts instead of
155
+ warm-starting from the full-data fit (respects `--random-init`).
156
+ - `--cv-tole FLOAT` — Fold convergence tolerance (default `1e-7`).
157
+
158
+ Use `--K 1` for a pooled-frequency baseline. PLINK scores use half binomial
159
+ deviance and Beagle scores use mean negative log marginal likelihood. Check fold
160
+ convergence in the log. Mapped CPU CV can use an extra BED-sized scratch file.
161
+
162
+ ### Bootstrap uncertainty
163
+
164
+ Estimate Q standard errors in any mode by resampling blocks of neighboring SNPs.
165
+
166
+ ```bash
167
+ fastmixture2 --bfile cohort --K 5 --threads 8 \
168
+ --bootstrap 200 --bootstrap-block 1500 --out cohort
169
+ ```
170
+
171
+ - `--bootstrap [INT]` — Number of moving-block replicates (default `200`, at
172
+ least `2`, cannot be combined with `--cv`).
173
+ - `--bootstrap-block INT` — Block length in SNPs. Defaults to ~10 cM within
174
+ chromosomes when PLINK `.bim` has a usable genetic map, and is required for
175
+ unmapped PLINK and for `--beagle`.
176
+ - `--bootstrap-iter INT` — Maximum SQP/ZAL iterations per replicate (default `3`).
177
+ - `--bootstrap-tole FLOAT` — Optional early-stopping likelihood tolerance per
178
+ replicate (disabled by default).
179
+
180
+ Projection conditions on fixed `P`. Fixed supervised reference rows have zero
181
+ standard error.
182
+
183
+ ### Restarts
184
+
185
+ Escape local optima in unsupervised fits by running structured perturbation rounds.
186
+
187
+ - `--restarts INT` — Restart rounds per unsupervised `K` and seed (default `0`,
188
+ skipped at `K = 1`, unsupervised only).
189
+ - Each round tests a `Q` permutation and, at `K ≥ 3`, a merge/split proposal,
190
+ keeping the highest full-data log-likelihood and recording the selection in the log.
191
+
192
+ ### Checkpointing
193
+
194
+ Save accepted optimizer states and resume an interrupted single fit or
195
+ multi-K/multi-seed batch.
196
+
197
+ ```bash
198
+ fastmixture2 --bfile cohort --K 4 5 --seed 42 43 --threads 8 \
199
+ --checkpoint run.ckpt --out cohort
200
+ fastmixture2 --bfile cohort --K 4 5 --seed 42 43 --threads 8 \
201
+ --resume run.ckpt --out cohort
202
+ ```
203
+
204
+ - `--checkpoint FILE` — Atomically save accepted state every `25` iterations or
205
+ `10` minutes. Multi-fit batches store a manifest in `FILE` and active fit state
206
+ in `FILE.fit.npz`.
207
+ - `--resume FILE` — Continue from a saved checkpoint or batch manifest (skipping
208
+ verified completed fits) using the same inputs, mode, options, `--K` and `--seed`.
209
+ Updates `FILE` in place unless a new `--checkpoint` path is also given.
210
+ - Use `--restarts` on a single resumed fit to run additional restart rounds after
211
+ convergence.
212
+
213
+ ## Output
214
+
215
+ The table shows the files for `--out cohort --K 5 --seed 42`.
216
+
217
+ | File | Contents |
218
+ | --- | --- |
219
+ | `cohort.K5.s42.Q` | Ancestry proportions, one row per sample |
220
+ | `cohort.K5.s42.P` | Allele frequencies, one row per variant |
221
+ | `cohort.K5.s42.Q_se` | Q standard errors when bootstrap is requested |
222
+ | `cohort.K5.s42.log` | Settings, timing, convergence, likelihood and optional analysis summaries |
223
+
224
+ Rows follow input order. `--write-info` adds headers and IDs. P gives the
225
+ frequency of BIM A1 for PLINK and allele2 for Beagle. Projection and `--no-freqs` omit P.
226
+ Use separate `--out` prefixes for concurrent fits with the same K and seed.
227
+
228
+ ## Authors and license
229
+
230
+ Lisa Thunegard and Jonas Meisner. Developed at **MeisnerLab** and distributed
231
+ under the [GNU General Public License v3.0](https://github.com/MeisnerLab/fastmixture2/blob/main/LICENSE).
@@ -1,4 +1,4 @@
1
1
  """Version metadata for fastmixture2."""
2
2
 
3
3
  __author__ = "Jonas Meisner"
4
- __version__ = "2.2.0"
4
+ __version__ = "2.3.0"