build_cladistic_matrix: Creates a morphological data file from a matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/build_cladistic_matrix.R

Description

Creates a morphological data file from a character-taxon matrix.

Usage

1
2
3
4
5
6
7
8
9
build_cladistic_matrix(
  character_taxon_matrix,
  header = "",
  character_weights = NULL,
  ordering = NULL,
  symbols = NULL,
  equalise.weights = FALSE,
  ignore_duplicate_taxa = FALSE
)

Arguments

character_taxon_matrix

A Character-Taxon (columns-rows) matrix, with taxon names as rownames.

header

A scalar indicating any header text (defaults to an empty string: "").

character_weights

A vector specifying the weights used (if not specified defaults to 1).

ordering

A vector indicating whether characters are ordered ("ord") or unordered ("unord") (if no specified defaults to ordered).

symbols

The symbols to use if writing to a file (defaults to the numbers 0:9 then the letters A to V).

equalise.weights

Optional that overrides the weights specified above make all characters truly equally weighted.

ignore_duplicate_taxa

Logical indicating whether or not to ignore (allow; TRUE) duplicate taxa or not (FALSE; default).

Details

Claddis generally assumes that matrices will be imported into R from the #NEXUS format, but in some cases (e.g., when using simulated data) it might be desirable to build a matrix within R. This function allows the user to convert such a matrix into the format required by other Claddis functions as long as it only contains a single block.

NB: Currently the function cannot deal directly with step matrices or continuous characters.

Value

topper

Contains any header text or step matrices and pertains to the entire file.

matrix_N

One or more matrix blocks (numbered 1 to N) with associated information pertaining only to that matrix block. This includes the block name (if specificed, NA if not), the block datatype (one of "CONTINUOUS", "DNA", "NUCLEOTIDE", "PROTEIN", "RESTRICTION", "RNA", or "STANDARD"), the actual matrix (taxa as rows, names stored as rownames and characters as columns), the ordering type of each character ("ord" = ordered, "unord" = unordered), the character weights, the minimum and maximum values (used by Claddis' distance functions), and the original characters (symbols, missing, and gap values) used for writing out the data.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

See Also

compactify_matrix, prune_cladistic_matrix, read_nexus_matrix, safe_taxonomic_reduction, write_nexus_matrix, write_tnt_matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Create random 10-by-50 matrix:
character_taxon_matrix <- matrix(sample(c("0", "1", "0&1", NA, ""),
  500,
  replace = TRUE
),
nrow = 10, dimnames =
  list(apply(matrix(sample(LETTERS, 40,
    replace = TRUE
  ), nrow = 10), 1, paste,
  collapse = ""
  ), c())
)

# Reformat for use elsewhere in Claddis:
build_cladistic_matrix(character_taxon_matrix)

Claddis documentation built on Oct. 23, 2020, 8:04 p.m.