make.binary: Convert a Character Matrix to a Binary Character Matrix

View source: R/make.binary.R

make.binaryR Documentation

Convert a Character Matrix to a Binary Character Matrix

Description

Convert a matrix of characters into a binary matrix by removing all columns that do not contain characters in exactly 2 states.

Usage

make.binary(dat, binChars = strsplit("ACDEFGHIKLMNPQRSTVWY", "")[[1]], extras = c("-"))

Arguments

dat

A matrix of characters.

binChars

An optional vector of all acceptable characters to represent a state in the binary matrix.

extras

An optional vector of all other acceptable characters which can be present in the binary matrix. These will not be counted towards one state or another.

Details

The default for binChars is all c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'), the IUPAC one-letter abbreviations for amino acids.

The default for extras is c('-'), the symbol for a gap in an alignment.

This function works by requiring that each column in a matrix have exactly two character states that have been listed as acceptable in binChars, or an acceptable non-state listed in extras. It removes all columns that do not fit these criteria and returns the resulting matrix.

Value

The converted character binary matrix.

Author(s)

Kasey Pham and Andrew Hipp

See Also

fas2bin


andrew-hipp/morton documentation built on April 7, 2024, 12:15 p.m.