Hi Marina.
Your problem is that the trees returned by make.simmap with nsim>1 are
an object of class "multiPhylo" - a list of trees (objects of class
"phylo") each with a mapped discrete character. I'm guessing that the
first time you ran this you encountered the error:
Error in is.rooted(target) : object "phy" is not of class "phylo"
This cannot be resolved by just changing the class attribute of your object.
Instead, you can iterate the function over a set of trees. For instance,
if you have two sets of trees, each with a mapped discrete character,
you can use:
overlap<-sapply(flower.trait.map,function(x,y)
sapply(y,map.overlap,x),y=pollinator.map)
Which will give you a matrix of pairwise overlaps between map trees.
Alternatively, if you want to iterate pairwise over a two sets of trees
(say, computing the overlap between the 1st & 1st, the 2nd & 2nd, etc.),
you can use:
overlap<-mapply(overlap,flower.map,pollinator.map)
This should be equivalent to the diagonal of the first example.
The latter case might be useful if you have a set of trees of different
topologies, or with different edge lengths, but the same trees are found
in each set.
Let us know if this is helpful. 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 5/19/2015 2:27 PM, Marina Strelin wrote:
Hi!
I'm trying to use the map.overlap function of the R package phytools to
compute the fraction of stochastic character mapping that is shared by two
trees (I basically want to obtain a quantitative value that tells me if
there is correlative evolution between an adaptive strategy and a trait).
But the function map.overlap does not accept my two stochastic chatacter
mappings.
I did
pollinator.map<-make.simmap(tree, pol, model="ER", nsim=100)
flower.trait.map<-make.simmap(tree, flower, model="ER", nsim=100)
class(flower.trait.map)<-"phylo"
class(pollinator.map)<-"phylo"
overlap.pol.flower<-map.overlap(pollinator.map, flower.trait.map,
tol=1e-6)
But get this error message..
*Error in tabulate(phy$edge[, 1]) : 'bin' must be numeric or a factor*
I tried to transform edge[, 1] to numeric, but this vector is empty
as.numeric(mapeo.syn$edge[,1])
*numeric(0)*
as.numeric(mapeo.flor$edge[,1])
*numeric(0)*
How can I solve this problem?
By the way, If this problem can be solved, can I apply the map.overlap
function to two stochastic character mappings, each made on trees with
different topologies (as long as the trees I use in the two mappings are
the same)?
Thanks in advance for answering my questions,
Marina
[[alternative HTML version deleted]]
_______________________________________________
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]/
_______________________________________________
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]/