1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
---
jupytext:
formats: ipynb,md:myst
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.11.3
kernelspec:
display_name: Python 3
language: python
name: python3
---
# Low-level API
```{eval-rst}
.. toctree::
:maxdepth: 2
:caption: Contents:
lowlevel/arrops
lowlevel/specs
lowlevel/stringops
```
Low level array-based operations are used to implement the genomic interval operations on dataframes.
```{code-cell} ipython3
import itertools
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import bioframe as bf
import bioframe.vis
from bioframe.core import arrops
```
```{code-cell} ipython3
starts1, ends1 = np.array([
[1,5],
[3,8],
[8,10],
[12,14]
]).T
starts2, ends2 = np.array([
[4,8],
[10,11],
]).T
```
```{code-cell} ipython3
bf.vis.plot_intervals_arr(
starts = starts1,
ends = ends1,
xlim = (-0.5,14.5),
labels = np.arange(0,starts1.shape[0]),
show_coords = True)
bf.vis.plot_intervals_arr(
starts = starts2,
ends = ends2,
colors = 'lightpink',
xlim = (-0.5,14.5),
labels = np.arange(0,starts2.shape[0]),
show_coords = True)
```
```{code-cell} ipython3
arrops.overlap_intervals(starts1, ends1, starts2, ends2)
```
```{code-cell} ipython3
arrops.overlap_intervals_outer(starts1, ends1, starts2, ends2)
```
```{code-cell} ipython3
arrops.merge_intervals(starts1, ends1, min_dist=0)
```
```{code-cell} ipython3
arrops.merge_intervals(starts1, ends1, min_dist=None)
```
```{code-cell} ipython3
arrops.merge_intervals(starts1, ends1, min_dist=2)
```
```{code-cell} ipython3
arrops.complement_intervals(starts1, ends1)
```
|