Registry / analytics / pyranges

pyranges

JSON →
library0.1.4pypypi✓ verified 86d ago

PyRanges is a Python library for representing and analyzing genomic intervals, similar to Bioconductor's GenomicRanges. It provides efficient operations for overlap, merging, and annotation of genomic ranges. Version 0.1.4 is current; release cadence is irregular.

pip install pyranges
INSTALL
IMPORT
SIG · PYRANGES
P
pyranges
analyticspythonv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PyRanges
from pyranges import PyRanges
import pyranges as pr
Common mistake: importing the module then trying to use pr.PyRanges works, but the correct class import is from pyranges import PyRanges

Create a PyRanges object from a pandas DataFrame.

import pandas as pd from pyranges import PyRanges df = pd.DataFrame({ 'Chromosome': ['chr1', 'chr1', 'chr2'], 'Start': [100, 200, 300], 'End': [150, 250, 400] }) gr = PyRanges(df) print(gr)
Debug
Known issues
gotchaPyRanges expects 0-based, half-open intervals (Start inclusive, End exclusive). Using 1-based coordinates will cause off-by-one errors in overlaps.
fix
Always use 0-based, half-open intervals.
affects: all
gotchaThe Chromosome column must be a string, not an integer. If you supply integers, overlaps may fail silently.
fix
Ensure Chromosome column is of dtype str.
affects: all
gotchaStrand information is supported only if a column named 'Strand' exists with values '+', '-', or '.'. Missing or invalid Strand causes errors in strand-specific operations.
fix
Include a Strand column with correct values when needed.
affects: all
Errors
Common errors & fixes
AttributeError: module 'pyranges' has no attribute 'PyRanges'
Imported the module instead of the class.
fix
Use 'from pyranges import PyRanges' then 'PyRanges(...)'.
ValueError: Chromosome column not found
DataFrame missing required column 'Chromosome'.
fix
Ensure DataFrame has columns: Chromosome, Start, End.
ValueError: Start column not found
DataFrame missing required column 'Start'.
fix
Include 'Start' column with integer values.
Upgrade
Version history
0.1.4latest on PyPI · released Mar 14, 2025
Audit
Dependencies
pandasrequiredCore data structure for genomic intervals
numpyrequiredNumerical computing support
nclsrequiredInterval tree data structure
Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
pyranges — pip install pyranges · libregistry