Thanks Liam, it was very helpful!

Now, I am able to run the analysis by your way. However, now arises another
question:

Looking the "multiPhylo" structure, I tried to run the analyses in a
looping format, in this way:



analysis <- NULL


for (i in 1:100 ) {

  analysis[i] <- aov.phylo(x~y,trees[[(i)]], nsim=100)

}


The p values are presented in console, but I did not found a way to bring
this into an object (below one of my attempts). I tried to recover the p
value inside de loop, but when the loop ends, the stored p values are all
the same (probably the p value of the last run of the loop).


for (i in 1:5 ) {

  analysis[i] <- aov.phylo(x~y,trees[[(i)]], nsim=100)

  p.value[i]<-attr(analysis, "summary")$ "Pr(phy)"[1]

}




Thanks again for your help,

All the best,

-         -  Carlos

On Tue, Mar 17, 2015 at 10:55 AM, Liam J. Revell <liam.rev...@umb.edu>
wrote:

> 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-ph...@r-project.org/
>>
>>


-- 
Carlos Biagolini-Jr
Universidade Federal de S�o Carlos
http://lattes.cnpq.br/4086237188108947

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

Reply via email to