distance_to_nearest-methods: Distance in bases to the closest interval(s)

Description Usage Arguments Details Value See Also Examples

Description

Given two objects, from and to, compute the distance in bases of each from interval to the nearest to interval(s). The distance between a base and the next inter-bases on either side values 0.5. Thus, base - base and inter-base - inter-base intervals distances are integer, whereas base - inter-base intervals distances are half-integers.

Usage

1
2
3
4
5
## S4 method for signature 'Genome_intervals,Genome_intervals'
distance_to_nearest(from, to)
## S4 method for signature 
## 'Genome_intervals_stranded,Genome_intervals_stranded'
distance_to_nearest(from, to)

Arguments

from

A Genome_intervals or Genome_intervals_stranded object.

to

A Genome_intervals or Genome_intervals object.

Details

A wrapper calling intervals::distance_to_nearest by seqnames and by strand (if both from and to are Genome_intervals_stranded objects). Thus, if both are stranded, distances are computed over each strand separately. One object must be coerced to Genome_intervals if this is not wished.

Value

A numeric vector of distances with one element for each row of from.

See Also

intervals::distance_to_nearest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## load toy examples
data(gen_ints)

## i in close_intervals notation
close_intervals(i)

## j in close_intervals notation
close_intervals(j)

## distances from i to j
dn = distance_to_nearest(i,j)
dn

## distance == 0 if and only if the interval overlaps another one:
io = interval_overlap(i,j)
if( any( ( sapply(io, length) >0 )  != (!is.na(dn) & dn ==0) ) )
 	stop("The property 'distance == 0 if and only if the interval overlaps another one' is not followed for at least one instance.")

## distances without strand-specificity
distance_to_nearest(
 		as(i,"Genome_intervals"),
 		as(j,"Genome_intervals")
)

genomeIntervals documentation built on Nov. 8, 2020, 4:56 p.m.