psoares
psoares

Reputation: 4883

Matrix in R - phytools subscript out of bounds

I wanted to build a matrix representation parsimony with R. I found this phylogenetic package and I've decided to give it a try, although I'm a newbie in R.

subset of the trees can be found here

When I use the example I'm able to generate a test tree perfectly. However when I use my file, I'm getting this error:

Error in XX[rownames(X[[i]]), c(j:((j - 1) + ncol(X[[i]])))] <- X[[i]]
    [1:nrow(X[[i]]),  :   subscript out of bounds

Another thing that I'm imaging is not working like it should is species. Because if I print species I will get an empty "" and two NA.

(...)
if(i==1) species<-phy[[i]]$tip.label

EDIT
I've tried with others newick files and have the same and different errors. Although the function says:

This function reads a file which contains one or several trees in
 parenthetic format known as the Newick or New Hampshire format.

It doesn't seem to be able to read these files. Any idea?

Is anybody willing to help to understand what should I do to avoid this error?

Thank you!

Upvotes: 1

Views: 2238

Answers (1)

psoares
psoares

Reputation: 4883

How did I solve the problem?

I've tried with different newick files and all of them gave me an error.

Since it worked with the example provided by the author, after one suggestion I've decided to write those test trees into a file, realized that the trees didn't have any distances, after removing the distances from the file, the code provided by Liam worked!

Upvotes: 1

Related Questions