第一种方法:
#
http://blog.phytools.org/2013/04/picking-tree-or-set-of-trees-at-random.htmlA friend recently asked:
"Does anybody know how to, in R, select a single tree at random from a posterior distribution of trees (e.g., generated via MrBayes)?"
This is not too hard. A set of trees read into memory using read.tree or read.nexus is just a list of trees with the class attribute set to "multiPhylo". To pick one at random we can just do:
random.tree<-sample(trees,size=1)[[1]]
We include the index [[1]] to (non-recursively) unlist the object returned by sample.
If we want to sample more than one, say 100 random trees from a posterior sample of 1,000, the procedure is the same. So we can just do:
random.trees<-sample(trees,size=100)
That's it.
Posted by Liam Revell at
7:26 PM#######################################################################
第二种方法:
Alice VershininaApril 2, 2013 at 7:20 AMVery useful and so simple! Thank you, Liam!
Few weeks ago, I found another approach, which takes into account burn-in.
http://coleoguy.blogspot.ru/2012/09/randomly-sampling-trees.html
#########################################################################
第三种方法:
https://github.com/FePhyFoFum/phyx/wiki/Program-list
利用phyx工具箱中的pxlog程序:
Resamples parameter or tree MCMC samples using some burnin and thinning across an arbitrary number of log files. NOTE: resampling parameters are in terms of number of samples, not number of generations. To determine the attributes of the log files, you can first use the -i (--info) flag:
./pxlog -t tree_files -i
and then sample accordingly:
./pxlog -t tree_files -b some_burnin -n some_thinning #每隔多少个样,sample一个。#pxlog -t 100conphy_mp70.trees -o 1000random.trees -b 1060 -r 1000
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。