Git Product home page Git Product logo

spacodir's Issues

`resamp.phy` function doesn't accept tree with named nodes

Hello,

First thank you for your great package spacodiR.

I found a really small issue in your resamp.phy function:
I'm currently working with a tree I want to randomized that have named nodes. And if I want to launch the function resamp.phy on it I get the following error:

Error in if (node <= n) return(NULL) :
missing value where TRUE/FALSE needed

So a really simple fix is only to delete the node names with : tree$node.label <- NULL. But you'll agree for saying it's not really elegant ? So I wanted to correct myself the issue and suggest you a fix. I found the problem came from this line in resamp.phy function: tt = as.numeric(names(tt)[which(tt)]). It works well when you don't have node names because automatically this line tt = sapply(b, function(x) withinrange(x, 0, time.threshold)) will give numbers as node names. But if you do have node names the as.numeric function on a character vector will produce NA bringing the function to bug. As a conclusion I wasn't able to suggest you a fix because I don't really now if you can manage node labels with get.descendants.of.node function our if you can only accept numerical names for tree nodes.

Please find bellow an example of code triggering the bug:
library(spacodiR)
data(sp.example)
attach(sp.example)
phy$node.label <- c(letters)[1:length(branching.times(phy))] # Giving letter name to nodes
resamp.phy(phy)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.