\HeaderA{disjoin}{Making Ranges disjoint}{disjoin}
\aliasA{disjoin,Ranges-method}{disjoin}{disjoin,Ranges.Rdash.method}
\aliasA{disjointBins}{disjoin}{disjointBins}
\aliasA{disjointBins,Ranges-method}{disjoin}{disjointBins,Ranges.Rdash.method}
\keyword{utilities}{disjoin}
\begin{Description}\relax
Functions for making \code{\LinkA{Ranges}{Ranges.Rdash.class}} disjoint,
where no ranges overlap another.
\end{Description}
\begin{Usage}
\begin{verbatim}
  disjoin(x, ...)
  disjointBins(x, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] The \code{\LinkA{Ranges}{Ranges.Rdash.class}} instance, possibly
overlapping intervals.
\item[\code{...}] Additional arguments for methods
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{disjoin} method returns a disjoint
\code{\LinkA{Ranges}{Ranges.Rdash.class}}, by finding the union of the end points in
\code{x}. In other words, the result consists of a range for every
interval, of maximal length, over which the set of overlapping ranges
in \code{x} is the same and at least of size 1.

\code{disjointBins} segregates \code{x} into a set of bins so that the
ranges in each bin are disjoint. Lower-indexed bins are filled
first. The method returns an integer vector indicating the bin index
for each range.
\end{Details}
\begin{Author}\relax
M. Lawrence
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{reduce}{reduce}} for making normal ranges, a subset
of disjoint ranges, where there must be a gap of length >= 1 between
each range.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ir <- IRanges(c(1, 1, 4, 10), c(6, 3, 8, 10))
  disjoin(ir) # IRanges(c(1, 4, 7, 10), c(3, 6, 8, 10))

  disjointBins(IRanges(1, 5)) # 1L
  disjointBins(IRanges(c(3, 1, 10), c(5, 12, 13))) # c(2L, 1L, 2L)
\end{ExampleCode}
\end{Examples}

