KB2
KB2

Reputation: 121

Reading a newick format phylogeny in r using caper

I desire to perform comparative analysis using independent contrasts which I believe can be done in ape. I have a phylogeny of the cat family in newick format, and when I try to read in the file I get the error below:

phy<-read.tree("phylogeny.txt") Error in if (sum(obj[[i]]$edge[, 1] == ROOT) == 1 && dim(obj[[i]]$edge)[1] > : missing value where TRUE/FALSE needed

Could anyone very kindly perhaps explain to me what this error means?

Kind regards, K.

Edit, the newick string is posted below:

((((Tiger_108,Snow leopard_024),(Jaguar_026,(Lion_127,Leopard_028))),(Clouded leopard_25,(Sunda clouded leopard_036))),((Serval_001,(Caracal_020,African golden cat_002)),(((Pampas cat_3,(TigrinaCA_13,(TigrinaSA_6,(Geoffroy's cat_003,Kodkod_003)))),(Andean mountain cat_1,(Margay_022,Ocelot_006))),(((Bobcat_004,(Canadian lynx_3,(Eurasian lynx_001,Iberian lynx_2))),(Marbled cat_005,(Bay cat_2,Asian golden cat_8))),(((Jungle cat_20,(Black-footed cat_0006,(Sand cat_8,((European wild cat_007,Domestic cat_4804),(African wild cat_0004,Chinese desert cat_5))))),(Pallas cat_65,(Rusty-spotted cat_1,(Flat-headed cat_6,(Fishing cat_02A,Asian leopard cat_054))))),(Cheetah_234,(Jaguarundi_5,Puma_28)))))));

Upvotes: 0

Views: 1511

Answers (1)

C_Z_
C_Z_

Reputation: 7796

Your newick tree has singleton nodes, which read.tree cannot deal with. Install the phytools library and use the read.newick function instead.

Note that you probably need to collapse your singleton nodes using collapse.singles() to perform any analyses

library(phytools)
tree = read.newick("phylogeny.txt")
# Read 1 item

Upvotes: 2

Related Questions