{"id":15646639,"url":"https://github.com/nvictus/pybbi","last_synced_at":"2025-04-09T12:04:08.496Z","repository":{"id":14038632,"uuid":"58960207","full_name":"nvictus/pybbi","owner":"nvictus","description":"Python bindings to UCSC BigWig and BigBed library","archived":false,"fork":false,"pushed_at":"2025-01-27T01:10:05.000Z","size":36105,"stargazers_count":32,"open_issues_count":3,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-02T11:03:51.193Z","etag":null,"topics":["bbi","bigbed","bigwig","bioinformatics","cython","genomics","kent","numpy","python"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nvictus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-16T19:18:58.000Z","updated_at":"2024-12-19T02:08:15.000Z","dependencies_parsed_at":"2024-06-18T20:27:16.204Z","dependency_job_id":"549250bd-6424-4eed-b205-affe09c44dfc","html_url":"https://github.com/nvictus/pybbi","commit_stats":{"total_commits":179,"total_committers":4,"mean_commits":44.75,"dds":0.08938547486033521,"last_synced_commit":"2f933e965823a93070f64b7365965c0a39cde5bf"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvictus%2Fpybbi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvictus%2Fpybbi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvictus%2Fpybbi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvictus%2Fpybbi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nvictus","download_url":"https://codeload.github.com/nvictus/pybbi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036064,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bbi","bigbed","bigwig","bioinformatics","cython","genomics","kent","numpy","python"],"created_at":"2024-10-03T12:13:40.499Z","updated_at":"2025-04-09T12:04:08.478Z","avatar_url":"https://github.com/nvictus.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pybbi #\n\n![Build Status](https://github.com/nvictus/pybbi/actions/workflows/ci.yml/badge.svg)\n[![DOI](https://zenodo.org/badge/58960207.svg)](https://zenodo.org/doi/10.5281/zenodo.10382980)\n\nPython interface to Jim Kent's Big Binary Indexed file (BBI) \\[[1](#ref1)\\] library from the [UCSC Genome Browser source tree](https://github.com/ucscGenomeBrowser/kent) using Cython.\n\nThis 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.\n\n\n## Installation ##\n\nWheels for `pybbi` are available on PyPI for Python 3.8, 3.9, 3.10, 3.11 on Linux (x86_64 and aarch64) and Mac OSX (x86_64/Intel). Apple Silicon (arm64) wheels will be made available once M1 runners are available in GitHub Actions.\n\n```\n$ pip install pybbi\n```\n\n## API ##\n\nThe `bbi.open` function returns a `BBIFile` object.\n\n```\nbbi.open(path) -\u003e BBIFile\n```\n\n`path` can be a local file path (bigWig or bigBed) or a URL. `BBIFile` objects are context managers and can be used in a `with` statement to clean up resources without calling `BBIFile.close()`.\n\n```python\n\u003e\u003e\u003e with bbi.open('bigWigExample.bw') as f:\n...     x = f.fetch('chr21', 1000000, 2000000, bins=40)\n```\n\n### Introspection\n\n```\nBBIFile.is_bigwig -\u003e bool\nBBIFile.is_bigbed -\u003e bool\nBBIFile.chromsizes -\u003e OrderedDict\nBBIFile.zooms -\u003e list\nBBIFile.info -\u003e dict\nBBIFile.schema -\u003e dict\nBBIFile.read_autosql() -\u003e str\n```\n\nNote: `BBIFile.schema['dtypes']` provides numpy data types for the fields in a bigWig or bigBed (matched from the autoSql definition).\n\n\n### Interval output\n\nThe actual interval records in a bigWig or bigBed can be retrieved as a pandas dataframe or as an iterator over records as tuples. The pandas output is parsed according to the file's schema.\n\n```\nBBIFile.fetch_intervals(chrom, start, end) -\u003e pandas.DataFrame\nBBIFile.fetch_intervals(chrom, start, end, iterator=True) -\u003e interval iterator\n```\n\nSummary bin records at each zoom level are also accessible.\n\n```\nBBIFile.fetch_summaries(chrom, start, end, zoom) -\u003e pandas.DataFrame\n```\n\n### Array output\n\nRetrieve quantitative signal as an array. The signal of a bigWig file is obtained from its \"value\" field. The signal of a bigBed file is obtained from the genomic coverage of its intervals.\n\nFor a single range query:\n```\nBBIFile.fetch(chrom, start, end, [bins [, missing [, oob, [, summary]]]]) -\u003e 1D numpy array\n```\n\nTo produce a stacked heatmap from a list of (1) equal-length intervals or (2) arbitrary-length intervals with `bins` specified:\n```\nBBIFile.stackup(chroms, starts, ends, [bins [, missing [, oob, [, summary]]]]) -\u003e 2D numpy array\n```\n\n* **Summary** querying is supported by specifying the number of `bins` for coarsening. The `summary` statistic can be one of: 'mean', 'min', 'max', 'cov', 'std', 'or 'sum'. (default = 'mean'). Intervals need not have the same length, in which case the data from each interval will be interpolated to the same number of bins (e.g., gene bodies).\n\n* **Missing** data can be filled with a custom fill value, `missing` (default = 0). \n\n* **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).\n\n### Function API\n\nThe original function-based API is still available:\n\n```python\nbbi.is_bbi(path: str) -\u003e bool\nbbi.is_bigwig(path: str) -\u003e bool\nbbi.is_bigbed(path:str) -\u003e bool\nbbi.chromsizes(path: str) -\u003e OrderedDict\nbbi.zooms(path: str) -\u003e list\nbbi.info(path: str) -\u003e dict\nbbi.fetch_intervals(path: str, chrom: str, start: int, end: int, iterator: bool) -\u003e Union[Iterable, pd.DataFrame]\nbbi.fetch(path: str, chrom: str, start: int, end: int, [bins: int [, missing: float [, oob: float, [, summary: str]]]]) -\u003e np.array[1, 'float64']\nbbi.stackup(path: str, chroms: np.array, starts: np.array, ends: np.array, [bins: int [, missing: float [, oob: float, [, summary: str]]]]) -\u003e np.array[2, 'float64']\n```\n\nSee the docstrings for complete documentation.\n\n## Related projects ##\n\n- [libBigWig](https://github.com/dpryan79/libBigWig): Alternative C library for bigWig and bigBed files by Devon Ryan\n- [pyBigWig](https://github.com/dpryan79/pyBigWig): Python bindings for `libBigWig` by the same author\n- [bw-python](https://github.com/brentp/bw-python): Alternative Python wrapper to `libBigWig` by Brent Pederson\n- [bx-python](https://github.com/bxlab/bx-python): Python bioinformatics library from James Taylor's group that includes tools for bbi files.\n\nThis library provides bindings to the reference UCSC bbi library code. Check out [@dpryan79](https://github.com/dpryan79)'s [libBigWig](https://github.com/dpryan79/libBigWig) for an alternative and dedicated C library for big binary files. pyBigWig also provides numpy-based retrieval and bigBed support.\n\n## References ##\n\n\u003ca id=\"ref1\"\u003e[1]\u003c/a\u003e: http://bioinformatics.oxfordjournals.org/content/26/17/2204.full\n\n## From source ##\n\nIf wheels for your platform or Python version aren't available or you want to develop, you'll need to install `pybbi` from source. The source distribution on PyPI ships with (slightly modified) kent utils source, which will compile before the extension module is built.\n\nRequires\n- Platform: Linux or Darwin (Windows Subsystem for Linux seems to work too)\n- pthreads, zlib, libpng, openssl, make, pkg-config\n- Python 3.6+\n- `numpy` and `cython`\n\nFor example, on a fresh Ubuntu instance, you'll need `build-essential`, `make`, `pkg-config`, `zlib1g-dev`, `libssl-dev`, `libpng16-dev`.\n\nOn a Centos/RedHat (rpm) system you'll need `gcc`, `make`, `pkg-config`, `zlib-devel`, `openssl-devel`, `libpng-devel`.\n\nOn a Mac, you'll need Xcode and to `brew install pkg-config openssl libpng`.\n\nFor development, clone the repo and install in editable mode:\n\n```\n$ git clone https://github.com/nvictus/pybbi.git\n$ cd pybbi\n$ pip install -e .\n```\n\nYou can use the `ARCH` environment variable to specify a target architecture or `ARCHFLAGS` on a Mac.\n\n### Notes\n\nUnfortunately, Kent's C source is not well-behaved library code, as it is littered with error calls that call `exit()`. `pybbi` will catch and pre-empt common input errors, but if somehow an internal error does get raised, it will terminate your interpreter instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvictus%2Fpybbi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnvictus%2Fpybbi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvictus%2Fpybbi/lists"}