rfmix-reader 0.3.0__tar.gz → 0.3.1__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.
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/PKG-INFO +27 -13
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/README.md +17 -8
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/pyproject.toml +6 -1
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/processing/imputation.py +0 -3
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/processing/phase.py +13 -1
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/LICENSE +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/__init__.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/_testing.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/base.svg.p +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/cli/__init__.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/cli/create_binaries.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/cli/merge_phased_zarrs.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/cli/prepare_reference.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/io/__init__.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/io/chunk.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/io/errors.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/io/loci_bed.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/io/prepare_reference.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/io/write_data.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/processing/__init__.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/processing/_hmm_lai.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/processing/constants.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/readers/__init__.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/readers/fb_read.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/readers/read_flare.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/readers/read_rfmix.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/readers/read_simu.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/utils.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/viz/__init__.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/viz/tagore.py +0 -0
- {rfmix_reader-0.3.0 → rfmix_reader-0.3.1}/rfmix_reader/viz/visualization.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rfmix-reader
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: RFMix-reader is a Python package designed to efficiently read and process output files generated by RFMix, a popular tool for estimating local ancestry in admixed populations. The package employs a lazy loading approach, which minimizes memory consumption by reading only the loci that are accessed by the user, rather than loading the entire dataset into memory at once.
|
|
5
5
|
License: GPL-3.0-or-later
|
|
6
6
|
License-File: LICENSE
|
|
@@ -17,25 +17,30 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Provides-Extra: all
|
|
20
21
|
Provides-Extra: docs
|
|
21
22
|
Provides-Extra: gpu
|
|
22
23
|
Provides-Extra: io
|
|
23
24
|
Provides-Extra: tests
|
|
24
25
|
Provides-Extra: viz
|
|
25
|
-
Requires-Dist: cairosvg (>=2.7,<3.0) ; extra == "viz"
|
|
26
|
+
Requires-Dist: cairosvg (>=2.7,<3.0) ; extra == "viz" or extra == "all"
|
|
27
|
+
Requires-Dist: cudf-cu12 ; extra == "all"
|
|
28
|
+
Requires-Dist: cupy-cuda12x ; extra == "all"
|
|
26
29
|
Requires-Dist: cyvcf2 (>=0.31)
|
|
27
30
|
Requires-Dist: dask (>=2025.1,<2026.0)
|
|
31
|
+
Requires-Dist: dask-cudf-cu12 ; extra == "all"
|
|
28
32
|
Requires-Dist: fonttools (>=4.61.0,<5.0.0)
|
|
29
|
-
Requires-Dist: matplotlib (>=3.10,<4.0) ; extra == "viz"
|
|
33
|
+
Requires-Dist: matplotlib (>=3.10,<4.0) ; extra == "viz" or extra == "all"
|
|
30
34
|
Requires-Dist: numpy (>=1.23,<3)
|
|
31
35
|
Requires-Dist: pandas (>=2.0)
|
|
32
36
|
Requires-Dist: psutil (>=7,<8)
|
|
33
|
-
Requires-Dist:
|
|
37
|
+
Requires-Dist: pyarrow ; extra == "io" or extra == "all"
|
|
38
|
+
Requires-Dist: seaborn (>=0.13,<0.14) ; extra == "viz" or extra == "all"
|
|
34
39
|
Requires-Dist: sphinx (>=7,<9) ; extra == "docs"
|
|
35
40
|
Requires-Dist: sphinx-autodoc-typehints (>=2,<3) ; extra == "docs"
|
|
36
41
|
Requires-Dist: sphinx-copybutton (>=0.5,<0.6) ; extra == "docs"
|
|
37
42
|
Requires-Dist: sphinx-rtd-theme (>=2,<3) ; extra == "docs"
|
|
38
|
-
Requires-Dist: torch (>=2.8) ; extra == "gpu"
|
|
43
|
+
Requires-Dist: torch (>=2.8) ; extra == "gpu" or extra == "all"
|
|
39
44
|
Requires-Dist: tqdm (>=4.66)
|
|
40
45
|
Project-URL: Bug Tracker, https://github.com/heart-gen/rfmix_reader/issues
|
|
41
46
|
Project-URL: homepage, https://rfmix-reader.readthedocs.io/en/latest/
|
|
@@ -53,7 +58,7 @@ for major speedups when available.
|
|
|
53
58
|
|
|
54
59
|
## Installation
|
|
55
60
|
|
|
56
|
-
`rfmix-reader` requires **Python 3.
|
|
61
|
+
`rfmix-reader` requires **Python 3.11+**. Install from PyPI:
|
|
57
62
|
|
|
58
63
|
```bash
|
|
59
64
|
pip install rfmix-reader
|
|
@@ -67,12 +72,16 @@ pip install rfmix-reader
|
|
|
67
72
|
pip install rfmix-reader
|
|
68
73
|
```
|
|
69
74
|
|
|
70
|
-
* **With GPU acceleration** (`cupy`, `cudf`, `dask-cudf`):
|
|
75
|
+
* **With GPU acceleration** (`cupy`, `cudf`, `dask-cudf`, `torch`):
|
|
71
76
|
|
|
72
77
|
```bash
|
|
73
78
|
pip install rfmix-reader[gpu]
|
|
74
79
|
```
|
|
75
80
|
|
|
81
|
+
The default GPU extra targets **CUDA 12** wheels (`cupy-cuda12x`,
|
|
82
|
+
`cudf-cu12`, `dask-cudf-cu12`). Use the appropriate CUDA build strings if
|
|
83
|
+
your environment requires a different version.
|
|
84
|
+
|
|
76
85
|
* **With documentation tools** (`sphinx`, `sphinx-rtd-theme`):
|
|
77
86
|
|
|
78
87
|
```bash
|
|
@@ -87,8 +96,11 @@ pip install rfmix-reader
|
|
|
87
96
|
|
|
88
97
|
### GPU Notes
|
|
89
98
|
|
|
90
|
-
*
|
|
91
|
-
*
|
|
99
|
+
* PyTorch is **not** installed in the base package. It is pulled in only when you install the `[gpu]` extra (`pip install rfmix-reader[gpu]`) or add it yourself.
|
|
100
|
+
* Install a PyTorch wheel that matches your platform and CUDA version using the [official selector](https://pytorch.org/get-started/locally/). For example:
|
|
101
|
+
* **CUDA 12 (Linux/Windows):** `pip install torch --index-url https://download.pytorch.org/whl/cu121`
|
|
102
|
+
* **CUDA 11 (Linux/Windows):** `pip install torch --index-url https://download.pytorch.org/whl/cu118`
|
|
103
|
+
* **CPU-only:** `pip install torch --index-url https://download.pytorch.org/whl/cpu`
|
|
92
104
|
* RAPIDS (`cudf`, `cupy`) wheels are version- and CUDA-specific. See the [RAPIDS install guide](https://docs.rapids.ai/install).
|
|
93
105
|
* CPU-only installations will still run efficiently, just without GPU acceleration.
|
|
94
106
|
|
|
@@ -218,8 +230,8 @@ Binaries can also be generated on-the-fly within `read_rfmix` with
|
|
|
218
230
|
|
|
219
231
|
```python
|
|
220
232
|
loci, g_anc, admix = read_rfmix("examples/three_populations/out/",
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
binary_dir="./binary_files",
|
|
234
|
+
generate_binary=True)
|
|
223
235
|
```
|
|
224
236
|
|
|
225
237
|
### Phasing data
|
|
@@ -241,10 +253,12 @@ admix = phase_rfmix_chromosome_to_zarr(
|
|
|
241
253
|
```
|
|
242
254
|
|
|
243
255
|
The chunking is suboptimal for phasing, so remember to
|
|
244
|
-
rechunk before using for optimal processing.
|
|
256
|
+
rechunk before using for optimal processing. This is only needed
|
|
257
|
+
when loading individual chromosomes. The merged data is already
|
|
258
|
+
optimized.
|
|
245
259
|
|
|
246
260
|
```python
|
|
247
|
-
local_array = admix["local_ancestry"].chunk({"variant": 20000, "sample":
|
|
261
|
+
local_array = admix["local_ancestry"].chunk({"variant": 20000, "sample": 100})
|
|
248
262
|
# Compute into memory, if needed
|
|
249
263
|
local_array = local_array.compute()
|
|
250
264
|
```
|
|
@@ -9,7 +9,7 @@ for major speedups when available.
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
`rfmix-reader` requires **Python 3.
|
|
12
|
+
`rfmix-reader` requires **Python 3.11+**. Install from PyPI:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
pip install rfmix-reader
|
|
@@ -23,12 +23,16 @@ pip install rfmix-reader
|
|
|
23
23
|
pip install rfmix-reader
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
* **With GPU acceleration** (`cupy`, `cudf`, `dask-cudf`):
|
|
26
|
+
* **With GPU acceleration** (`cupy`, `cudf`, `dask-cudf`, `torch`):
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
pip install rfmix-reader[gpu]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
The default GPU extra targets **CUDA 12** wheels (`cupy-cuda12x`,
|
|
33
|
+
`cudf-cu12`, `dask-cudf-cu12`). Use the appropriate CUDA build strings if
|
|
34
|
+
your environment requires a different version.
|
|
35
|
+
|
|
32
36
|
* **With documentation tools** (`sphinx`, `sphinx-rtd-theme`):
|
|
33
37
|
|
|
34
38
|
```bash
|
|
@@ -43,8 +47,11 @@ pip install rfmix-reader
|
|
|
43
47
|
|
|
44
48
|
### GPU Notes
|
|
45
49
|
|
|
46
|
-
*
|
|
47
|
-
*
|
|
50
|
+
* PyTorch is **not** installed in the base package. It is pulled in only when you install the `[gpu]` extra (`pip install rfmix-reader[gpu]`) or add it yourself.
|
|
51
|
+
* Install a PyTorch wheel that matches your platform and CUDA version using the [official selector](https://pytorch.org/get-started/locally/). For example:
|
|
52
|
+
* **CUDA 12 (Linux/Windows):** `pip install torch --index-url https://download.pytorch.org/whl/cu121`
|
|
53
|
+
* **CUDA 11 (Linux/Windows):** `pip install torch --index-url https://download.pytorch.org/whl/cu118`
|
|
54
|
+
* **CPU-only:** `pip install torch --index-url https://download.pytorch.org/whl/cpu`
|
|
48
55
|
* RAPIDS (`cudf`, `cupy`) wheels are version- and CUDA-specific. See the [RAPIDS install guide](https://docs.rapids.ai/install).
|
|
49
56
|
* CPU-only installations will still run efficiently, just without GPU acceleration.
|
|
50
57
|
|
|
@@ -174,8 +181,8 @@ Binaries can also be generated on-the-fly within `read_rfmix` with
|
|
|
174
181
|
|
|
175
182
|
```python
|
|
176
183
|
loci, g_anc, admix = read_rfmix("examples/three_populations/out/",
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
binary_dir="./binary_files",
|
|
185
|
+
generate_binary=True)
|
|
179
186
|
```
|
|
180
187
|
|
|
181
188
|
### Phasing data
|
|
@@ -197,10 +204,12 @@ admix = phase_rfmix_chromosome_to_zarr(
|
|
|
197
204
|
```
|
|
198
205
|
|
|
199
206
|
The chunking is suboptimal for phasing, so remember to
|
|
200
|
-
rechunk before using for optimal processing.
|
|
207
|
+
rechunk before using for optimal processing. This is only needed
|
|
208
|
+
when loading individual chromosomes. The merged data is already
|
|
209
|
+
optimized.
|
|
201
210
|
|
|
202
211
|
```python
|
|
203
|
-
local_array = admix["local_ancestry"].chunk({"variant": 20000, "sample":
|
|
212
|
+
local_array = admix["local_ancestry"].chunk({"variant": 20000, "sample": 100})
|
|
204
213
|
# Compute into memory, if needed
|
|
205
214
|
local_array = local_array.compute()
|
|
206
215
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "rfmix-reader"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.1" # This will be overridden if dynamic versioning is enabled
|
|
4
4
|
description = "RFMix-reader is a Python package designed to efficiently read and process output files generated by RFMix, a popular tool for estimating local ancestry in admixed populations. The package employs a lazy loading approach, which minimizes memory consumption by reading only the loci that are accessed by the user, rather than loading the entire dataset into memory at once."
|
|
5
5
|
authors = ["Kynon J.M. Benjamin <kj.benjamin90@gmail.com>"]
|
|
6
6
|
maintainers = ["Kynon J.M. Benjamin <kj.benjamin90@gmail.com>"]
|
|
@@ -28,6 +28,10 @@ seaborn = { version = "^0.13", optional = true }
|
|
|
28
28
|
cairosvg = { version = "^2.7", optional = true }
|
|
29
29
|
# GPU
|
|
30
30
|
torch = { version = ">=2.8", optional = true }
|
|
31
|
+
cupy-cuda12x = { version = "*", optional = true }
|
|
32
|
+
cudf-cu12 = { version = "*", optional = true }
|
|
33
|
+
dask-cudf-cu12 = { version = "*", optional = true }
|
|
34
|
+
pyarrow = { version = "*", optional = true }
|
|
31
35
|
# Docs
|
|
32
36
|
sphinx = { version = ">=7,<9", optional = true }
|
|
33
37
|
sphinx-rtd-theme = { version = "^2", optional = true }
|
|
@@ -39,6 +43,7 @@ fonttools = "^4.61.0"
|
|
|
39
43
|
viz = ["matplotlib", "seaborn", "cairosvg"]
|
|
40
44
|
gpu = ["cupy", "cudf", "dask-cudf", "torch"]
|
|
41
45
|
io = ["pyarrow"] # parquet export
|
|
46
|
+
all = ["matplotlib", "seaborn", "cairosvg", "torch", "cupy-cuda12x", "cudf-cu12", "dask-cudf-cu12", "pyarrow"]
|
|
42
47
|
docs = ["sphinx", "sphinx-rtd-theme", "sphinx-autodoc-typehints", "sphinx-copybutton"]
|
|
43
48
|
tests = ["pytest"]
|
|
44
49
|
|
|
@@ -275,9 +275,6 @@ def interpolate_array(
|
|
|
275
275
|
Batch size for processing local ancestry data. Default is 10,000.
|
|
276
276
|
interpolation : {"linear","nearest","stepwise"}, default "linear"
|
|
277
277
|
Interpolation scheme.
|
|
278
|
-
``"hmm"`` is available for experimentation but requires
|
|
279
|
-
`allow_hmm=True` and haplotype-level inputs created with
|
|
280
|
-
`split_to_haplotypes`.
|
|
281
278
|
use_bp_positions : bool, default False
|
|
282
279
|
If True, use `variant_loci_df['pos']` as the x-axis for interpolation.
|
|
283
280
|
If False, loci are treated as equally spaced (index-based).
|
|
@@ -1240,10 +1240,22 @@ def merge_phased_zarrs(
|
|
|
1240
1240
|
if sort:
|
|
1241
1241
|
combined = combined.sortby(["chromosome", "variant_position"])
|
|
1242
1242
|
|
|
1243
|
+
for v in combined.variables:
|
|
1244
|
+
var = combined[v]
|
|
1245
|
+
var.encoding.pop("chunks", None)
|
|
1246
|
+
if var.dtype == object:
|
|
1247
|
+
combined[v] = var.astype("S50")
|
|
1248
|
+
|
|
1249
|
+
# Ensure string coordinates are encoded consistently when writing to Zarr.
|
|
1250
|
+
for coord in ("chromosome", "sample_id", "ancestry"):
|
|
1251
|
+
if coord in combined.coords:
|
|
1252
|
+
combined = combined.assign_coords({coord: combined[coord].astype(str)})
|
|
1253
|
+
|
|
1243
1254
|
logger.info(
|
|
1244
1255
|
"[merge_phased_zarrs] Writing merged dataset with %d variants to %s",
|
|
1245
|
-
combined.
|
|
1256
|
+
combined.sizes.get("variant", 0),
|
|
1246
1257
|
output_path,
|
|
1247
1258
|
)
|
|
1259
|
+
combined = combined.chunk({"variant": 50000})
|
|
1248
1260
|
combined.to_zarr(output_path, mode="w")
|
|
1249
1261
|
return combined
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|