Registry / data / pybigwig

pybigwig

JSON →
library0.3.25pypypi✓ verified 85d ago

pyBigWig is a Python package providing efficient access to bigWig files, leveraging the underlying C library libBigWig. It enables reading genomic data stored in bigWig format and also supports creating and writing new bigWig files. The current version is 0.3.25, with frequent updates addressing bug fixes and build improvements.

pip install pyBigWig
INSTALL
IMPORT
SIG · PYBIGWIG
P
pybigwig
datapythonv0.3.25
Install
1.6s avg
Import
Disk
17MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.25 · 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.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

pyBigWigTest
import pyBigWigTest
import pyBigWig

This quickstart demonstrates how to create a simple bigWig file with dummy data, then open it in read mode to extract values, summary statistics, and intervals from specific genomic regions. It also shows the importance of closing the file handles.

import pyBigWig import os # Define a temporary bigWig file name temp_bw_file = "temp_quickstart.bigWig" # --- Writing a new bigWig file for demonstration --- # Chromosome sizes are required for writing chrom_sizes = {"chr1": 100000, "chr2": 50000} bw_write = pyBigWig.open(temp_bw_file, "w") bw_write.addHeader([(name, size) for name, size in chrom_sizes.items()]) # Add some dummy entries bw_write.addEntries( ["chr1"] * 5, [0, 100, 200, 300, 400], [99, 199, 299, 399, 499], [0.1, 0.2, 0.3, 0.4, 0.5] ) bw_write.addEntries("chr1", 5000, 5010, [1.0]*10, step=1, span=1) bw_write.addEntries("chr2", 1000, 1005, [2.0]*5, step=1, span=1) bw_write.close() print(f"Created dummy bigWig file: {temp_bw_file}\n") # --- Reading from the bigWig file --- bw = pyBigWig.open(temp_bw_file) print(f"Chromosomes found: {bw.chroms()}\n") # Get values from a specific region on chr1 values_chr1 = bw.values("chr1", 0, 500) print(f"Values on chr1 (0-500, first 10): {values_chr1[:10]}...\n") # Get summary statistics for a region summary_chr1 = bw.stats("chr1", 0, 1000, type="mean") print(f"Mean value on chr1 (0-1000): {summary_chr1[0]}\n") # Get intervals (start, end, value) for a region intervals_chr1 = bw.intervals("chr1", 0, 1000) print(f"Intervals on chr1 (0-1000, first 3): {intervals_chr1[:3]}...\n") # Close the bigWig file to release resources bw.close() # Clean up the temporary file if os.path.exists(temp_bw_file): os.remove(temp_bw_file) print(f"Cleaned up temporary file: {temp_bw_file}")
Debug
Known issues
gotchaExplicitly close bigWig file objects using `bw.close()` after use to prevent potential memory leaks, especially when processing many files in a single session.
fix
Always call `bw.close()` for opened bigWig files. This issue was largely addressed in v0.3.17 but good practice remains.
affects: <0.3.17
gotchaAttempting to perform read operations (e.g., `values()`, `stats()`) on a `pyBigWig` object opened in write mode (`'w'`) will result in an error.
fix
Ensure the file is opened in read mode (`'r'`, which is the default) for reading, or create a separate `pyBigWig` object for reading if simultaneous read/write-like logic is required.
affects: All versions
breakingVersions prior to 0.3.25 could incorrectly report a single random entry for a genuinely empty bigWig file, and versions prior to 0.3.18 might misinterpret bigWig files with all zero summary values as empty.
fix
Update to `pyBigWig` version 0.3.25 or later to ensure correct handling of empty files and files with zero summary values.
affects: <0.3.25, <0.3.18
gotchaBigWig files where the chromosome order in the header differs from the data sections could lead to issues.
fix
Update to `pyBigWig` version 0.3.24 or later, which includes a fix to handle such cases correctly.
affects: <0.3.24
Upgrade
Version history
0.3.25latest on PyPI · released Jan 14, 2026
Audit
Dependencies
numpyrequiredRequired for handling numerical data arrays used in bigWig operations.
Agent activity
9 hits · last 30 days
node
8
Resources
pybigwig — pip install pybigwig · libregistry