msaConvert {msa} | R Documentation

## Convert Multiple Sequence Alignment for Other Packages

### Description

This function converts a multiple sequence alignment object to formats used in other sequence analysis packages.

### Usage

        msaConvert(x,
                   type=c("seqinr::alignment", "bios2mds::align",
                          "ape::AAbin", "ape::DNAbin",
                          "phangorn::phyDat", "bio3d::fasta"))

### Arguments

`x` | an object of class `MultipleAlignment` (which includes objects of classes `MsaAAMultipleAlignment`, `MsaDNAMultipleAlignment`, and `MsaRNAMultipleAlignment`)
`type` | a character string specifying to which type of object `x` should be converted; currently, the values `"seqinr::alignment"`, `"bios2mds::align"`, `"ape::AAbin"`, `"ape::DNAbin"`, `"phangorn::phyDat"`, and `"bio3d::fasta"`.

### Details

The function converts `x` to the class of object as specified by the `type` argument. The values possible for the `type` argument follow the same principle pkg::cl, i.e. `x` is converted to class cl as defined in the pkg package.

The conversions for usage by the packages seqinr, bios2mds, and ape work independently of these packages and do not strictly require these packages. They need not even be installed. This approach has been chosen to avoid abundant dependencies and possible incompatibilities. That is also why the standard S3/S4 mechanism of `as`/`as.class` functions is not used.

The conversion to the `phyDat` class can be done easily using the `as.phyDat` function from the phangorn package. The `msaConvert` function still provides this conversion for the sake of consistency. However, this conversion is just a wrapper function around the `as.phyDat` function from the phangorn package. Thus, the phangorn package needs to be installed.

The conversion `"ape::AAbin"` only works for multiple alignments of amino acid sequences, while the conversions `"ape::DNAbin"` and `"phangorn::phyDat"` only work for multiple alignments of DNA sequences. When converting to `"ape::AAbin"`, gaps/dashes are replaced by ‘X’. Moreover, conversions to `"ape::DNAbin"` also convert all characters to lowercase and replace gaps/dashes by ‘n’.

### Value

The function returns an object of the class as specified by the `type` argument.

### Author(s)

Ulrich Bodenhofer <msa@bioinf.jku.at>

### References

http://www.bioinf.jku.at/software/msa

U. Bodenhofer, E. Bonatesta, C. Horejs-Kainrath, and S. Hochreiter (2015). msa: an R package for multiple sequence alignment. Bioinformatics 31(24):3997-3999. DOI: 10.1093/bioinformatics/btv494.

### See Also

`msa`, `MsaAAMultipleAlignment`, `MsaDNAMultipleAlignment`, `MsaRNAMultipleAlignment`, `MsaMetaData`

### Examples

    ## read sequences
    filepath <- system.file("examples", "exampleAA.fasta", package="msa")
    mySeqs <- readAAStringSet(filepath)

    ## perform multiple alignment
    myAlignment <- msa(mySeqs)

    ## convert to an object of class 'alignment' (package 'seqinr')
    msaConvert(myAlignment, "seqinr::alignment")

    ## convert to an object of class 'align' (package 'bios2mds')
    msaConvert(myAlignment, "bios2mds::align")

[Package msa version 1.18.0 Index]