read.nex: Read in NEXUS data

View source: R/read.nex.R

read.nexR Documentation

Read in NEXUS data

Description

This function reads NEXUS data stored in nexus, text, or pdf files. Note: for pdf files, it is necessary to first install poppler with, e.g., 'brew install poppler'

Usage

read.nex(file, charlabels = NULL, charnums = NULL,
  statelabels = NULL, taxlabels = NULL, filename = NULL,
  ntax = NULL, nchar = NULL, first = NULL, last = NULL,
  missing = "?", gap = "-")

Arguments

file

(required) path to either a .nex, .txt, or .pdf file with NEXUS data

charlabels

optional path to text file with character statements

charnums

optional vector with character numbers

statelabels

optional character vector with state labels for characters

taxlabels

optional vector with names of taxa

filename

vector with names of files associated with characters

ntax

number of taxa (needed for PDF file reading)

nchar

number of characters (needed for PDF file reading)

first

first page for data matrix in a PDF file

last

last page for data matrix in a PDF file

missing

character representing missing data

gap

character representing inapplicable/incomporable data

Value

an object of class nex for use in further phenotools functions

Author(s)

Chad Eliason celiason@fieldmuseum.org

References

Bertelli, S. and Chiappe, L. M. (2005). Earliest Tinamous (Aves: Palaeognathae) from the Miocene of Argentina and Their Phylogenetic Position. Contributions in Science, 502, 1-20.

Examples

## Not run: 
# Read in a nexus file:
x <- read.nex(file = system.file("extdata", "clarke_2006.nex",
package = "phenotools"))
# Build a `nex` object from text files:
charpath <- system.file("extdata", "brusatte2014_charlist.txt",
package = "phenotools")
matpath <- system.file("extdata", "brusatte2014_matrix.txt",
package = "phenotools")
x <- read.nex(matpath, charlabels=charpath)
# Build a `nex` object from a PDF file (Bertelli & Chiappe 2005):
x <- read.nex(file = system.file("extdata", "Bertelli_2005.pdf",
package = "phenotools"), ntax = 34, nchar = 63, first = 20, last = 22)
x
# Plot
plot(x, legend.pos = "top")

## End(Not run)


celiason/phenotools documentation built on Sept. 16, 2024, 8:31 a.m.