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

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/BioGeoBEARS_readwrite_v1.R

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

1

Arguments

tr

A phylo tree object

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

Value

downpass_node_matrix A matrix of node numbers

Note

Go BEARS!

Author(s)

Nicholas J. Matzke matzke@berkeley.edu

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)

Example output

Loading required package: rexpokit
Loading required package: cladoRcpp
Loading required package: ape
Loading required package: phylobase

Attaching package: 'phylobase'

The following object is masked from 'package:ape':

    edges

      [,1] [,2]
 [1,]   27    1
 [2,]   28    2
 [3,]   26    3
 [4,]   29    4
 [5,]   25    5
 [6,]   24    6
 [7,]   30    7
 [8,]   23    8
 [9,]   34    9
[10,]   33   10
[11,]   32   11
[12,]   31   12
[13,]   22   13
[14,]   35   14
[15,]   21   15
[16,]   37   16
[17,]   36   17
[18,]   20   18

BioGeoBEARS documentation built on May 29, 2017, 8:36 p.m.