GenomicRanges
Container class to represent genomic locations and support genomic analysis in Python similar to Bioconductor's GenomicRanges.
Install
Package is published to PyPI
pip install genomicranges
Usage
The package provide several ways to represent genomic annotations and intervals.
Initialize a GenomicRanges object
From UCSC or GTF file
Methods are available to easily access UCSC genomes or load a genome annotation from GTF
import genomicranges
gr = genomicranges.fromGTF(<PATH TO GTF>)
# OR
gr = genomicranges.fromUCSC(genome="hg19")
Pandas DataFrame
A common representation in Python is a pandas DataFrame for all tabular datasets. One can convert this into GenomicRanges. Intervals are inclusive on both ends.
Note: The DataFrame must contain columns seqnames, starts and ends to represent genomic coordinates.
import genomicranges
import pandas as pd
df = pd.DataFrame(
{
"seqnames": ["chr1", "chr2", "chr1", "chr3", "chr2"],
"starts": [101, 102, 103, 104, 109],
"ends": [112, 103, 128, 134, 111],
"strand": ["*", "-", "*", "+", "-"],
"score": range(0, 5),
"GC": [random() for _ in range(5)],
}
)
gr = genomicranges.fromPandas(df)
Interval Operations
Currently supports most commonly used interval based operations.
subject = genomicranges.fromUCSC(genome="hg38")
query = genomicranges.fromPandas(
pd.DataFrame(
{
"seqnames": ["chr1", "chr2", "chr3"],
"starts": [100, 115, 119],
"ends": [103, 116, 120],
}
)
)
hits = subject.nearest(query)
print(hits)
Checkout the documentation for more usecases.
Note
This project has been set up using PyScaffold 4.1.1. For details and usage information on PyScaffold see https://pyscaffold.org/.
Release files for genomicranges 0.2.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| GenomicRanges-0.2.11.tar.gz | 46.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| GenomicRanges-0.2.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.4 kB
Release files / GenomicRanges-0.2.11.tar.gz
| Download URL | GenomicRanges-0.2.11.tar.gz |
|---|---|
| Size | 46.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04926258b89f0283dc8c15fd170add16667912f89dd1f274cc86ee096243b89e
|
|
BLAKE2b-256 checksum How to use checksums |
50e07f61b4d91ab9c9cc4c3479ccfe2bfb35ff67360fa027e15ce60d5ef1301e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / GenomicRanges-0.2.11-py3-none-any.whl
| Download URL | GenomicRanges-0.2.11-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a04f632f1a89029e9c3846971b0cbe60b0fa108c9f525913e559978b100c230d
|
|
BLAKE2b-256 checksum How to use checksums |
fd5193711a0bcc46e05980218809d4830474d2d9bf55546240e65426e285cbba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|