trimEnds: Trim Alignment Ends

View source: R/trimEnds.R

trimEndsR Documentation

Trim Alignment Ends

Description

Trims both ends of a DNA sequence alignment to the first and last alignment positions that contain a minimum number of IUPAC base characters ("a", "c", "g", "t", "r", "y", "s", "w", "k", "m", "b", "d", "h", "v"). In addition, all gap characters ("-") beyond the first and last base characters of each sequence are replaced by the character "n".

Usage

trimEnds(x, min.n.seq = 4)

Arguments

x

An object of class DNAbin.

min.n.seq

A numeric giving the required minimum number of sequences having an non-ambiguous base character (a, c, g, t) in the first and last position of the alignment; defaults to 4, which is the minimum number of sequences needed to produce a non-trivial unrooted topology. Can also be given as a fraction.

Value

An object of class DNAbin.

See Also

deleteEmptyCells, deleteGaps

Examples

# simple example alignment:
x <- structure(list(nb = 5, seq = c("acaaggtaca", "-caaggtac-",
"acaaggtaca", "aca--gtaca", "-ccaggta--"), nam = LETTERS[1:5]),
.Names = c("nb", "seq", "nam"), class = "alignment")
# convert to DNAbin:
x <- as.DNAbin(x)
# fill missing nucleotides:
x <- trimEnds(x)
# show results:
as.character(x[2, ])

heibl/ips documentation built on April 24, 2024, 3:19 a.m.