Skip to main content

Pandas utilities for tab-delimited and other genomic files

Project description

Bioframe: Operations on Genomic Interval Dataframes

Python package DOI Docs status

Bioframe is a library to enable flexible and scalable operations on genomic interval dataframes in python. Building bioframe directly on top of pandas enables immediate access to a rich set of dataframe operations. Working in python enables rapid visualization (e.g. matplotlib, seaborn) and iteration of genomic analyses.

The philosophy underlying bioframe is to enable flexible operations: instead of creating a function for every possible use-case, we instead encourage users to compose functions to achieve their goals. As a rough rule of thumb, if a function requires three steps and is crucial for genomic interval arithmetic we have included it; conversely if it can be performed in a single line by composing two of the core functions, we have not included it.

Bioframe implements a variety of genomic interval operations directly on dataframes. Bioframe also has functions for loading diverse genomic data formats, and performing operations on special classes of genomic intervals, including chromosome arms and fixed size bins.

Read the docs, including the guide.

Installation

The following are required before installing bioframe:

  • Python 3.7+
  • numpy
  • pandas>=1.3
pip install bioframe

Interval operations

Key genomic interval operations in bioframe include:

  • closest: For every interval in a dataframe, find the closest intervals in a second dataframe.
  • cluster: Group overlapping intervals in a dataframe into clusters.
  • complement: Find genomic intervals that are not covered by any interval from a dataframe.
  • overlap: Find pairs of overlapping genomic intervals between two dataframes.

Bioframe additionally has functions that are frequently used for genomic interval operations and can be expressed as combinations of these core operations and dataframe operations, including: coverage, expand, merge, select, and subtract.

To overlap two dataframes, call:

import bioframe as bf

bf.overlap(df1, df2)

For these two input dataframes, with intervals all on the same chromosome:

overlap will return the following interval pairs as overlaps:

To merge all overlapping intervals in a dataframe, call:

import bioframe as bf

bf.merge(df1)

For this input dataframe, with intervals all on the same chromosome:

merge will return a new dataframe with these merged intervals:

See the guide for visualizations of other interval operations in bioframe.

File I/O

Bioframe includes utilities for reading genomic file formats into dataframes and vice versa. One handy function is read_table which mirrors pandas’s read_csv/read_table but provides a schema argument to populate column names for common tabular file formats.

jaspar_url = 'http://expdata.cmmt.ubc.ca/JASPAR/downloads/UCSC_tracks/2018/hg38/tsv/MA0139.1.tsv.gz'
ctcf_motif_calls = bioframe.read_table(jaspar_url, schema='jaspar', skiprows=1)

Tutorials

See this jupyter notebook for an example of how to assign TF motifs to ChIP-seq peaks using bioframe.

Projects currently using bioframe:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bioframe-0.3.1.tar.gz (109.1 kB view details)

Uploaded Source

Built Distribution

bioframe-0.3.1-py2.py3-none-any.whl (115.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file bioframe-0.3.1.tar.gz.

File metadata

  • Download URL: bioframe-0.3.1.tar.gz
  • Upload date:
  • Size: 109.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for bioframe-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e1e839febfb3736adbb303cefb17ea5d9fe81adbda352eaf57624860ce3d0df3
MD5 d543b71eda9dffc4fd954bb1323863bc
BLAKE2b-256 976884bcf9d3cf131f4656c90a3015898f827fe2554c81e6c199d5618d454d73

See more details on using hashes here.

File details

Details for the file bioframe-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: bioframe-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 115.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for bioframe-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c87d17d816463967018d1d001a53c996fbcfa1f9fe96b215b60957cffa23ad6b
MD5 4f0b906e09de20921fe541277b65eeb0
BLAKE2b-256 a16b1dd487407bb46a4ca6b3eb6680c11e0cc6200b3ea9c577e98c92b0bd94c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page