Module epiclass.utils.bigwig_metrics

This module provides functionalities compute a metric on given regions from bigwig files. Uses pyBigWig.

Functions

def chunks(lst: List, n: int) ‑> Generator[List[~T], None, None]

Yield successive n-sized chunks from lst.

def compute_all_metrics(file_path: Path, regions: pd.DataFrame, metric: str)

Compute metric values in regions, returning a dictionary mapping region_id to value.

Parameters file_path (Path): Path to bigwig file regions (pd.DataFrame): DataFrame with regions (chr, start, end) metric (str): Metric to compute. Must respect metrics available to pyBigWig stats.

Return Tuple[filename, Dict[str, float|None]|None] : Tuple with filename and dictionary mapping region_id to value or None if error.

def compute_metrics(bw: pyBigWig.bigWigFile, regions: pd.DataFrame, metric: str)

Compute metric value in each region using pyBigWig stats. Returns a list of scalar metric values (or None if region is unsummarizable).

def main()

Main. See module docstring.

def parse_arguments() ‑> argparse.Namespace

argument parser for command line

def read_regions(regions_path: Path) ‑> pandas.core.frame.DataFrame

Read regions from a bed file and add a 'region_id' column.