mask               package:Biostrings               R Documentation

_M_a_s_k_i_n_g _p_o_r_t_i_o_n_s _o_f _a _s_e_q_u_e_n_c_e

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

     Use this function to mask some portions of a sequence. The
     portions to mask can either be specified "by position" (start/end)
     or "by content" (they match a given pattern).

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

       mask(x, ...)

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

       x: The single string or BString (or derived) object to mask.
          This can also be a BStringViews object. 

     ...: Additional arguments to be passed to or from methods. 

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

     For BString (or derived) objects, 'mask()' can be used in two
     different ways: by specifying the starts/ends of the portions to
     mask (masking "by position") or by specifying a pattern (masking
     "by content").

     For BStringViews objects, no extra argument is needed: 'y <-
     mask(x)' is the shortest (in term of number of views) BStringViews
     object such that: (a) subject(y) == subject(x), (b) y views cover
     the portions of the subject that are not covered by x views, (c) y
     views are sorted from left to right, (d) y views are not "out of
     limits".

_V_a_l_u_e:

     A BStringViews object containing the set of "unmasked" portions.

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

     H. Pages

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

     BStringViews, BString, DNAString, RNAString

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

       ## masking "by position"
       mask("AxyxyxBC", 2, 6)

       ## masking "by content"
       mask("AxyxyxBC", "xyx")

       ## masking the N's in a chromosome sequence
       library(BSgenome.Dmelanogaster.FlyBase.r51)
       x <- Dmelanogaster[["3L"]]
       alphabetFrequency(x)
       noN_x <- mask(x, "N")
       alphabetFrequency(noN_x)

       ## masking a BStringViews object
       v <- views("AxyxyxBC", c(6, 4,-1, NA), c(7, 6, 1, 1))
       mask(v)

       ## note that applying mask() again returns a BStringViews object
       ## where the original views on v have been merged, sorted from left to right
       ## and cleaned from their "out of limits" portions
       mask(mask(v))

       ## finally, note that mask(mask(mask(v))) is _always_ the same as mask(v)
       mask(mask(mask(v)))

