phylo4-labels {phylobase}R Documentation

Labels for phylo4/phylo4d objects

Description

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

Usage

labels(object, ...)

## S4 method for signature 'phylo4'
labels(object, type = c("all", "tip", "internal"))

labels(x, type, use.names, ...) <- value

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

hasDuplicatedLabels(x, type)

## S4 method for signature 'phylo4'
hasDuplicatedLabels(x, type = c("all", "tip", "internal"))

hasNodeLabels(x)

## S4 method for signature 'phylo4'
hasNodeLabels(x)

nodeLabels(x)

## S4 method for signature 'phylo4'
nodeLabels(x)

nodeLabels(x, ...) <- value

## S4 replacement method for signature 'phylo4'
nodeLabels(x, ...) <- value

tipLabels(x)

## S4 method for signature 'phylo4'
tipLabels(x)

tipLabels(x, ...) <- value

## S4 replacement method for signature 'phylo4'
tipLabels(x, ...) <- value

hasEdgeLabels(x)

## S4 method for signature 'phylo4'
hasEdgeLabels(x)

edgeLabels(x)

## S4 method for signature 'phylo4'
edgeLabels(x)

edgeLabels(x, ...) <- value

## S4 replacement method for signature 'phylo4'
edgeLabels(x, ...) <- value

Arguments

object

a phylo4 or phylo4d object.

...

additional optional arguments (not in use)

type

which type of labels: all (tips and internal nodes), tip (tips only), internal (internal nodes only).

x

a phylo4 or phylo4d object.

use.names

should the names of the vector used to create/update labels be used to match the labels? See Details for more information.

value

a vector of class character, 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.

Value

labels in ascending order.

Methods

labels

signature(object = "phylo4"): tip and/or internal node labels, ordered by node ID

hasDuplicatedLabels

signature(object = "phylo4"): are any labels duplicated?

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

Author(s)

Ben Bolker, Peter Cowan, Steve Kembel, Francois Michonneau

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.8.12 Index]