Learn R Programming

Claddis (version 0.7.0)

build_cladistic_matrix: Creates a morphological data file from a matrix

Description

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

Usage

build_cladistic_matrix(
  character_taxon_matrix,
  header = "",
  character_weights = NULL,
  ordering = NULL,
  symbols = NULL,
  equalise.weights = FALSE,
  ignore_duplicate_taxa = FALSE
)

Value

topper

Contains any header text or costmatrices 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 ("ordered", "unordered" etc.), 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.

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 ("ordered") or unordered ("unordered") (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).

Author

Graeme T. Lloyd graemetlloyd@gmail.com

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 costmatrices or continuous characters.

See Also

compactify_cladistic_matrix, prune_cladistic_matrix, read_nexus_matrix, safe_taxonomic_reduction, write_nexus_matrix, write_tnt_matrix

Examples

Run this code

# 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)

Run the code above in your browser using DataLab