From 31d71ce3ff426358a77412db5b006465a5bddef2 Mon Sep 17 00:00:00 2001 From: Dominic Bennett Date: Thu, 21 Jan 2016 18:57:54 +0000 Subject: [PATCH] Name update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit — switched to more intuitive prid, ptid, and prdst — this should make differentiating between a node and its ID easier --- R/calc-methods.R | 4 +-- R/display-methods.R | 10 ++++---- R/gen-methods.R | 8 +++--- R/get-methods.R | 38 ++++++++++++++--------------- R/manip-methods.R | 22 ++++++++--------- R/node-declaration.R | 22 ++++++++--------- R/read-write-methods.R | 32 ++++++++++++------------ R/treeman-declaration.R | 16 ++++++------ tests/testthat/test-calc-methods.R | 4 +-- tests/testthat/test-get-methods.R | 8 +++--- tests/testthat/test-manip-methods.R | 4 +-- 11 files changed, 84 insertions(+), 84 deletions(-) diff --git a/R/calc-methods.R b/R/calc-methods.R index 704f524..dd162f3 100644 --- a/R/calc-methods.R +++ b/R/calc-methods.R @@ -1,7 +1,7 @@ # TODO: calc imbalance, calc tree dists calcPhyDv <- function(tree, ids) { - prids <- unlist(getNodesPre(tree, ids)) + prids <- unlist(getNodesPrid(tree, ids)) counts <- table(prids) prids <- names(counts)[counts < length(ids)] spans <- unlist(lapply(tree@nodelist[c(ids, prids)], @@ -21,7 +21,7 @@ calcFrPrp <- function(tree, ids) { span/n } .calc <- function(tip) { - ids <- c(tip, getNodePre(tree, tip)) + ids <- c(tip, getNodePrid(tree, tip)) shares <- unlist(sapply(ids, .share)) sum(shares) } diff --git a/R/display-methods.R b/R/display-methods.R index ffd4ce6..682a8c4 100644 --- a/R/display-methods.R +++ b/R/display-methods.R @@ -56,7 +56,7 @@ setGeneric ("viz", signature=c("tree", "taxonyms"), setMethod ('viz', 'TreeMan', function(tree, taxonyms){ get_pnts <- function (node, y, pnts) { - pstids <- node[['post']] + pstids <- node[['ptid']] low_y_diff <- -node[['pd']]/2 high_y_diff <- node[['pd']]/2 y_diffs <- seq(from=low_y_diff, to=high_y_diff, @@ -64,7 +64,7 @@ setMethod ('viz', 'TreeMan', counter <- 1 for (pstid in pstids) { pstnd <- tree@nodelist[[pstid]] - pstnd_x <- pstnd[['predist']] + pstnd_x <- pstnd[['prdst']] pstnd_y <- y + y_diffs[counter] pnts <- rbind (pnts, data.frame (node=pstid, x=pstnd_x, y=pstnd_y)) @@ -78,8 +78,8 @@ setMethod ('viz', 'TreeMan', for(i in 1:length(tree@nodelist)) { tree@nodelist[[i]][['span']] <- 1 tree@nodelist[[i]][['pd']] <- length(tree@nodelist[[i]][['children']]) - prids <- getNodePre(tree, tree@nodelist[[i]][['id']]) - tree@nodelist[[i]][['predist']] <- length(prids) + prids <- getNodePrid(tree, tree@nodelist[[i]][['id']]) + tree@nodelist[[i]][['prdst']] <- length(prids) } tree@pd <- length(tree@nodelist) - 1 } @@ -104,7 +104,7 @@ setMethod ('viz', 'TreeMan', } # draw lines for (i in 2:nrow (pnts)) { - prenode <- tree@nodelist[[pnts$node[i]]][['pre']] + prenode <- tree@nodelist[[pnts$node[i]]][['prid']] ind <- c (i, which (pnts$node == prenode)) lines (x=pnts$x[ind], y=pnts$y[ind]) } diff --git a/R/gen-methods.R b/R/gen-methods.R index 3af9d77..48de760 100644 --- a/R/gen-methods.R +++ b/R/gen-methods.R @@ -18,11 +18,11 @@ randTree <- function (n) { pd <- 0 node <- list ('id'=id, 'span'=span, - 'pre'=pre, - 'post'=post, + 'prid'=pre, + 'ptid'=post, 'children'=children, 'pd'=pd, - 'predist'=predist) + 'prdst'=predist) nodelist[[id]] <- node # if there are enough ns left to have children n_left <- n_left - 1 @@ -56,7 +56,7 @@ randTree <- function (n) { } } nodelist[[id]][['children']] <- children - nodelist[[id]][['post']] <- post + nodelist[[id]][['ptid']] <- post nodelist[[id]][['pd']] <- pd nodelist } diff --git a/R/get-methods.R b/R/get-methods.R index 728e078..f5f6186 100644 --- a/R/get-methods.R +++ b/R/get-methods.R @@ -27,7 +27,7 @@ getNodesChildren <- function(tree, ids) { #TODO: how to effectively handle unrooted trees, age has no meaning getNodeAge <- function(tree, id) { node <- tree@nodelist[[id]] - tree@age - node[['predist']] + tree@age - node[['prdst']] } getNodesAge <- function(tree, ids) { @@ -36,14 +36,14 @@ getNodesAge <- function(tree, ids) { } getEdgeAge <- function(tree, id) { - max <- getNodeAge(tree, tree@nodelist[[id]][['pre']]) + max <- getNodeAge(tree, tree@nodelist[[id]][['prid']]) min <- getNodeAge(tree, id) data.frame(edge=id, max, min) } getEdgesAge <- function(tree, ids) { maxs <- sapply(ids, function(tree, id) { - getNodeAge(tree, tree@nodelist[[id]][['pre']]) + getNodeAge(tree, tree@nodelist[[id]][['prid']]) }, tree=tree) mins <- sapply(ids, getNodeAge, tree=tree) data.frame(edge=ids, max=maxs, min=mins, row.names=NULL) @@ -51,7 +51,7 @@ getEdgesAge <- function(tree, ids) { # @name getParent getParent <- function(tree, ids) { - prids <- getNodesPre(tree, ids) + prids <- getNodesPrid(tree, ids) rf <- prids[[1]] mn_rnk <- 0 for(n in prids[-1]) { @@ -63,8 +63,8 @@ getParent <- function(tree, ids) { # @name getPath getPath <- function(tree, from, to) { - pre_1 <- getNodePre(tree, from) - pre_2 <- getNodePre(tree, to) + pre_1 <- getNodePrid(tree, from) + pre_2 <- getNodePrid(tree, to) parent <- pre_1[which(pre_1 %in% pre_2)[1]] path_1 <- c(from ,pre_1[!pre_1 %in% pre_2]) path_2 <- c(pre_2[!pre_2 %in% pre_1], to) @@ -72,9 +72,9 @@ getPath <- function(tree, from, to) { } # @name get_Pre -getNodePre <- function(tree, id) { +getNodePrid <- function(tree, id) { .get <- function(nd, prids) { - prid <- tree@nodelist[[nd]][['pre']] + prid <- tree@nodelist[[nd]][['prid']] if(!is.null(prid)) { prids <- c(prid, .get(prid, prids)) } @@ -83,13 +83,13 @@ getNodePre <- function(tree, id) { .get(id, NULL) } -getNodesPre <- function(tree, ids) { - sapply(ids, getNodePre, tree=tree, simplify=FALSE) +getNodesPrid <- function(tree, ids) { + sapply(ids, getNodePrid, tree=tree, simplify=FALSE) } # @name get_Lineage getNodeLineage <- function(tree, id) { - prids <- getNodePre(tree, id) + prids <- getNodePrid(tree, id) lineage <- sapply(prids, function(n) tree@nodelist[[n]][['taxonym']]) if(length(lineage) > 0) { lineage <- c(tree@nodelist[[id]][['taxonym']], lineage) @@ -106,11 +106,11 @@ getNodesLineage <- function(tree, ids) { } # @name get_Post -getNodePost <- function(tree, id) { +getNodePtid <- function(tree, id) { .get <- function(nds, pstids) { new_nds <- c() for(nd in nds) { - new_nds <- c(new_nds, tree@nodelist[[nd]][['post']]) + new_nds <- c(new_nds, tree@nodelist[[nd]][['ptid']]) } pstids <- c(pstids, new_nds) if(length(new_nds) > 0) { @@ -121,20 +121,20 @@ getNodePost <- function(tree, id) { .get(nds=id, pstids=NULL) } -getNodesPost <- function(tree, ids) { - sapply(ids, getNodePost, tree=tree) +getNodesPtid <- function(tree, ids) { + sapply(ids, getNodePtid, tree=tree) } # @name getSubtree getSubtree <- function(tree, id) { - pstids <- getNodePost(tree, id) + pstids <- getNodePtid(tree, id) ndlst <- tree@nodelist[c(id, pstids)] - nd_prdst <- ndlst[[id]][['predist']] + nd_prdst <- ndlst[[id]][['prdst']] ndlst <- lapply(ndlst, function(x) { - x[['predist']] <- x[['predist']] - nd_prdst + x[['prdst']] <- x[['prdst']] - nd_prdst x }) - ndlst[[id]][['pre']] <- NULL + ndlst[[id]][['prid']] <- NULL ndlst[[id]][['span']] <- 0 new_tree <- new('TreeMan', nodelist=ndlst, root=id) .update(new_tree) diff --git a/R/manip-methods.R b/R/manip-methods.R index 45d5ee7..a2e8f17 100644 --- a/R/manip-methods.R +++ b/R/manip-methods.R @@ -19,24 +19,24 @@ addTip <- function(tree, id, sister, start, end, tip[['span']] <- start - end age <- getNodeAge(tree, sister) new_sister <- sister <- tree@nodelist[[sister]] - new_parent <- tree@nodelist[[sister[['pre']]]] - new_parent[['post']] <- new_parent[['post']][!new_parent[['post']] %in% sister[['id']]] - new_parent[['post']] <- c(new_parent[['post']], node[['id']]) + new_parent <- tree@nodelist[[sister[['prid']]]] + new_parent[['ptid']] <- new_parent[['ptid']][!new_parent[['ptid']] %in% sister[['id']]] + new_parent[['ptid']] <- c(new_parent[['ptid']], node[['id']]) new_sister[['span']] <- start - age - new_sister[['pre']] <- node[['id']] + new_sister[['prid']] <- node[['id']] node[['span']] <- sister[['span']] - new_sister[['span']] node[['pd']] <- new_sister[['span']] + tip[['span']] - node[['predist']] <- sister[['predist']] - new_sister[['span']] - node[['pre']] <- sister[['pre']] - node[['post']] <- node[['children']] <- c(tip[['id']], sister[['id']]) + node[['prdst']] <- sister[['prdst']] - new_sister[['span']] + node[['prid']] <- sister[['prid']] + node[['ptid']] <- node[['children']] <- c(tip[['id']], sister[['id']]) tip[['pd']] <- 0 - tip[['predist']] <- node[['predist']] + tip[['span']] - tip[['pre']] <- node[['id']] + tip[['prdst']] <- node[['prdst']] + tip[['span']] + tip[['prid']] <- node[['id']] tree@nodelist[[tip[['id']]]] <- tip tree@nodelist[[node[['id']]]] <- node tree@nodelist[[new_sister[['id']]]] <- new_sister tree@nodelist[[new_parent[['id']]]] <- new_parent - pres <- getNodePre(tree, node[['id']]) + pres <- getNodePrid(tree, node[['id']]) tree@nodelist[pres] <- lapply(tree@nodelist[pres], updatePre) .update(tree) @@ -49,7 +49,7 @@ pinTip <- function(tree, tip_id, lineage, end) { if(length(edges) == 0) { next } - edges <- c(edges, unlist(sapply(edges, function(n) tree@nodelist[[n]][['post']]))) + edges <- c(edges, unlist(sapply(edges, function(n) tree@nodelist[[n]][['ptid']]))) edges <- edges[edges != tree@root] rngs <- getEdgesAge(tree, ids=edges) bool <- rngs[ ,'max'] > end diff --git a/R/node-declaration.R b/R/node-declaration.R index b27b117..ca1ee90 100644 --- a/R/node-declaration.R +++ b/R/node-declaration.R @@ -6,26 +6,26 @@ span <- node[['span']] } if(length(tree@age) > 0) { - age <- tree@age - node[['predist']] + age <- tree@age - node[['prdst']] } else { age <- numeric() } - new('Node', id=node[['id']], span=span, pre=as.character(node[['pre']]), - post=as.character(node[['post']]), children=as.character(node[['children']]), + new('Node', id=node[['id']], span=span, prid=as.character(node[['prid']]), + ptid=as.character(node[['ptid']]), children=as.character(node[['children']]), nchildren=length(as.character(node[['children']])), pd=node[['pd']], - predist=node[['predist']], root=tree@root == node[['id']], - age=age, tip=length(node[['post']]) == 0) + prdst=node[['prdst']], root=tree@root == node[['id']], + age=age, tip=length(node[['ptid']]) == 0) } setClass ('Node', representation=representation ( id='character', # unique ID for node in tree@nodelist span='numeric', # length of preceding branch - pre='character', # parent node ID - post='vector', # child node IDs + prid='character', # parent node ID + ptid='vector', # child node IDs children='vector', # descending tip IDs nchildren='numeric', # number of descending tips pd='numeric', # total branch length represented by node - predist='numeric', # total branch length of connected pres + prdst='numeric', # total branch length of connected pres age='numeric', # age of node in tree root='logical', # T/F root node? tip='logical') # T/F tip node? @@ -51,10 +51,10 @@ setMethod ('print', c('x'='Node'), } msg <- paste0(msg, ' + ID: \"', x@id, '\"\n') if(!x@root) { - msg <- paste0(msg, ' + pre: \"', x@pre, '\"\n') + msg <- paste0(msg, ' + preid: \"', x@prid, '\"\n') } if(!x@tip) { - msg <- paste0(msg, ' + post: \"', paste0(x@post, collapse='\", \"'), '\"\n') + msg <- paste0(msg, ' + postid: \"', paste0(x@ptid, collapse='\", \"'), '\"\n') msg <- paste0(msg, ' + nchildren: ', length(x@children), '\n') } if(length(x@span) > 0) { @@ -64,7 +64,7 @@ setMethod ('print', c('x'='Node'), if(length(x@age) > 0) { msg <- paste0(msg, ' + age: ', signif(x@age, 2), '\n') } else { - msg <- paste0(msg, ' + predist: ', signif(x@predist, 2), '\n') + msg <- paste0(msg, ' + predist: ', signif(x@prdst, 2), '\n') } msg <- paste0(msg, ' + pd: ', signif(x@pd, 2), '\n') } diff --git a/R/read-write-methods.R b/R/read-write-methods.R index bb10854..b4e3971 100644 --- a/R/read-write-methods.R +++ b/R/read-write-methods.R @@ -28,12 +28,12 @@ readTree <- function(file=NULL, tree_string=NULL) { NULL } add <- function(prndid, rdrenv, ndid=prndid) { - if(!is.null(rdrenv$nodelist[[prndid]][['post']])) { + if(!is.null(rdrenv$nodelist[[prndid]][['ptid']])) { rdrenv$nodelist[[prndid]][['pd']] <- rdrenv$nodelist[[prndid]][['pd']] + rdrenv$nodelist[[ndid]][['span']] } - if(!is.null(rdrenv$nodelist[[prndid]][['pre']])) { - add(rdrenv$nodelist[[prndid]][['pre']], rdrenv, ndid) + if(!is.null(rdrenv$nodelist[[prndid]][['prid']])) { + add(rdrenv$nodelist[[prndid]][['prid']], rdrenv, ndid) } NULL } @@ -45,24 +45,24 @@ readTree <- function(file=NULL, tree_string=NULL) { # add children .addChildren <- function(rdrenv) { add <- function(ndid, rdrenv, tpid=ndid) { - if(!is.null(rdrenv$nodelist[[ndid]][['post']])) { + if(!is.null(rdrenv$nodelist[[ndid]][['ptid']])) { rdrenv$nodelist[[ndid]][['children']] <- c(tpid, rdrenv$nodelist[[ndid]][['children']]) } - if(!is.null(rdrenv$nodelist[[ndid]][['pre']])) { - add(rdrenv$nodelist[[ndid]][['pre']], rdrenv, tpid) + if(!is.null(rdrenv$nodelist[[ndid]][['prid']])) { + add(rdrenv$nodelist[[ndid]][['prid']], rdrenv, tpid) } NULL } - tips <- sapply(rdrenv$nodelist, function(n) length(n[['post']]) == 0) + tips <- sapply(rdrenv$nodelist, function(n) length(n[['ptid']]) == 0) tips <- names(tips)[tips] sapply(tips, add, rdrenv=rdrenv) NULL } .addRoot <- function(rdrenv) { - root_i <- which(unlist(lapply(rdrenv$nodelist, function(n) n[['pre']] == "root"))) + root_i <- which(unlist(lapply(rdrenv$nodelist, function(n) n[['prid']] == "root"))) if(length(root_i) > 0) { - rdrenv$nodelist[[root_i]][['pre']] <- NULL + rdrenv$nodelist[[root_i]][['prid']] <- NULL rdrenv$nodelist[[root_i]][['span']] <- 0 rdrenv$root <- names(rdrenv$nodelist)[root_i] } else { @@ -75,14 +75,14 @@ readTree <- function(file=NULL, tree_string=NULL) { .addPredist <- function(rdrenv) { calc <- function(nd, d) { nd <- rdrenv$nodelist[[nd]] - if(!is.null(nd[['pre']])) { + if(!is.null(nd[['prid']])) { d <- nd[['span']] + d - d <- calc(nd[['pre']], d) + d <- calc(nd[['prid']], d) } d } assgn <- function(i) { - rdrenv$nodelist[[i]][['predist']] <- ds[[i]] + rdrenv$nodelist[[i]][['prdst']] <- ds[[i]] NULL } ds <- sapply(names(rdrenv$nodelist), calc, d=0) @@ -135,19 +135,19 @@ readTree <- function(file=NULL, tree_string=NULL) { # TODO: utilise nd$id, e.g. node labels are taxonym or support nd$id <- rdrenv$prnds[[rdrenv$i]][['id']] rdrenv$prnds[[rdrenv$i]][['span']] <- nd[['span']] - rdrenv$prnds[[rdrenv$i]][['pre']] <- + rdrenv$prnds[[rdrenv$i]][['prid']] <- rdrenv$prnds[[rdrenv$i-1]][['id']] rdrenv$nodelist[[nd[['id']]]] <- rdrenv$prnds[[rdrenv$i]] rdrenv$prnds <- rdrenv$prnds[-rdrenv$i] rdrenv$i <- rdrenv$i - 1 rdrenv$nxt_is_intrnl <- FALSE } else { - nd[['pre']] <- rdrenv$prnds[[rdrenv$i]][['id']] + nd[['prid']] <- rdrenv$prnds[[rdrenv$i]][['id']] rdrenv$nodelist[[nd[['id']]]] <- nd } if(length(rdrenv$prnds) > 0) { - rdrenv$prnds[[rdrenv$i]][['post']] <- - c(rdrenv$prnds[[rdrenv$i]][['post']], nd[['id']]) + rdrenv$prnds[[rdrenv$i]][['ptid']] <- + c(rdrenv$prnds[[rdrenv$i]][['ptid']], nd[['id']]) } if(grepl("\\)$", ndstr)) { rdrenv$nxt_is_intrnl <- TRUE diff --git a/R/treeman-declaration.R b/R/treeman-declaration.R index d72b194..2130cba 100644 --- a/R/treeman-declaration.R +++ b/R/treeman-declaration.R @@ -77,8 +77,8 @@ #TODO: modify this to allow user-defined Node slot #TODO: check for missing children or no pd essential_node_slots <- c('id') -valid_node_slots <- c('id', 'taxonym', 'span', 'pre', - 'post', 'children', 'predist', 'pd') +valid_node_slots <- c('id', 'taxonym', 'span', 'prid', + 'ptid', 'children', 'prdst', 'pd') .checkTreeMan <- function(object) { .check <- function(node) { @@ -94,8 +94,8 @@ valid_node_slots <- c('id', 'taxonym', 'span', 'pre', invlds)) } test_1 <- node[['id']] %in% nodes - test_2 <- is.null(node[['pre']]) || (node[['pre']] %in% nodes) - test_3 <- is.null(node[['pre']]) || all(node[['post']] %in% nodes) + test_2 <- is.null(node[['prid']]) || (node[['prid']] %in% nodes) + test_3 <- is.null(node[['prid']]) || all(node[['ptid']] %in% nodes) if(test_1 & test_2 & test_3) { return(TRUE) } @@ -143,7 +143,7 @@ setGeneric('.update', signature=c('x'), setMethod('.update', 'TreeMan', function(x) { wo_pstndes <- sapply(x@nodelist, - function(n) length(n[['post']]) == 0) + function(n) length(n[['ptid']]) == 0) x@tips <- names(wo_pstndes)[wo_pstndes] x@ntips <- length(x@tips) x@nodes <- names(wo_pstndes)[!wo_pstndes] @@ -152,9 +152,9 @@ setMethod('.update', 'TreeMan', x@wspn <- all(sapply(x@nodelist[wspn], function(n) !is.null(n[['span']]))) if(x@wspn) { if(!is.null(x@root)) { - x@age <- max(sapply(x@nodelist[wspn], function(x) x[['predist']])) + x@age <- max(sapply(x@nodelist[wspn], function(x) x[['prdst']])) extant_is <- unlist(sapply(x@tips, function(i) { - (x@age - x@nodelist[[i]][['predist']]) <= x@tol})) + (x@age - x@nodelist[[i]][['prdst']]) <= x@tol})) x@ext <- names(extant_is)[extant_is] x@exc <- x@tips[!x@tips %in% x@ext] x@ultr <- all(x@tips %in% x@ext) @@ -165,7 +165,7 @@ setMethod('.update', 'TreeMan', x@ext <- x@ext <- vector() x@ultr <- logical() } - x@ply <- any(sapply(x@nodelist, function(n) length(n[['post']]) > 2)) + x@ply <- any(sapply(x@nodelist, function(n) length(n[['ptid']]) > 2)) initialize(x) }) diff --git a/tests/testthat/test-calc-methods.R b/tests/testthat/test-calc-methods.R index edbc3b0..36671bb 100644 --- a/tests/testthat/test-calc-methods.R +++ b/tests/testthat/test-calc-methods.R @@ -6,14 +6,14 @@ library(testthat) context('Testing \'calc-methods\'') test_that('calcPhyDv() works', { tree <- randTree(10) - tips <- sample(tree@tips, 3) + tips <- sample(tree['tips'], 3) pd <- calcPhyDv(tree, tips) parent <- getParent(tree, ids=tips) test_that(pd, is_less_than(tree@nodelist[[parent]][['pd']])) # add a tip with a specified length. sister <- sample(tips, 1) sister_age <- getNodeAge(tree, sister) - parent_age <- getNodeAge(tree, tree@nodelist[[sister]][['pre']]) + parent_age <- getNodeAge(tree, tree@nodelist[[sister]][['prid']]) start <- runif(min=sister_age, max=parent_age, n=1) end <- runif(min=0, max=start, n=1) tree <- addTip(tree, id='new_tip', sister=sister, start=start, end=end) diff --git a/tests/testthat/test-get-methods.R b/tests/testthat/test-get-methods.R index b554e02..77dbb3b 100644 --- a/tests/testthat/test-get-methods.R +++ b/tests/testthat/test-get-methods.R @@ -32,16 +32,16 @@ test_that("getPath() works", { prnt <- getParent(tree, ids=c('t1', "t10")) expect_true(prnt %in% pth) }) -test_that("get_Pre() works", { +test_that("get_Prid() works", { tree <- randTree(10) - prids <- getNodesPre(tree, tree['nodes']) + prids <- getNodesPrid(tree, tree['nodes']) expect_that(prids[[1]], is_null()) lst_nds <- unlist(lapply(prids[-1], function(n) n[length(n)])) expect_true(all(lst_nds == "n1")) }) -test_that("get_Post() works", { +test_that("get_Ptid() works", { tree <- randTree(10) - pstids <- getNodesPost(tree, tree['nodes']) + pstids <- getNodesPtid(tree, tree['nodes']) expect_true(all(pstids[['n1']] %in% c(tree['nodes'], tree['tips']))) expect_that(pstids[['t1']], is_null()) }) diff --git a/tests/testthat/test-manip-methods.R b/tests/testthat/test-manip-methods.R index ff813f6..41798f0 100644 --- a/tests/testthat/test-manip-methods.R +++ b/tests/testthat/test-manip-methods.R @@ -7,7 +7,7 @@ randomLineage <- function(n, tree) { # add random monophyletic taxonyms to tree addLname <- function(node, tree) { tree@nodelist[[node]][['taxonym']] <- lname - pnodes <- tree@nodelist[[node]][['post']] + pnodes <- tree@nodelist[[node]][['ptid']] if(!is.null(pnodes)) { for(pnode in pnodes) { tree <- addLname(pnode, tree) @@ -53,7 +53,7 @@ test_that('addTip() works', { # add random tip sister <- sample(tree@tips, 1) sister_age <- getNodeAge(tree, sister) - parent_age <- getNodeAge(tree, tree@nodelist[[sister]][['pre']]) + parent_age <- getNodeAge(tree, tree@nodelist[[sister]][['prid']]) start <- runif(min=sister_age, max=parent_age, n=1) end <- runif(min=0, max=start, n=1) tree <- addTip(tree, id='new_tip', sister=sister, start=start, end=end)