trimEnds: Trim Alignment Ends

Description Usage Arguments Value See Also Examples

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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, ])

Example output

Loading required package: ape
Loading required package: colorspace
Loading required package: XML
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
B "c"  "a"  "a"  "g"  "g"  "t"  "a"  "c" 

ips documentation built on July 4, 2019, 5:04 p.m.