Learn R Programming

tidysq (version 1.2.3)

reverse: Reverse sequence

Description

Reverse given list of sequences.

Usage

reverse(x, ...)

# S3 method for sq reverse(x, ..., NA_letter = getOption("tidysq_NA_letter"))

Value

An sq object of the same type as input object but each sequence is reversed.

Arguments

x

[sq]
An object this function is applied to.

...

further arguments to be passed from or to other methods.

NA_letter

[character(1)]
A string that is used to interpret and display NA value in the context of sq class. Default value equals to "!".

Details

reverse() function reverses each sequence in supplied sq object (e.q. transforms "MIAANYTWIL" to "LIWTYNAAIM"). This operation does not alter the type of the input object nor its alphabet.

See Also

Functions that affect order of elements: bite(), collapse(), paste()

Examples

Run this code
# Creating objects to work on:
sq_ami <- sq(c("MIAANYTWIL","TIAALGNIIYRAIE", "NYERTGHLI", "MAYXXXIALN"),
             alphabet = "ami_ext")
sq_dna <- sq(c("ATGCAGGA", "GACCGAACGAN", ""), alphabet = "dna_ext")
sq_unt <- sq(c("ATGCAGGA?", "TGACGAGCTTA", "", "TIAALGNIIYRAIE"))

# Reversing sequences:
reverse(sq_ami)
reverse(sq_dna)
reverse(sq_unt)

Run the code above in your browser using DataLab