Hi Juan, it seems that you trim too many taxa. I can replicate the error message if I trim for example 19 out of a 20 tips of a tree. drop.tip(tree, sample(20, 19)) Error in integer(max(oldnodes)) : vector size cannot be infinite In addition: Warning message: In max(oldnodes) : no non-missing arguments to max; returning -Inf > traceback() 3: integer(max(oldnodes)) 2: collapse.singles(phy) 1: drop.tip(tree, sample(20, 19))
Maybe you include a check into your function z that the pruned trees have at least two tips left if( length( setdiff(treeP$tip.label, colnames(hp))) < ( length( treeP$tip.label ) -2 ) ) Cheers, Klaus On Fri, Jan 20, 2017 at 7:26 AM, Juan Antonio Balbuena <j.a.balbu...@uv.es> wrote: > Hello all > > I am working with a cophylogenetic problem where I have a host tree, a > parasite tree and a binary matrix HP encapsulating the host-parasite > associations . After trimming the matrix according to a given criterion, I > require to prune the trees accordingly. Since I am getting errors at the > execution I devised the following control function to check the number of > tree nodes after pruning: > z <- function (hp, treeH,treeP) { > treeh <- drop.tip(treeH, setdiff(treeH$tip.label, rownames(hp))) > treep <- drop.tip(treeP, setdiff(treeP$tip.label, colnames(hp))) > res <- c(treeh$Nnode,treep$Nnode) > return(res) > } > > Then I try the following > > x <- sapply (THP, z, treeH=TreeH[[7]], treeP= TreeP[[7]]) > > where THP is a list of trimmed HP matrices and TreeH and TreeP are > multiphylo objects and get the following error: > > Error in integer(max(oldnodes)) : vector size cannot be infinite > > The traceback is > > 6. integer(max(oldnodes)) > 5. collapse.singles(phy) > 4. drop.tip(treeP, setdiff(treeP$tip.label, colnames(hp))) > 3. FUN(X[[i]], ...) > 2. lapply(X = X, FUN = FUN, ...) > 1. sapply(THP, z, treeH = TreeH[[7]], treeP = TreeP[[7]]) > > This error appears only with this particular pair of host and parasite > trees (#7) and I cannot find a reason why this case should be different. > > Any help will be very much appreciated. > > Juan A. Balbuena > > -- > > Dr. Juan A. Balbuena > Cavanilles Institute of Biodiversity and Evolutionary Biology > University of Valencia > http://www.uv.es/~balbuena > P.O. Box 22085 > http://www.uv.es/cophylpaco > <http://www.uv.es/cavanilles/zoomarin/index.htm> > 46071 Valencia, Spain > e-mail: j.a.balbu...@uv.es tel. +34 963 543 658 > <+34%20963%2054%2036%2058> fax +34 963 543 733 > <+34%20963%2054%2037%2033> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > *NOTE!* For shipments by EXPRESS COURIER use the following street address: > C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain. > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > _______________________________________________ > 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-ph...@r-project.org/ > -- Klaus Schliep Postdoctoral Fellow Revell Lab, University of Massachusetts Boston http://www.phangorn.org/ [[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/