Hi Carla, I use this function of ips:
<https://rdrr.io/github/heibl/ips/man/collapseUnsupportedEdges.html>collapseUnsupportedEdges(phy, value = "node.label", cutoff) It took me a while to figure out that there is a trick to do with multiPhylo - here is the code I use for files with multiple trees (in this case to produce sets of collapsed trees with thresholds from 10 to 10). I hope it helps! Martin library("ape") require(phytools) require(ips) input_file_name <- "tree.treefile" loci_trees <- read.tree(input_file_name) # newick tree/s. If multiple trees, this makes a multiPhylo object if(class(loci_trees) == "phylo"){ loci_trees <- as.multiPhylo(loci_trees) # in case there is a single tree in the file } for(cutoff in seq(from=10, to=100, by=10)){ for(i in 1:length(loci_trees)){ locus_tree <- loci_trees[[i]] collapsed_locus_tree <- collapseUnsupportedEdges(locus_tree, "node.label", cutoff) output_file_name = paste(input_file_name,".cutoff.",cutoff,".treefile",sep="") if (i==1){ write.tree(collapsed_locus_tree,file = output_file_name,append=FALSE) } else{ write.tree(collapsed_locus_tree,file = output_file_name,append=TRUE) } } } Date: Fri, 22 May 2020 10:42:24 -0300 From: Karla Shikev <karlashi...@gmail.com> To: R Sig Phylo Listserv <r-sig-phylo@r-project.org> Subject: [R-sig-phylo] collapsing sets of nodes based on label values Message-ID: <CAPU4_4pYGOw3uDQ9RE8hRxRFN=0bc_P29HOfJucJp=ahvxc...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Dear all, I'm surprised I could not find a simple function to do this in any of the packages I know. I just want to take a tree with node labels (e.g. bootstrap values from a RAxML analysis) and collapse all nodes with support values below, say, 90%. I tried to do this recursively using collapse.to.star in phytools, but node numbers change after the first collapsed node and my indexing gets completely off. with best regards, Karla Mart�n J. Ram�rez Curador, Divisi�n Aracnolog�a Museo Argentino de Ciencias Naturales - CONICET Av. Angel Gallardo 470 C1405DJR Buenos Aires Argentina tel +54 11 4982-8370 int. 169 [[alternative HTML version deleted]]
_______________________________________________ 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/