Hi Jonathan.

This seems to be a bug in phytools that is due to your tree being multifurcating, rather than fully bifurcating. Sorry about this. I will fix this in a future release of phytools.

In the meantime, you could do something like this:

tt<-multi2di(symbTree)
islandRecon<-rerootingMethod(tt,island,model="ER")
M<-matchNodes(symbTree,tt)
ii<-sapply(M[,1],function(x,y)
  which(y==x),y=rownames(islandRecon$marginal.anc))
rownames(islandRecon$marginal.anc)<-M[ii,2]
islandRecon$marginal.anc<-
  islandRecon$marginal.anc[!is.na(rownames(islandRecon$marginal.anc)),]

Now the row names in islandRecon$marginal.anc should correspond to node numbers in your original tree.

All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: [email protected]
blog: http://blog.phytools.org

On 6/4/2014 11:37 AM, Brown, Jonathan wrote:
Hi,

   Sorry for the simple question, but I am getting an error when using Phytools 
rerootingMethod function, and I can’t figure it out.

Error in `colnames<-`(`*tmp*`, value = c("Haw", "Kau", "Mau", "Oah")) :
   attempt to set 'colnames' on an object with less than two dimensions

Thanks,

Jackie
————————————————

symbTree <- read.nexus("symbiontMCCTree.nex")
symbTree

Phylogenetic tree with 20 tips and 13 internal nodes.

Tip labels:
        PnewKa1, PvitMo1, TwaiMa1, TarbHa1, TbeaMa1, TcraMa1, ...

Rooted; includes branch lengths.

symIsland<-read.table("symbiontIsland.txt")
symIsland
         V1  V2
1  PnewKa1 Kau
2  PvitMo1 Mau
3  TwaiMa1 Mau
4  TarbHa1 Haw
5  TbeaMa1 Mau
6  TcraMa1 Mau
7  TdubKa1 Kau
8  TdubOa1 Oah
9  TdubMa1 Mau
10 TjoiKa1 Kau
11 TjoiMa1 Mau
12 TjoiMo1 Mau
13 TpanHa1 Haw
14 TpanHa2 Haw
15 TpohHa1 Haw
16 TartMa1 Mau
17 TperKa1 Kau
18 TdenMa1 Mau
19 TsweKa1 Kau
20 TsweMa1 Mau
island<-symIsland[,2]
island
  [1] Kau Mau Mau Haw Mau Mau Kau Oah Mau Kau Mau Mau Haw Haw Haw Mau Kau Mau 
Kau
[20] Mau
Levels: Haw Kau Mau Oah
names(island)<-symIsland[,1]
island
PnewKa1 PvitMo1 TwaiMa1 TarbHa1 TbeaMa1 TcraMa1 TdubKa1 TdubOa1 TdubMa1 TjoiKa1
     Kau     Mau     Mau     Haw     Mau     Mau     Kau     Oah     Mau     Kau
TjoiMa1 TjoiMo1 TpanHa1 TpanHa2 TpohHa1 TartMa1 TperKa1 TdenMa1 TsweKa1 TsweMa1
     Mau     Mau     Haw     Haw     Haw     Mau     Kau     Mau     Kau     Mau
Levels: Haw Kau Mau Oah
islandRecon<-rerootingMethod(symbTree,island,model="ER")
Error in `colnames<-`(`*tmp*`, value = c("Haw", "Kau", "Mau", "Oah")) :
   attempt to set 'colnames' on an object with less than two dimensions

-----------------
Jackie (Jonathan M.) Brown
Professor of Biology
Grinnell College, IA, USA

_______________________________________________
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]/


_______________________________________________
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