Dear list, First, Happy New Year!
Second, I will apologize in advance, as I am nothing more than a duffer with R, so I may ask several follow-up questions to this one. I have a set of 1000 trees that lack branch lengths. I have used previously used ape to calculate branch lengths on a single tree, but never on a multiphylo object. I did find and have tried the approach documented at this link: http://blog.phytools.org/2015/04/phylogenetic-regression-when-branch.html but I received a few error messages, including: > library(phytools) Error in gzfile(file, "rb") : cannot open the connection In addition: Warning messages: 1: package ‘phytools’ was built under R version 3.0.3 2: In read.dcf(file.path(p, "DESCRIPTION"), c("Package", "Version")) : cannot open compressed file 'C:/Program Files/R/R-3.0.2/library/ape/DESCRIPTION', probable reason 'No such file or directory' 3: In gzfile(file, "rb") : cannot open compressed file '', probable reason 'No such file or directory' > library(phangorn) Error in gzfile(file, "rb") : cannot open the connection In addition: Warning messages: 1: package ‘phangorn’ was built under R version 3.0.3 2: In read.dcf(file.path(p, "DESCRIPTION"), c("Package", "Version")) : cannot open compressed file 'C:/Program Files/R/R-3.0.2/library/ape/DESCRIPTION', probable reason 'No such file or directory' 3: In gzfile(file, "rb") : cannot open compressed file '', probable reason 'No such file or directory' and: > library(ape) > ## simulate 200 pure-birth trees: > trees<-ttrees<-pbtree(n=50,scale=1,nsim=200) Error: could not find function "pbtree" > ## ttrees contains the trees with their original branch lengths > ## we'll perform manipulations on trees > foo<-function(tree){ + obj<-fastBM(tree,nsim=2) + colnames(obj)<-c("x","y") + as.data.frame(obj) + } > xy<-lapply(ttrees,foo) Error in lapply(ttrees, foo) : object 'ttrees' not found > library(nlme) > fit.model<-function(tree,data){ + data$v<-diag(vcv.phylo(tree)) + fit<-gls(y~x,data=data,correlation=corBrownian(1,tree), + weights=varFixed(~v)) + setNames(c(coefficients(fit)[2],anova(fit)$"p-value"[2]), + c("beta","p-value")) + } > fit.true<-t(mapply(fit.model,trees,xy)) Error in mapply(fit.model, trees, xy) : object 'xy' not found > mean(fit.true[,1]) ## should be zero Error in mean(fit.true[, 1]) : object 'fit.true' not found > noogtree<-lapply(noogtree,compute.brlen) > class(noogtree)<-"multiPhylo" > fit.grafen<-t(mapply(fit.model,noogtree,xy)) Error in mapply(fit.model, noogtree, xy) : object 'xy' not found > utils:::menuInstallPkgs() Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified > fit.grafen<-t(mapply(fit.model,noogtree)) Error in data$v <- diag(vcv.phylo(tree)) : argument "data" is missing, with no default > fit.grafen<-t(mapply(fit.model,noogtree,xy)) Error in mapply(fit.model, noogtree, xy) : object 'xy' not found > mean(fit.grafen[,1]) Error in mean(fit.grafen[, 1]) : object 'fit.grafen' not found > foo<-function(tree){ + tree$edge.length<-rep(1,nrow(tree$edge)) + tree + } > trees<-lapply(ttrees,foo) Error in lapply(ttrees, foo) : object 'ttrees' not found > class(trees)<-"multiPhylo" > fit.equal<-t(mapply(fit.model,trees,xy)) Error in mapply(fit.model, trees, xy) : object 'xy' not found > mean(fit.equal[,1]) ## should be zero Error in mean(fit.equal[, 1]) : object 'fit.equal' not found Does anyone have any advice? Please let me know if I should provide more information. Thanks in advance, Mike Pauers [[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/