# Statistics: spatial correlations between PyRanges

To compute the similarities between two sets of ranges which do not necessarily
overlap much, we can use the relative distance function. It describes the
relative distances between each interval in one set and the two closest intervals
in another. Any deviance from a uniform distribution is an indication of spatial
correlation.

```{python tidy=FALSE}
import pyranges as pr
gr = pr.data.chipseq()
gr2 = pr.data.chipseq_background()
print(gr.stats.relative_distance(gr2, strandedness="same"))
```
