alphabetFrequency {XNAString} | R Documentation

## XNAAlphabetFrequency returns letters frequency for a given object in base, sugar or backbone slot

### Description

XNAAlphabetFrequency returns letters frequency for a given object in base, sugar or backbone slot

XNAAlphabetFrequency method returns alphabet frequency for a given object. It works for 3 slots: base, sugar and backbone. If matrix_nbr equals 1, alphabet frequency for the first elements in the slot is returned. Letters can be given as argument, otherwise unique letters in object's dictionary are in use.

### Usage

    XNAAlphabetFrequencyFun(
      obj,
      slot,
      letters = NA,
      matrix_nbr = 1,
      as.prob = FALSE,
      base_only = FALSE
    )

    XNAAlphabetFrequency(
      obj,
      slot,
      letters = NA,
      matrix_nbr = 1,
      as.prob = FALSE,
      base_only = FALSE,
      ...
    )

    ## S4 method for signature 'XNAString'
    XNAAlphabetFrequency(
      obj,
      slot,
      letters = NA,
      matrix_nbr = 1,
      as.prob = FALSE,
      base_only = FALSE
    )

    ## S4 method for signature 'XNAStringSet'
    XNAAlphabetFrequency(
      obj,
      slot,
      letters = NA,
      matrix_nbr = 1,
      as.prob = FALSE,
      base_only = FALSE
    )

### Arguments

`obj` | XNAString or XNAStringSet class
`slot` | string (slot name: base, sugar or backbone)
`letters` | character (or character vector)
`matrix_nbr` | numeric (1 or 2, if 1 - first slot's element is use, if 2 - 2nd element in slot)
`as.prob` | logical - if TRUE frequency returned as probability of occurence
`base_only` | logical - if TRUE, frequency checked for 'A', 'C', 'G', 'T', other
`...` | optional arguments to generic function to support additional methods

### Value

matrix (frequency matrix for a given slot)

### Examples

    xnastring_obj <- XNAString(
      name = "b",
      base = c("AACC", "GGEE"),
      sugar = c("FFOO", "OODD")
    )
    XNAAlphabetFrequency(obj = xnastring_obj,
                         slot = "base")
    XNAAlphabetFrequency(obj = xnastring_obj,
                         slot = "base",
                         as.prob = TRUE)
    XNAAlphabetFrequency(obj = xnastring_obj,
                         slot = "base",
                         base_only = TRUE)
    XNAAlphabetFrequency(obj = xnastring_obj,
                         slot = "base",
                         letters = c("A", "C"))
    XNAAlphabetFrequency(obj = xnastring_obj,
                         slot = "base",
                         matrix_nbr = 2)

    xnastring_obj_2 <- XNAString(
      base = c("ATCG"),
      sugar = c("FODD"),
      backbone = c("SBB")
    )
    XNAStringSet_obj <- XNAStringSet(objects = list(
      xnastring_obj,
      xnastring_obj_2
    ))
    XNAAlphabetFrequency(XNAStringSet_obj, "sugar")

[Package XNAString version 1.2.2 Index]