AlignTranslation {DECIPHER} | R Documentation

## Align Sequences By Their Amino Acid Translation

### Description

Performs alignment of a set of DNA or RNA sequences by aligning their corresponding amino acid sequences.

### Usage

    AlignTranslation(myXStringSet,
                     sense = "+",
                     direction = "5' to 3'",
                     readingFrame = NA,
                     type = class(myXStringSet),
                     geneticCode = GENETIC_CODE,
                     ...)

### Arguments

`myXStringSet` | A `DNAStringSet` or `RNAStringSet` object of unaligned sequences.
`sense` | Single character specifying sense of the input sequences, either the positive (`"+"`) coding strand or negative (`"-"`) non-coding strand.
`direction` | Direction of the input sequences, either `"5' to 3'"` or `"3' to 5'"`.
`readingFrame` | Numeric vector giving a single reading frame for all of the sequences, or an individual reading frame for each sequence in `myXStringSet`. The `readingFrame` can be either `1`, `2`, `3` to begin translating on the first, second, and third nucleotide position, or `NA` (the default) to guess the reading frame. (See details section below.)
`type` | Character string indicating the type of output desired. This should be (an abbreviation of) one of `"DNAStringSet"`, `"RNAStringSet"`, `"AAStringSet"`, or `"both"`. (See value section below.)
`geneticCode` | Either a character vector giving the genetic code in the same format as `GENETIC_CODE` (the default), or a list containing one genetic code for each sequence in `myXStringSet`.
`...` | Further arguments to be passed directly to `AlignSeqs`, including `gapOpening`, `gapExtension`, `gapPower`, `terminalGap`, `restrict`, `anchor`, `normPower`, `substitutionMatrix`, `structureMatrix`, `alphabet`, `guideTree`, `iterations`, `refinements`, `useStructures`, `structures`, `FUN`, and `levels`.

### Details

Alignment of proteins is often more accurate than alignment of their coding nucleic acid sequences. This function aligns the input nucleic acid sequences via aligning their translated amino acid sequences. First, the input sequences are translated according to the specified `sense`, `direction`, and `readingFrame`. The resulting amino acid sequences are aligned using `AlignSeqs`, and this alignment is (conceptually) reverse translated into the original sequence type, `sense`, and `direction`. Not only is alignment of protein sequences generally more accurate, but aligning translations will ensure that the reading frame is maintained in the nucleotide sequences.

If the `readingFrame` is `NA` (the default) then an attempt is made to guess the reading frame of each sequence based on the number of stop codons in the translated amino acids. For each sequence, the first reading frame will be chosen (either `1`, `2`, or `3`) without stop codons, except in the final position. If the number of stop codons is inconclusive for a sequence then the reading frame will default to `1`. The entire length of each sequence is translated in spite of any stop codons identified. Note that this method is only constructive in circumstances where there is a substantially long coding sequence with at most a single stop codon expected in the final position, and therefore it is preferable to specify the reading frame of each sequence if it is known.

### Value

An `XStringSet` of the class specified by `type`, or a list of two components (nucleotides and amino acids) if `type` is `"both"`. Note that incomplete starting and ending codons will be translated into the mask character ("+") if the result includes an `AAStringSet`.

### Author(s)

Erik Wright eswright@pitt.edu

### References

Wright, E. S. (2015). DECIPHER: harnessing local sequence context to improve protein multiple sequence alignment. BMC Bioinformatics, 16, 322. http://doi.org/10.1186/s12859-015-0749-z

### See Also

`AlignDB`, `AlignProfiles`, `AlignSeqs`, `AlignSynteny`, `CorrectFrameshifts`

### Examples

    # first three sequences translate to  MFITP*
    # and the last sequence translates as MF-TP*
    rna <- RNAStringSet(c("AUGUUCAUCACCCCCUAA", "AUGUUCAUAACUCCUUGA",
    	"AUGUUCAUUACACCGUAG", "AUGUUUACCCCAUAA"))
    RNA <- AlignSeqs(rna, verbose=FALSE)
    RNA

    RNA <- AlignTranslation(rna, verbose=FALSE)
    RNA

    AA <- AlignTranslation(rna, type="AAStringSet", verbose=FALSE)
    AA

    BOTH <- AlignTranslation(rna, type="both", verbose=FALSE)
    BOTH

    # example of aligning many protein coding sequences:
    fas <- system.file("extdata", "50S_ribosomal_protein_L2.fas", package="DECIPHER")
    dna <- readDNAStringSet(fas)
    DNA <- AlignTranslation(dna) # align the translation then reverse translate
    DNA

    # using a mixture of standard and non-standard genetic codes
    gC1 <- getGeneticCode(id_or_name2="1", full.search=FALSE, as.data.frame=FALSE)
    # Mollicutes use an alternative genetic code
    gC2 <- getGeneticCode(id_or_name2="4", full.search=FALSE, as.data.frame=FALSE)
    w <- grep("Mycoplasma|Ureaplasma", names(dna))
    gC <- vector("list", length(dna))
    gC[-w] <- list(gC1)
    gC[w] <- list(gC2)
    AA <- AlignTranslation(dna, geneticCode=gC, type="AAStringSet")
    BrowseSeqs(AA)

[Package DECIPHER version 2.20.0 Index]