Hi Carlos.
If you like to use for loops, you could do something like:
analysis<-list()
p.value<-vector()
for (i in 1:5 ) {
analysis[[i]] <- aov.phylo(x~y,trees[[i]], nsim=100)
p.value[i]<-attr(analysis[i], "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: [email protected]
blog: http://blog.phytools.org
On 3/17/2015 3:58 PM, Carlos H. Biagolini Junior wrote:
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 <[email protected]
<mailto:[email protected]>> 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/
<http://faculty.umb.edu/liam.revell/>
email: [email protected] <mailto:[email protected]>
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 <http://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 - [email protected]
<mailto:[email protected]>
https://stat.ethz.ch/mailman/__listinfo/r-sig-phylo
<https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
Searchable archive at
http://www.mail-archive.com/[email protected]/
<http://www.mail-archive.com/[email protected]/>
--
Carlos Biagolini-Jr
Universidade Federal de São Carlos
http://lattes.cnpq.br/4086237188108947
_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/