Hi Jürgen,
Jürgen Kluge <klugejuer...@gmx.de> a écrit :
Dear all.
I search for a possibility to transform phylogenetic data from class
'phylog' (which is processed by ade4) to calss 'phylo' which I want to
use within commands of 'picante'
Here is a short dataframe with 5 species, transformed to object of
class 'phylog' with package 'ade4'
library(ade4)
dat.phyl<-data.frame(cbind(c("a","a","b","c","c"),
c("a","a","a","b","b")))
rownames(dat.phyl)<-c("HUP","LYC","SEL","CAM","CER")
phyl.1<-as.taxo(dat.phyl) phyl.2<-taxo2phylog(phyl.1)
# show Newick format of phyl.2:
phyl.2$trebetween
Which returns:
phyl.2$tre
[1] "(((HUP,LYC)l1a,(SEL)l1b)l2a,((CAM,CER)l1c)l2b)Root;"
So there is a singleton in this tree (an internal node of degree 2
linking l1b and SEL) which is not permitted in ape (all internal nodes
must be of degree 3 or higher).
You can use as.phylo.formula() in ape. First, add a column with
species names in your data.frame:
dat.phyl$sp <- factor(rownames(dat.phyl))
Then call as.phylo with a formula defining the hierarchy (see
?as.phylo.formula for details):
phyl.3 <- as.phylo(~X2/X1/sp, data=dat.phyl)
EP
# and tree
plot(phyl.2)
# now I want to transform phyl.2 (class: 'phylog') into phyl.3 (class:
'phylo') by using:
library(picante) phyl.3<-as.phylo(phyl.2)
# as described in : http://cran.r-project.org/web/packages/ape/ape.pdf
# gives error message (translation from German by me):
Error in if (sum(obj[[i]]$edge[, 1] == ROOT) == 1 &&
dim(obj[[i]]$edge)[1] > :
missing value, where TRUE/FALSE is expected
# What is going wrong?
# For every hint i am very thankful!
# Kind regards,
# Juergen
_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo