Alpha Rust-native PLINK and BGEN reader for Python and Polars.
Project description
pgen-polars
Rust-native reader for PLINK 2 .pgen, PLINK 1 .bed, and BGEN v1.2
genotype files, with Python and Polars integration.
[!WARNING] Alpha software:
pgen-polarsis under active development. APIs, supported formats, and behavior are subject to change between releases. Pin the package version when using it in other projects.
Python package installation
Create or activate a Python 3.10 or newer virtual environment, then install the package from PyPI. Because the project is alpha software, pin the exact version in applications and reproducible environments:
python -m venv .venv
source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
python -m pip install "pgen-polars==0.1.1"
With uv:
uv add "pgen-polars==0.1.1"
Verify the installation:
python -c "import pgen_polars; print(pgen_polars.__version__)"
Published wheels support CPython 3.10 and newer on Linux (x86-64 and ARM64),
macOS (Intel and Apple Silicon), and 64-bit Windows. Building from the source
distribution requires Rust 1.85 or newer. pgen-polars currently supports
Polars 1.31 through 1.42.
Status: eager and lazy/chunked
.bed,.pgen, and BGEN Layout 2 reading is implemented, including ordered sample/variant selection and long or samples-by-variants wide output. Statistics remain deferred. See the roadmap and product specification for details.
Python API
from pgen_polars import read_bgen, read_pgen, scan_bgen, scan_pgen
# read_pgen also accepts PLINK 1 .bed files and auto-detects sidecars.
features = read_pgen(
"cohort.pgen",
samples=["sample_42", "sample_7"],
variants=["variant_1", "variant_2"],
)
lazy = scan_pgen("cohort.pgen", variants=["variant_1", "variant_2"])
selected = lazy.select("ID", "variant_2").collect()
# BGEN v1.2 Layout 2 requires an Oxford .sample file. BGEN does not
# identify the reference allele, so ref_allele must be explicit.
bgen_features = read_bgen(
"cohort.bgen",
ref_allele="last",
samples=["sample_42", "sample_7"],
rsids=["rs123", "rs456"],
)
bgen_lazy = scan_bgen("cohort.bgen", ref_allele="last")
Metadata readers are also available as read_psam, read_pvar, read_fam,
read_bim, and read_sample. Eager readers return Polars DataFrames; scan
functions return Polars LazyFrames. Wide output is the default, and
output_format="long" enables row-oriented output.
Development
Development requires Rust, uv, and Python 3.10
or newer.
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
uv venv --python 3.10
uv pip install -e '.[dev]'
uv run pytest tests/python -q
Releases
The package version comes from Cargo.toml. A matching tag such as v0.1.1
builds and tests platform wheels and a source distribution, then publishes them
to PyPI through Trusted Publishing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pgen_polars-0.1.1.tar.gz.
File metadata
- Download URL: pgen_polars-0.1.1.tar.gz
- Upload date:
- Size: 133.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d79484d924ffed6b11935a4174339ad38d05270d8c9324f0b5b7f39f1e4df6b
|
|
| MD5 |
47d8b645a2fb2f0b8f6ece64bfcd215d
|
|
| BLAKE2b-256 |
866a07cd9114911155c7344acb14441bb32df4325f47d9648f70147671c64551
|
Provenance
The following attestation bundles were made for pgen_polars-0.1.1.tar.gz:
Publisher:
release-python.yml on idinsmore1/pgen_rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgen_polars-0.1.1.tar.gz -
Subject digest:
9d79484d924ffed6b11935a4174339ad38d05270d8c9324f0b5b7f39f1e4df6b - Sigstore transparency entry: 2187299450
- Sigstore integration time:
-
Permalink:
idinsmore1/pgen_rs@568261793c0f3f21ee2f063678654a45e4033db8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/idinsmore1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@568261793c0f3f21ee2f063678654a45e4033db8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgen_polars-0.1.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: pgen_polars-0.1.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 20.0 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73511cc1567da2fb64d878acad17b954f63213baea218b2e12420734cb6a34a8
|
|
| MD5 |
8a426edc52e798dfd9acfbae549a40d3
|
|
| BLAKE2b-256 |
11ad51df73264fea2b0a7db7c18f2ae7062200835d952767d2a55b85d0f07e92
|
Provenance
The following attestation bundles were made for pgen_polars-0.1.1-cp310-abi3-win_amd64.whl:
Publisher:
release-python.yml on idinsmore1/pgen_rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgen_polars-0.1.1-cp310-abi3-win_amd64.whl -
Subject digest:
73511cc1567da2fb64d878acad17b954f63213baea218b2e12420734cb6a34a8 - Sigstore transparency entry: 2187299927
- Sigstore integration time:
-
Permalink:
idinsmore1/pgen_rs@568261793c0f3f21ee2f063678654a45e4033db8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/idinsmore1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@568261793c0f3f21ee2f063678654a45e4033db8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 21.6 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c543712397f6b5e1c51247cb86c54cc11ca44f1c57f4fb3ed6c7360b577ab2a4
|
|
| MD5 |
3aa0a26ed302d4e9842e7a708fe33883
|
|
| BLAKE2b-256 |
6473d94b0d6e190e71ba42cc31ee80a1a6bb7d42ad348145ebd9b465868ea0a0
|
Provenance
The following attestation bundles were made for pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-python.yml on idinsmore1/pgen_rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
c543712397f6b5e1c51247cb86c54cc11ca44f1c57f4fb3ed6c7360b577ab2a4 - Sigstore transparency entry: 2187299547
- Sigstore integration time:
-
Permalink:
idinsmore1/pgen_rs@568261793c0f3f21ee2f063678654a45e4033db8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/idinsmore1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@568261793c0f3f21ee2f063678654a45e4033db8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 23.7 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
356eb6fdc2b7fdaee0651cf87c35d44163d806622cfbd6c5666ed9eca48cdf2f
|
|
| MD5 |
3dccde5c3b3638a0d9b85680f42a7749
|
|
| BLAKE2b-256 |
4c2621c90a10bb793d1e3f3e0333c55f14d5f127040baef29ce678a49f2d3a28
|
Provenance
The following attestation bundles were made for pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release-python.yml on idinsmore1/pgen_rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgen_polars-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
356eb6fdc2b7fdaee0651cf87c35d44163d806622cfbd6c5666ed9eca48cdf2f - Sigstore transparency entry: 2187299716
- Sigstore integration time:
-
Permalink:
idinsmore1/pgen_rs@568261793c0f3f21ee2f063678654a45e4033db8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/idinsmore1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@568261793c0f3f21ee2f063678654a45e4033db8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgen_polars-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pgen_polars-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.5 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62fe0ea320118ea2ecc5f106b09b6dc5bf27e90993f6b8541f269ea53d467471
|
|
| MD5 |
c33b7d6d538062b95690dee5b4182a75
|
|
| BLAKE2b-256 |
a8a4704c2710e28c34bd109dc76d1e339d3f420d10d5b88408de175c3b72ab94
|
Provenance
The following attestation bundles were made for pgen_polars-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release-python.yml on idinsmore1/pgen_rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgen_polars-0.1.1-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
62fe0ea320118ea2ecc5f106b09b6dc5bf27e90993f6b8541f269ea53d467471 - Sigstore transparency entry: 2187299630
- Sigstore integration time:
-
Permalink:
idinsmore1/pgen_rs@568261793c0f3f21ee2f063678654a45e4033db8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/idinsmore1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@568261793c0f3f21ee2f063678654a45e4033db8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgen_polars-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pgen_polars-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 21.6 MB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
729f9cfbc9f620baf290993629e83519a905e979b0b5dad3380434529bc53888
|
|
| MD5 |
79c52b61f4cef60e9a8ada1f4cb6c485
|
|
| BLAKE2b-256 |
11604058f89b52253374b4c3061813534565b7b341f0eb5323d97716fb1e3d01
|
Provenance
The following attestation bundles were made for pgen_polars-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
release-python.yml on idinsmore1/pgen_rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgen_polars-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
729f9cfbc9f620baf290993629e83519a905e979b0b5dad3380434529bc53888 - Sigstore transparency entry: 2187299833
- Sigstore integration time:
-
Permalink:
idinsmore1/pgen_rs@568261793c0f3f21ee2f063678654a45e4033db8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/idinsmore1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@568261793c0f3f21ee2f063678654a45e4033db8 -
Trigger Event:
push
-
Statement type: