This provides read-level access to local and remote bigWig and bigBed files but no write capabilitites. The main feature is fast retrieval of range queries into numpy arrays.
These accept a local file path or URL.
These accept either a bigWig or bigBed file path / URL. The signal of a bigBed file is the genomic coverage of its intervals.
For a single range query:
bbi.fetch(path, chrom, start, end, [bins [, missing [, oob, [, summary]]]])--> 1D numpy array
For a list of equal-length segments (i.e. to produce a stacked heatmap):
bbi.stackup(path, chroms, starts, ends, [bins [, missing [, oob, [, summary]]]])--> 2D numpy array
Summary querying is supported by specifying the number of
bins for coarsegraining. The
summary statistic can be one of: 'mean', 'min', 'max', 'cov', or 'std'. (default = 'mean').
Missing data can be filled with a custom fill value,
missing (default = 0).
Out-of-bounds ranges (i.e.
start less than zero or
end greater than the chromosome length) are permitted because of their utility e.g., for generating vertical heatmap stacks centered at specific genomic features. A separate custom fill value,
oob can be provided for out-of-bounds positions (default = NaN).
Accepts either a bigWig or bigBed file path / URL.
bbi.fetch_intervals(path, chrom, start, end)--> iterator
See the docstrings for complete documentation.
- C compiler, zlib, pthreads, libpng, openssl, make
- Python 2.7/3.4+
On fresh Ubuntu instance, you'll need
libpng16-dev. It seems to work on the Windows Subsystem for Linux too.
On a Centos/RedHat (rpm) system you'll need
pybbi is now on PyPI as a source distribution. It ships with (slightly modified) kent utils source, which it will compile before building the extension module.
$ pip install pybbi
For development, clone the repo and install in editable mode:
$ git clone https://github.com/nvictus/pybbi.git $ cd pybbi $ pip install -e .
- libBigWig: Alternative C library for bigWig and bigBed files by Devon Ryan
- pyBigWig: Python bindings for
libBigWigby the same author
- bw-python: Alternative Python wrapper to
libBigWigby Brent Pederson
- bx-python: Python bioinformatics library from James Taylor's group that includes tools for bbi files.
This library provides bindings to the reference UCSC bbi library code. Check out @dpryan79's libBigWig for an alternative and dedicated C library for big binary files. pyBigWig also provides numpy-based retrieval and bigBed support.
On OSX, you may get errors about missing header files (e.g.,
openssl/sha.h), which even if installed may not be located in standard include locations. Either create the required symlinks or update the
C_INCLUDE_PATH environment variable accordingly before installing pybbi.
Unfortunately, Kent's C source is not well-behaved library code, as it is littered with error calls that call
pybbi will catch and pre-empt common input errors, but if somehow an internal error does get raised, it will terminate your interpreter instance.