mask {Biostrings}R Documentation

Masking portions of a sequence

Description

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).

Usage

  mask(x, ...)

Arguments

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.

Details

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".

Value

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

Author(s)

H. Pages

See Also

BStringViews, BString, DNAString, RNAString

Examples

  ## 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)
  chrU <- Dmelanogaster[["U"]]
  alphabetFrequency(chrU)
  noN_chrU <- mask(chrU, "N")
  alphabetFrequency(noN_chrU)

  ## masking a BStringViews object
  mask(noN_chrU)
  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)))

[Package Biostrings version 2.6.6 Index]