lib5c.contrib.pybigwig.bigwig module

Module for interfacing with the external pyBigWig Python package, which enables reading and searching genomic features from .bigwig files.

class lib5c.contrib.pybigwig.bigwig.BigWig(filename)[source]

Bases: object

Wrapper class around pyBigWig, mostly to expose our own query() function.

bw

The underlying pyBigWig object.

Type

pyBigWig object

query(grange, stat='max', num_bins=None, exact=True)[source]

Signature rework/wrapper around pyBigWig’s stats() and intervals().

Parameters
  • grange (Dict[str, Any]) –

    The genomic range to query. Should have at least the following structure:

    {
        'chrom': str,
        'start': int,
        'end': int
    }
    

  • num_bins (Optional[int]) – Pass an integer to split grange into num_bins bins of equal width, and return a summary statistic for each bin. Pass None to return all bigwig features in grange without binning.

  • stat (str) – The summary statistic to use if num_bins is not None.

  • exact (bool) – Pass True to ignore bigwig zoom levels when computing summary statistics and return the exact answer instead.

Returns

A list of bed features with ‘value’ keys representing the results of the query.

Return type

List[Dict[str, Any]]

lib5c.contrib.pybigwig.bigwig.bigwig_avail()[source]

Utility function for checking if pyBigWig is installed.

Returns

True if pyBigWig is installed, otherwise False.

Return type

bool