Hi Hannah,

if you provide MCTree then I guess the first column is the species and the 
second column is the character vector.
Try providing only the state vector. I think in this case “length” does count 
the length of your MCTree data.frame which would be 2 and not the length of 
your character vector in the data.frame.

So try this:
ace.ER<-ace(MCTree[,2],phy=tree,type="discrete",model=“ER”)

Hope this works...
Best, Franz


MSc. Franz Krah
Mycology, Phylogenetics, PCM
http://www.biodiv.wzw.tum.de/index.php?id=18 
<http://www.biodiv.wzw.tum.de/index.php?id=18>
currently at Clark University



> On 13 Mar 2015, at 12:16, Hannah west <[email protected]> wrote:
> 
> 
> 
> 
> 
> 
> Dear All,
> 
> I am trying to do an ancestral state reconstruction in R using the package 
> 'ape'. I have tried trimming my tree in BayesTraits and in R itself, and the 
> resulting tree reports as having 573 species tips, which is the same as my 
> dataset. As far as I can tell everything is loading properly, but every time 
> I try running the ACE codes R returns the following error message;
> Error in ace(MCTree, phy = tree, type = "discrete", model = "ER") : 
>  length of phenotypic and of phylogenetic data do not match.
> 
> The code I'm using is 
> ace.ER<-ace(MCTree,phy=tree,type="discrete",model="ER")
> 
> My data summary loads as
> 'data.frame':   573 obs. of  2 variables:
> $ Species: Factor w/ 573 levels "Abeomelomys_sevia",..: 251 10 16 17 18 25 30 
> 31 32 54 ...
> $ MCAll  : int  0 0 0 0 0 0 0 0 0 0 ...
> 
> My tree loads as
> List of 4
> $ edge       : int [1:1144, 1:2] 574 575 576 576 577 577 578 578 579 579 ...
> $ edge.length: num [1:1144] 64.6 27.3 55.2 3.6 51.6 33.3 18.3 0.1 18.2 18.2 
> ...
> $ Nnode      : int 572
> $ tip.label  : chr [1:573] "Abeomelomys_sevia" "Abrothrix_longipilis" 
> "Abrothrix_olivaceus" "Acerodon_celebensis" ...
> - attr(*, "class")= chr "phylo"
> - attr(*, "order")= chr "cladewise"
> 
> And as you can see the tips and data strings should match in length.
> 
> Any help would be much appreciated. Thank you!
> 
> (This is my first submission to one of these help threads so let me know if I 
> miss anything vital).
> 
>                                                                               
>   
>       [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-phylo mailing list - [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/[email protected]/


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to