TreeTools (version 0.1.3)

ReadCharacters: Read characters from Nexus file

Description

Parses a Nexus file, reading character states and names.

Usage

ReadCharacters(filepath, character_num = NULL, session = NULL)

ReadTntCharacters(filepath, character_num = NULL, session = NULL)

ReadAsPhyDat(filepath)

ReadTntAsPhyDat(filepath)

PhyDat(dataset)

Arguments

filepath

character string specifying location of file

character_num

Index of character(s) to return. NULL, the default, returns all characters.

session

(optionally) a Shiny session with a numericInput named character_num whose maximum should be updated.

dataset

list of taxa and characters, in the format produced by read.nexus.data: a list of sequences each made of a single vector of mode character, and named with the taxon name.

Value

A matrix whose row names correspond to tip labels, and column names correspond to character labels, with the attribute state.labels listing the state labels for each character; or a character string explaining why the character cannot be returned.

Functions

  • ReadTntCharacters: Read characters from TNT file

  • ReadAsPhyDat: Read Nexus characters as phyDat object.

  • ReadTntAsPhyDat: Read TNT characters as phyDat object.

  • PhyDat: A convenient wrapper for phangorn's phyDat, which converts a list of morphological characters into a phyDat object. If your morphological characters are in the form of a matrix, perhaps because they have been read using read.table, try MatrixToPhyDat instead.

Details

Tested with nexus files downloaded from MorphoBank with the "no notes" option, but should also work more generally.

Please report incorrectly parsed files.

References

Maddison1997TreeTools

Examples

Run this code
# NOT RUN {
fileName <- paste0(system.file(package='TreeTools'),
                   '/extdata/input/dataset.nex')
ReadCharacters(fileName)

# }

Run the code above in your browser using DataLab