Hi Carlos.

If you read in a set of trees they will be stored as an object of class "multiPhylo" which is a list of trees in memory.

To iterate aov.phylo across all the trees in this object (let's say, trees), you could do the following (modifying variable names as appropriate):

fits<-lapply(trees,aov.phylo,formula=y~x,nsim=100)

Then to pull out the 'phylogenetic p-values' only in a vector you could do:

Pr.phy<-sapply(fits,function(x) attr(x,"summary")$"Pr(phy)"[1])

All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 3/16/2015 5:29 PM, Carlos H. Biagolini Junior wrote:
Hello, I would like to ask for an advice:

I am using the function aov.phylo () in Geiger package (Garland, 1993), to
run a phylogenetic ANOVA.  I have had collected data in literature, and I
am using trees from the birdtree.org web site (for bird phylogenies).

My difficulty is: How can I perform a sequence of ANOVAs using my dataset
and the list of phylogenetic trees.

I aim to get each tree inside this list, and write a looping to run the
phylogenetic ANOVA, and store the results (i.e. p value) in an object.
However, I did not realize how can I systematically capture each tree in
this list (since the name of the trees follows a random number sequence,
i.e., within the file has trees with name: tree_3937, tree_2141, tree_8734,
etc...).


Thanks


-          Carlos Biagolini



Following my script (for now):



library(geiger)

setwd("D:/...")



# Introducing the trees

all.trees<-read.nexus("mytreefile.tre") # input the 100 trees

single.tree<- all.trees$ tree_3937 # one tree inside the list



# Creating a simulated dataset for exemplify

matrix<- matrix(rnorm (65, mean = 0.5, sd = 0.1),nrow=65,ncol=1)

species<- single.tree$tip.label # Carrying all species names for an object

rownames(matrix)<-species # Naming each data

group <-as.factor(rep(c("A","B","C","D","E"),each=13)) ;

d1 <- matrix[,1] ;

names(group) <- rownames(matrix);



# Phylogenetical ANOVA

aov.phylo(d1~group, single.tree, nsim=1000)






_______________________________________________
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/


_______________________________________________
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/

Reply via email to