liamrevell / phytools

GNU General Public License v3.0
198 stars 56 forks source link

`paintBranches` error when sapply within function returns ii as list #130

Open rubysaltbush opened 1 year ago

rubysaltbush commented 1 year ago

Hello!

I am trying to use paintBranches on a large (1201 tip) phylogeny and it gave the error:

Error in tree$edge.length[[ii[i]]] : invalid subscript type 'list'

For some reason in Line 8 of the paintBranches function sapply is returning a list with my data, although running the example code from your blog it returns a vector.

I've fixed this by defining the function in my code and adding ii <- unlist(ii) at Line 9 of the paintBranches function, not sure if you could add this fix to the function to prevent it happening for others in future?

liamrevell commented 12 months ago

Hi @rubysaltbush. To figure this out I'd really need to see a reproducible example, as I'm not running into the same problem using example cases -- even with trees of similar size. Thanks! -- Liam