distance_to_nearest {genomeIntervals} | R Documentation |
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.
## 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)
from |
A |
to |
A |
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.
A numeric vector of distances with one element for each row of from
.
intervals::distance_to_nearest
## 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") )