Learn R Programming

ips (version 0.0-7)

trimEnds: Trim Alignment Ends

Description

This function trims both ends of a DNA sequence alignment to the first and last alignment positions that contain a minimum number of non-ambiguous characters (a, c, g, t). In addition, all gap characters ("-") beyond the first and last non-ambiguous 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.

Value

An object of class DNAbin.

See Also

deleteEmptyCells, deleteGaps

Examples

Run this code
# NOT RUN {
# 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, ])
# }

Run the code above in your browser using DataLab