-
Notifications
You must be signed in to change notification settings - Fork 0
/
nearest.Rmd
33 lines (27 loc) · 1.03 KB
/
nearest.Rmd
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
# Finding the closest intervals
With the nearest-method, you can search for the feature in other that is nearest
the ones in self.
```{python tidy=FALSE}
import pyranges as pr
gr = pr.load_dataset("chipseq")
gr2 = pr.load_dataset("chipseq_background")
print(gr.nearest(gr2, suffix="_Input"))
```
The nearest method takes a strandedness option, which can either be
`"same"`, `"opposite"` or `False`/`None`
```{python tidy=FALSE}
print(gr.nearest(gr2, suffix="_Input", strandedness="opposite"))
```
The nearest method also takes two variables, namely how and overlap. How can
take the values `None`, `"next"` and `"previous"`. The default
is `None`, which means that PyRanges looks in both directions. The default
is `None`. The overlap argument is a bool which indicates whether you want
to include overlaps or not.
```{python tidy=FALSE}
f1 = pr.load_dataset("f1")
print(f1)
f2 = pr.load_dataset("f2")
print(f2)
print(f2.nearest(f1, strandedness="opposite", how="next"))
print(f2.nearest(f1, strandedness="opposite", how="next", overlap=False))
```