Last active
December 21, 2021 14:05
-
-
Save endrebak/a4b276abc7fae187bc85298fdb01fa15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyranges as pr | |
gr = pr.PyRanges(chromosomes=["chr1"] * 2 + ["chr2"] * 2, starts=[0, 100, 200, 300], ends=[50, 150, 250, 350], strands=["+", "+", "-", "-"]) | |
gr.spliced_subsequence(0, -75, by="gene") | |
+--------------+-----------+-----------+--------------+------------+ | |
| Chromosome | Start | End | Strand | gene | | |
| (category) | (int64) | (int32) | (category) | (object) | | |
|--------------+-----------+-----------+--------------+------------| | |
| chr1 | 0 | 25 | + | 1 | | |
| chr2 | 325 | 350 | - | 2 | | |
+--------------+-----------+-----------+--------------+------------+ | |
Stranded PyRanges object has 2 rows and 5 columns from 2 chromosomes. | |
For printing, the PyRanges was sorted on Chromosome and Strand. | |
gr.spliced_subsequence(-80, -10, by="gene") | |
+--------------+-----------+-----------+--------------+------------+ | |
| Chromosome | Start | End | Strand | gene | | |
| (category) | (int64) | (int32) | (category) | (object) | | |
|--------------+-----------+-----------+--------------+------------| | |
| chr1 | 20 | 50 | + | 1 | | |
| chr1 | 100 | 140 | + | 1 | | |
| chr2 | 210 | 250 | - | 2 | | |
| chr2 | 300 | 330 | - | 2 | | |
+--------------+-----------+-----------+--------------+------------+ | |
Stranded PyRanges object has 4 rows and 5 columns from 2 chromosomes. | |
For printing, the PyRanges was sorted on Chromosome and Strand. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment