phylo4-labels {phylobase}R Documentation

Labels for phylo4/phylo4d objects

Description

Methods for creating, accessing and updating labels in phylo4/phylo4d objects

Usage


## S4 method for signature 'phylo4':
labels(object, type=c("all", "tip", "internal"))
## S4 method for signature 'phylo4, ANY, ANY, character':
labels(x, type=c("all", "tip",
  "internal"), use.names=FALSE) <- value

## S4 method for signature 'phylo4':
tipLabels(x)
## S4 method for signature 'phylo4, character':
tipLabels(x) <- value

## S4 method for signature 'phylo4':
hasNodeLabels(x)
## S4 method for signature 'phylo4':
nodeLabels(x)
## S4 method for signature 'phylo4, character':
nodeLabels(x) <- value

## S4 method for signature 'phylo4':
hasEdgeLabels(x)
## S4 method for signature 'phylo4':
edgeLabels(x)
## S4 method for signature 'phylo4, character':
edgeLabels(x) <- value

Arguments

x a phylo4 or phylo4d object.
object a phylo4 or phylo4d object.
type which type of labels: all (tips and internal nodes), tip (tips only), internal (internal nodes only).
value a vector of class character, see Details for more information.
use.names should the names of the vector used to create/update labels be used to match the labels? See Details for more information.

Details

In phylo4/phylo4d objects, tips must have labels (that's why there is no method for hasTipLabels), internal nodes and edges can have labels.

Labels must be provided as a vector of class character. The length of the vector must match the number of elements they label.

The option use.names allows the user to match a label to a particular node. In this case, the vector must have names that match the node numbers.

The function labels is mostly intended to be used internally.

Methods

labels
signature(object = "phylo4"): tip and/or internal node labels, ordered by node ID
tipLabels
signature(object = "phylo4"): tip labels, ordered by node ID
hasNodeLabels
signature(object = "phylo4"): whether tree has (internal) node labels
nodeLabels
signature(object = "phylo4"): internal node labels, ordered by node ID
hasEdgeLabels
signature(object = "phylo4"): whether tree has (internal) edge labels
edgeLabels
signature(object = "phylo4"): internal edge labels, ordered according to the edge matrix

Examples


data(geospiza)

## Return labels from geospiza
tipLabels(geospiza)

## Internal node labels in geospiza are empty
nodeLabels(geospiza)

## Creating internal node labels
ndLbl <- paste("n", 1:nNodes(geospiza), sep="")
nodeLabels(geospiza) <- ndLbl
nodeLabels(geospiza)

## naming the labels
names(ndLbl) <- nodeId(geospiza, "internal")

## shuffling the labels
(ndLbl <- sample(ndLbl))

## by default, the labels are attributed in the order
## they are given:
nodeLabels(geospiza) <- ndLbl
nodeLabels(geospiza)

## but use.names puts them in the correct order
labels(geospiza, "internal", use.names=TRUE) <- ndLbl
nodeLabels(geospiza)


[Package phylobase version 0.5 Index]