IRanges-setops            package:IRanges            R Documentation

_S_e_t _o_p_e_r_a_t_i_o_n_s _o_n _I_R_a_n_g_e_s _o_b_j_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Performs set operations on IRanges objects.

_U_s_a_g_e:

       ## Vector-wise operations:
       ## S4 method for signature 'IRanges, IRanges':
       union(x, y)
       ## S4 method for signature 'IRanges, IRanges':
       intersect(x, y)
       ## S4 method for signature 'IRanges, IRanges':
       setdiff(x, y)

       ## Element-wise (aka "parallel") operations:
       punion(x, y, ...)
       pintersect(x, y, ...)
       psetdiff(x, y, ...)
       pgap(x, y, ...)

_A_r_g_u_m_e_n_t_s:

    x, y: IRanges objects. 

     ...: Further arguments to be passed to or from other methods. For
          example, the 'fill.gap' argument can be passed to the
          'punion' method for IRanges objects (see below). 

_D_e_t_a_i_l_s:

     The 'union', 'intersect' and 'setdiff' methods for IRanges objects
     return a "normal" IRanges object (of the same class as 'x')
     representing the union, intersection and (asymmetric!) difference
     of the sets of integers represented by 'x' and 'y'.

     'punion', 'pintersect', 'psetdiff' and 'pgap' are generic
     functions that compute the element-wise (aka "parallel") union,
     intersection, (asymmetric!) difference and gap between each
     element in 'x' and its corresponding element in 'y'. Methods for
     IRanges objects are defined. For these methods, 'x' and 'y' must
     have the same length (i.e. same number of ranges) and they return
     an IRanges instance of the same length as 'x' and 'y' where each
     range represents the union/intersection/difference/gap of/between
     the corresponding ranges in 'x' and 'y'.

     Note that the union or difference of 2 ranges cannot always be
     represented by a single range so 'punion' and 'psetdiff' cannot
     always return their result in an IRanges instance of the same
     length as the input. This happens to 'punion' when there is a gap
     between the 2 ranges to combine. In that case, the user can use
     the 'fill.gap' argument to enforce the union by filling the gap.
     This happens to 'psetdiff' when a range in 'y' has its end points
     strictly inside the corresponding range in 'x'. In that case,
     'psetdiff' will simply fail.

     If two ranges overlap, then the gap between them is empty.

_A_u_t_h_o_r(_s):

     H. Pages and M. Lawrence

_S_e_e _A_l_s_o:

     Ranges-class, IRanges-class, IRanges-utils

_E_x_a_m_p_l_e_s:

       x <- IRanges(c(1, 5, -2, 0, 14), c(10, 9, 3, 11, 17))
       y <- Views(as(4:-17, "XInteger"), start=c(14, 0, -5, 6, 18), end=c(20, 2, 2, 8, 20))

       ## Vector-wise operations:
       union(x, y)
       union(y, x)

       intersect(x, y)
       intersect(y, x)

       setdiff(x, y)
       setdiff(y, x)

       ## Element-wise (aka "parallel") operations:
       try(punion(x, y))
       punion(x[3:5], y[3:5])
       punion(x, y, fill.gap=TRUE)
       pintersect(x, y)
       psetdiff(y, x)
       try(psetdiff(x, y))
       start(x)[4] <- -99
       end(y)[4] <- 99
       psetdiff(x, y)
       pgap(x, y)

