The replacements of ambiguous bases are done columwise. First, the
base frequencies are counted: if no ambiguous base is found in the
column, nothing is done. By default (i.e., if random = TRUE
),
the replacements are done by random sampling using the frequencies of
the observed compatible, non-ambiguous bases. For instance, if the
ambiguous base is Y, it is replaced by either C or T using their
observed frequencies as probabilities. If random = FALSE
, the
greatest of these frequencies is used. If there are no compatible
bases in the column, equal probabilities are used. For instance, if
the ambiguous base is R, and only C and T are observed, then it is
replaced by either A or G with equal probabilities.
Alignment gaps are not changed; see the function latag2n
to change the leading and trailing gaps.