emmanuelparadis / ape

analysis of phylogenetics and evolution
http://ape-package.ird.fr/
GNU General Public License v2.0
52 stars 11 forks source link

Fixed bug and added node label handling for discrete #127

Open TGuillerme opened 3 weeks ago

TGuillerme commented 3 weeks ago

My previous PR seemed to have included a bug when using trees with node labels and doing ace for discrete data (guessing from here).

Here's a quick fix and the test for discrete characters for next release.

test_that("adding node labels to ace output works for discrete characters", {
    ## Example with no node labels
    data(bird.orders)
    x <- as.factor(c(rep(0, 5), rep(1, 18)))
    ### Compare the three methods for continuous characters:
    out <- ace(x, bird.orders, type = "d")
    expect_equal(rownames(out$lik.anc), as.character(seq(from = 1+Ntip(bird.orders), to = Nnode(bird.orders)+Ntip(bird.orders))))

    ## Adding node labels
    phy_nodes <- makeNodeLabel(bird.orders)
    out <- ace(x, phy_nodes, type = "d")
    expect_equal(rownames(out$lik.anc), phy_nodes$node.label)
})