deleteGaps: Remove Gap/Indel Positions from Alignment

Description Usage Arguments Details Value Author(s) See Also


This function removes indel positions (or gaps) from a DNA sequence alignment. For faster execution, deleteGaps handles sequences in ape's bit-level coding scheme.


deleteGaps(x, nmax = nrow(x) - 4)



an object of class DNAbin.


an integer number between 0 and nrow(x) - 2, which gives the maximum number of gap characters ("-") that will be tolerated at any given alignment position (column).


The default, nmax = nrow(x) - 4, removes all those positions from the alignment, which contain at least four non-gap characters, which is the minimum number of sequences needed to produce a non-trivial unrooted topology. All gaps will be excluded by selecting nmax = 0 and half of all gaps with nmax = nrow(x) / 2.

In contrast, del.gaps removes all gap characters from the alignment, so most probably the result will not be a set of sequences of equal length and the matrix will be coerced to a list.


an object of class DNAbin.


Christoph Heibl

See Also

code.simple.gaps for coding of simple gaps, del.gaps for removal of all gap symbols from an alignment, gblocks and aliscore for more sophisticated methods of cleaning/masking alignments.

Search within the ips package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.