Dear colleagues, I would like to ask for a little help from you. I have a phylogenetic tree with nine taxa and three samples (see figure below). Each sample has three taxa from the phylogeny. I am interested in extracting the internal branch lengths (corresponding to the ancestors of all tips) that are present in each sample (represented by the corresponding tips) and summarising them for each sample (e.g., summing all internal branch lengths on samples). Here is a rough reproducible example until getting all branch lengths: #number of taxa ntax <- 9 #get a phylogeny with 9 taxa set.seed(999) samptree <- rcoal(ntax) #color fot the tips according to their occurrence on samples colors <- c("blue", "blue", "blue", "green", "green", "green", "purple", "purple", "purple") #plot the tree and branch lengths with rounded values plot(samptree, label.offset = 0.2, tip.color = colors) edgelabels(round(samptree$edge.length, 2), cex=1, width = 1, height = 0.1, frame = "none", bg = NULL, col = "red", offset = 1.5, adj = c(-0.1, -0.2)) #matrix with samples based on the phylogeny and three samples as in the figure sample <- matrix(data = c(1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1), nrow = 3, ncol = 9, dimnames = list(c("purple", "green", "blue"), c("t4", "t3", "t6", "t8", "t2", "t1", "t9", "t7", "t5")), byrow = TRUE) #get all branch lengths from the tree all_branch_lenghts <- round(samptree$edge.length, 2) From here, I could not separate internal branch lengths to tip lengths and trace these internal branches on samples based on their occurrence. Does anyone have an idea to do such a thing? The real phylogeny has around 6,000 tips and the real number of samples is around 130. Thank you very much for any help! Here is the figure that exemplifies what I want to do: Best regards, -- Dr Jhonny Capichoni Massante Postdoctoral Research Fellow in Macroecology Universidade de São Paulo Instituto de Biociências Departamento de Ecologia Laboratório de Ecologia de Florestas Tropicais |
_______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/