[R-sig-phylo] ace in ape how to derive ancestral states (which.max)

2013-03-20 Thread Andrés Parada
Sorry if this was addressed before. I reconstructed a binary discrete character with* ace* (coded as 0-1). As suggested in APER 2nd edition with the* Sylvia *case I can obtain the lik.anc values but I wanted to derive the ancestral states from this matrix. *First* *ANC - ace (data$character,

[R-sig-phylo] Concatenation of character matrices

2013-03-20 Thread thom.g
Hi, I have a certain number of character matrices that I want to merge together but unfortunately all the matrices don't have the same number of taxa and characters. However there is always more than one character/taxa in common between each matrix. I have something like that: Taxa

Re: [R-sig-phylo] Concatenation of character matrices

2013-03-20 Thread Liam J. Revell
Hi Thomas. For just two matrices (say, A B), this is easy: aa-sort(unique(c(rownames(A),rownames(B bb-sort(unique(c(colnames(A),colnames(B XX-matrix(NA,length(aa),length(bb),dimnames=list(aa,bb)) XX[rownames(A),colnames(B)]-A XX[rownames(B),colnames(B)]-B There may be some easier way

Re: [R-sig-phylo] ace in ape how to derive ancestral states (which.max)

2013-03-20 Thread Liam J. Revell
Hi Andres. To answer your question at its face value, the line of code you want is: anc-setNames(apply(ANC$lik.anc,1,function(x) names(which.max(x))),length(tree$tip.label)+1:tree$Nnode) (The setNames ensures that your resultant vector gets the node numbers for names.) This message really