Debian Codegraph @

man/interval_overlap-methods.Rd

raw
1 \name{interval_overlap}
2
3 \alias{interval_overlap}
4 \alias{interval_overlap,Intervals_virtual_or_numeric,Intervals_virtual_or_numeric-method}
5 \alias{interval_overlap,missing,ANY-method}
6 \alias{interval_overlap,ANY,missing-method}
7
8 \title{Assess overlap from one set of intervals to another}
9
10 \description{
11 Assess overlap from intervals in one set to intervals in another set,
12 and return the relevant indices.
13 }
14
15 \usage{
16 \S4method{interval_overlap}{Intervals_virtual_or_numeric,Intervals_virtual_or_numeric}(from, to, check_valid = TRUE)
17 }
18
19 \arguments{
20
21 \item{from}{
22 An \code{"Intervals"} or \code{"Intervals_full"} object, or a
23 vector of class \code{"numeric"}. \emph{Note!} Prior to v. 0.11.1,
24 this argument was called \code{target}.
25 }
26
27 \item{to}{
28 An \code{"Intervals"} or \code{"Intervals_full"} object, or a
29 vector of class \code{"numeric"}. \emph{Note!} Prior to v. 0.11.1,
30 this argument was called \code{query}.
31 }
32
33 \item{check_valid}{
34 Should \code{\link{validObject}} be called before passing to
35 compiled code? This, among other things, verifies that endpoints are
36 of data type \code{"numeric"} and the \code{closed} vector/matrix is
37 appropriately sized and of the correct data type. (Compiled code
38 does no further checking.)
39 }
40
41 }
42
43 \details{
44 Intervals which meet at endpoints overlap only if both endpoints are
45 closed. Intervals in \code{to} with \code{NA} endpoints are
46 ignored, with a warning; in \code{from}, such intervals produce no
47 matches. Intervals in either \code{to} or \code{from} which are
48 actually empty have their endpoints set to \code{NA} before
49 proceeding, with warning, and so do not generate matches. If
50 eith \code{to} or \code{from} is a vector of class \code{"numeric"},
51 overlap will be assess for the corresponding set of points.
52 }
53
54 \value{
55 A list, with one element for each row/component of \code{from}. The
56 elements are vectors of indices, indicating which \code{to} rows (or
57 components, for the \code{"numeric"} method) overlap each interval in
58 \code{from}. A list element of length 0 indicates no overlapping
59 elements.
60 }
61
62 \note{
63 If you want real (\code{type == "R"}) intervals that overlap in a set
64 of positive measure --- not just at endpoints --- set all endpoints to
65 open (i.e., \code{close(from) <- FALSE; closed(to) <- FALSE}) first.
66
67 This function is now just a wrapper for \code{\link{which_nearest}}.
68 }
69
70 \seealso{
71 See \code{\link{which_nearest}} for details on nearby as well as
72 overlapping intervals in \code{to}.
73 }
74
75 \examples{
76 # Note that 'from' contains a valid but empty interval.
77
78 to <- Intervals(
79 matrix(
80 c(
81 2, 8,
82 3, 4,
83 5, 10
84 ),
85 ncol = 2, byrow = TRUE
86 ),
87 closed = c( TRUE, FALSE ),
88 type = "Z"
89 )
90
91 from <- Intervals(
92 matrix(
93 c(
94 2, 8,
95 8, 9,
96 6, 9,
97 11, 12,
98 3, 3
99 ),
100 ncol = 2, byrow = TRUE
101 ),
102 closed = c( TRUE, FALSE ),
103 type = "Z"
104 )
105 rownames(from) <- letters[1:nrow(from)]
106
107 empty(to)
108 empty(from)
109
110 interval_overlap(from, to)
111
112 # Non-empty real intevals of size 0 can overlap other intervals.
113
114 u <- to
115 type(u) <- "R"
116
117 v <- Intervals_full( rep(3,4) )
118 closed(v)[2,] <- FALSE
119 v
120 empty(v)
121 size(v)
122
123 interval_overlap(v, u)
124
125 # Working with points
126
127 interval_overlap( from, c( 2, 3, 6, NA ) )
128 }