R: dN/dS Ratio

dnds {ape} | R Documentation

## dN/dS Ratio

### Description

This function computes the pairwise ratios dN/dS for a set of aligned DNA sequences using Li's (1993) method.

### Usage

    dnds(x, code = 1, codonstart = 1, quiet = FALSE,
         details = FALSE, return.categories = FALSE)

### Arguments

`x` | an object of class `"DNAbin"` (matrix or list) with the aligned sequences.
`code` | an integer value giving the genetic code to be used. Currently, the codes 1 to 6 are supported.
`codonstart` | an integer giving where to start the translation. This should be 1, 2, or 3, but larger values are accepted and have for effect to start the translation further within the sequence.
`quiet` | single logical value: whether to indicate progress of calculations.
`details` | single logical value (see details).
`return.categories` | a logical value: if `TRUE`, a matrix of the same size than `x` is returned giving the degeneracy category of each base in the original alignment.

### Details

Since ape 5.6, the degeneracy of each codon is calculated directly from the genetic code using the function `trans`. A consequence is that ambiguous bases are ignored (see `solveAmbiguousBases`).

If `details = TRUE`, a table is printed for each pair of sequences giving the numbers of transitions and transversions for each category of degeneracy (nondegenerate, twofold, and fourfold). This is helpful when non-meaningful values are returned (e.g., NaN, Inf, negative values).

### Value

an object of class `"dist"`, or a numeric matrix if `return.categories = TRUE`.

### Author(s)

Emmanuel Paradis

### References

Li, W.-H. (1993) Unbiased estimation of the rates of synonymous and nonsynonymous substitution. Journal of Molecular Evolution, 36, 96–99.

### See Also

`AAbin`, `trans`, `alview`, `solveAmbiguousBases`

### Examples

    data(woodmouse)
    res <- dnds(woodmouse, quiet = TRUE) # NOT correct
    res2 <- dnds(woodmouse, code = 2, quiet = TRUE) # using the correct code
    identical(res, res2)
    ## There a few N's in the woodmouse data, but this does not affect
    ## greatly the results:
    res3 <- dnds(solveAmbiguousBases(woodmouse), code = 2, quiet = TRUE)
    cor(res, res3)

    ## a simple example showing the usefulness of 'details = TRUE'
    X <- as.DNAbin(matrix(c("C", "A", "G", "G", "T", "T"), 2, 3))
    alview(X)
    dnds(X, quiet = TRUE) # NaN + warnings
    dnds(X, details = TRUE) # only a TV at a nondegenerate site

[Package ape version 5.6 Index]