Registry / data / bgen
library1.9.10pypypi✓ verified 80d ago

Python package for loading and manipulating data from BGEN files, a binary file format for storing genotype data. Current version is 1.9.9, compatible with Python >=3.8. It is actively maintained with periodic releases.

pip install bgen
INSTALL
IMPORT
SIG · BGEN
B
bgen
datapythonv1.9.10
Install
4.5s avg
Import
Disk
101MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 102.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.5s · import 0.000s · 96MB
101MB installed
● package 101MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BgenReader
from bgen import BgenReader
from bgen import BGENFile
BgenVar
from bgen import BgenVar
BgenWriter
from bgen import BgenWriter

Open a BGEN file and read basic information and variant genotypes.

from bgen import BGENFile # Replace with your actual BGEN file path bgen = BGENFile('example.bgen') # Get number of samples print('Number of samples:', bgen.nsamples) # Get number of variants print('Number of variants:', bgen.nvariants) # Iterate over first 5 variants for i, variant in enumerate(bgen): if i >= 5: break print('Variant:', variant.rsid, variant.chromosome, variant.position) # Access genotype probabilities (3D array: samples x alleles x ploidy) probs = variant.genotype() print('Genotype probs shape:', probs.shape)
Debug
Known issues
gotchaBGENFile indexing is 0-based, not 1-based. Often users expect variant positions to be 1-indexed.
fix
Always check documentation or use .rsid for identifiers.
affects: all
deprecatedFunctions like 'bgen_open' are deprecated in favor of direct class instantiation.
fix
Use 'from bgen import BGENFile; bgen = BGENFile(filename)' instead.
affects: >=1.7
gotchaMemory usage can be high when calling .genotype() on a large variant because it loads all sample data into memory.
fix
Use the 'subsample' or 'probs' arguments to subset or use iterator for large files.
affects: all
Upgrade
Version history
1.9.10latest on PyPI · released May 25, 2026
Audit
Dependencies
numpyrequiredRequired for array operations.
cythonoptionalRequired for building from source if wheel not available.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
bgen — pip install bgen · libregistry