separate {Modstrings} | R Documentation

## Separating and combining a modification information into/from a `XString` and a `GRanges` object

### Description

With `combineIntoModstrings` and `separate` the construction and deconstruction of ModString Objects from an interacive session avoiding problematic encoding issues. In addition, modification information can be transfered from/to tabular data with these functions.

`combineIntoModstrings` expects `seqnames(gr)` or `names(gr)` to match the available `names(x)`. Only information with strand information `*` and `+` are used.

`separate` when used with a `GRanges`/`GRangesList` object will return an object of the same type, but with modifications seperated. For example an element with `mod = "m1Am"` will be returned as two elements with `mod = c("Am","m1A")`. The reverse operation is available via `combineModifications()`.

`removeIncompatibleModifications` filters incompatible modification from a `GRanges` or `GRangesList`. `incompatibleModifications()` returns the logical vector used for this operation.

### Usage

    separate(x, nc.type = "short")

    combineIntoModstrings(
      x,
      gr,
      with.qualities = FALSE,
      quality.type = "Phred",
      stop.on.error = TRUE,
      verbose = FALSE,
      ...
    )

    combineModifications(gr, ...)

    incompatibleModifications(gr, x, ...)

    removeIncompatibleModifications(gr, x, ...)

    ## S4 method for signature 'ModString'
    separate(x, nc.type = c("short", "nc"))

    ## S4 method for signature 'ModStringSet'
    separate(x, nc.type = c("short", "nc"))

    ## S4 method for signature 'GRanges'
    separate(x)

    ## S4 method for signature 'GRangesList'
    separate(x)

    ## S4 method for signature 'XString,GRanges'
    combineIntoModstrings(
      x,
      gr,
      with.qualities = FALSE,
      quality.type = "Phred",
      stop.on.error = TRUE,
      verbose = FALSE,
      ...
    )

    ## S4 method for signature 'XStringSet,GRangesList'
    combineIntoModstrings(
      x,
      gr,
      with.qualities = FALSE,
      quality.type = "Phred",
      stop.on.error = TRUE,
      verbose = FALSE,
      ...
    )

    ## S4 method for signature 'XStringSet,GRanges'
    combineIntoModstrings(
      x,
      gr,
      with.qualities = FALSE,
      quality.type = "Phred",
      stop.on.error = TRUE,
      verbose = FALSE,
      ...
    )

    ## S4 method for signature 'GRanges'
    combineModifications(gr)

    ## S4 method for signature 'GRangesList'
    combineModifications(gr)

    ## S4 method for signature 'GRanges,XString'
    incompatibleModifications(gr, x)

    ## S4 method for signature 'GRanges,XStringSet'
    incompatibleModifications(gr, x)

    ## S4 method for signature 'GRangesList,XStringSet'
    incompatibleModifications(gr, x)

    ## S4 method for signature 'GRanges,XString'
    removeIncompatibleModifications(gr, x)

    ## S4 method for signature 'GRanges,XStringSet'
    removeIncompatibleModifications(gr, x)

    ## S4 method for signature 'GRangesList,XStringSet'
    removeIncompatibleModifications(gr, x)

### Arguments

`x` | For `separate`: a `ModString`/`ModStringSet` or `GRanges`/`GRangesList`object For `combineIntoModstrings`: a `XString` and a `XStringSet` object.
`nc.type` | the type of nomenclature to be used. Either "short" or "nc". "Short" for m3C would be "m3C", "nc" for m3C would be "3C". ( `default = "short"`)
`gr` | a GRanges object
`with.qualities` | `TRUE` or `FALSE` (default): Should the values from a `score` column of the `GRanges` object stored? If set `with.qualities = TRUE`, `combineIntoModstrings` will try to construct a `QualityScaledModStringSet` object.
`quality.type` | the type of `QualityXStringSet` used, if `with.qualities = TRUE`. Must be on of the following values: `"Phred","Solexa","Illumina"`.
`stop.on.error` | For `combineIntoModstrings`: `TRUE`(default) or `FALSE`: Should an error be raised upon encounter of incompatible positions?
`verbose` | For `combineIntoModstrings`: `TRUE` or `FALSE` (default): Should verbose information reported on the positions filled with modifications? This settings is passed onto `modifyNucleotides`.
`...` | `default.quality`: For `combineIntoModstrings`: the `default.quality` default value for non-modified positions. (default: `default.quality = 0L`)

### Value

for `separate` a `GRanges` object and for `combineIntoModstrings` a `ModString*` object or a `QualityScaledModStringSet`, if `with.qualities = TRUE`.

### Examples

    library(GenomicRanges)
    # ModDNAString
    seq <- ModDNAString(paste(alphabet(ModDNAString()), collapse = ""))
    seq

    gr <- separate(seq)
    gr

    seq2 <- combineIntoModstrings(as(seq,"DNAString"),gr)
    seq2

    seq == seq2
    # ModRNAString
    seq <- ModRNAString(paste(alphabet(ModRNAString()), collapse = ""))
    seq

    gr <- separate(seq)
    gr

    # Separating RNA modifications
    gr <- gr[1]
    separate(gr)

    # ... and combine them again (both operations work only on a subset of
    # modifications)
    combineModifications(separate(gr))

    # handling incompatible modifications
    seq <- RNAString("AGCU")
    gr <- GRanges(c("chr1:1:+","chr1:2:+"),mod="m1A")
    incompatibleModifications(gr,seq)

    #
    removeIncompatibleModifications(gr,seq)

[Package Modstrings version 1.10.0 Index]