Learn R Programming

BioGeoBEARS (version 0.2.1)

get_lagrange_nodenums: Get internal node numbers in LAGRANGE's downpass order

Description

There are many ways of numbering nodes in a tree. This returns a matrix containing (column 1) R's native internal numbering scheme, and (column 2) the node numbers in the downpass numbering used by C++ LAGRANGE, in particular in their .bgkey output file. Note that this is different from ape's pruningwise downpass ordering (see get_pruningwise_nodenums).

Usage

get_lagrange_nodenums(tr)

Arguments

tr
A phylo tree object

Value

downpass_node_matrix A matrix of node numbers

Details

The python version of LAGRANGE labels internal nodes differently (sigh), but they are in the same order at least, so can just be renumbered from 1 to tr$Nnode to get them to match the C++ LAGRANGE node numbering.

DIVA has yet a different node numbering scheme; see postorder_nodes_phylo4_return_table

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster

Matzke_2012_IBS

See Also

get_pruningwise_nodenums, prt, postorder_nodes_phylo4_return_table

Examples

Run this code
extdata_dir = np(system.file("extdata", package="BioGeoBEARS"))
tmppath = paste(extdata_dir,
"/examples/Psychotria_M0/LGcpp/Psychotria_5.2.newick", sep="")
trfn = np(slashslash(tmppath))
tr = read.tree(trfn)
downpass_node_matrix = get_lagrange_nodenums(tr)
downpass_node_matrix


downpass_node_matrix = get_lagrange_nodenums(tr)
downpass_node_matrix = downpass_node_matrix[order(downpass_node_matrix[,2]), ]
plot(tr)
nodelabels(node=20:37, downpass_node_matrix[,1])
tiplabels(1:19)

plot(tr)
nodelabels(node=20:37, downpass_node_matrix[,2])
tiplabels(1:19)

downpass_node_matrix = get_lagrange_nodenums(tr)
downpass_node_matrix = downpass_node_matrix[order(downpass_node_matrix[,1]), ]
plot(tr)
nodelabels(node=20:37, downpass_node_matrix[,1])
tiplabels(1:19)

# THIS WORKS
plot(tr)
nodelabels(node=20:37, downpass_node_matrix[,2])
tiplabels(1:19)

Run the code above in your browser using DataLab