Permalink
Browse files

merge

  • Loading branch information...
cboettig committed Jan 10, 2012
2 parents 854c3de + 73ffca2 commit db9fc59d7e10480eac3fc0720e35f37d790b4acc
Showing with 2,631 additions and 1,839 deletions.
  1. +25 −4 DESCRIPTION
  2. +27 −32 NAMESPACE
  3. +0 −42 R/blomberg_power.R
  4. +0 −24 R/confidenceIntervals.R
  5. +22 −31 R/{treeformats.R → convert.R}
  6. +19 −0 R/data_documentation.R
  7. +161 −0 R/format_data.R
  8. +26 −0 R/generics.R
  9. +263 −0 R/maticce.R
  10. +0 −78 R/object_oriented_geiger.R
  11. +0 −37 R/object_oriented_laser.R
  12. +0 −28 R/object_oriented_ouch.R
  13. +0 −44 R/oo_treepar.R
  14. +0 −55 R/ouch_treetransforms.R
  15. +0 −36 R/plot_functions.R
  16. +223 −0 R/pmc.R
  17. +0 −139 R/pmc_model.R
  18. +12 −1 R/powercurve.R
  19. +40 −0 R/treepalette.R
  20. +170 −0 R/wrappers_geiger.R
  21. +21 −0 R/wrappers_laser.R
  22. +68 −0 R/wrappers_ouch.R
  23. +13 −0 R/wrappers_treepar.R
  24. BIN data/anoles_model_choice.rda
  25. BIN data/geospiza_lambda.rda
  26. BIN data/power_curves.rda
  27. BIN data/simtree_lambda_dist.rda
  28. +4 −7 demo/00Index
  29. +0 −151 demo/anoles_model_choice.R
  30. +0 −35 demo/conf_interval_ex.R
  31. +0 −33 demo/early_burst_example.R
  32. +0 −35 demo/early_burst_geospiza.R
  33. +0 −54 demo/example.R
  34. +0 −42 demo/geospiza_lambda.R
  35. +38 −0 demo/make_anoles_example.R
  36. +61 −0 demo/pmc_anoles.R
  37. +0 −46 demo/pmc_ex.R
  38. +60 −0 demo/pmc_finches.R
  39. +12 −28 demo/power_curves.R
  40. +0 −13 demo/replot.R
  41. +0 −33 demo/simtree_eb.R
  42. +0 −31 demo/simtree_lambda_dist.R
  43. +29 −0 inst/doc/Makefile
  44. +0 −289 inst/doc/pmc.Rnw
  45. +350 −0 inst/doc/pmc_tutorial.Rnw
  46. +350 −0 inst/doc/pmc_tutorial/pmc_tutorial.Rnw
  47. +11 −0 man/anoles.Rd
  48. +25 −0 man/compute_regimes.Rd
  49. +20 −15 man/convert.Rd
  50. +18 −40 man/fitContinuous_object.Rd
  51. +37 −0 man/format_data.Rd
  52. +14 −0 man/getParameters.Rd
  53. +14 −0 man/getParameters.browntree.Rd
  54. +18 −0 man/getParameters.fitContinuous.Rd
  55. +14 −0 man/getParameters.hansentree.Rd
  56. +14 −0 man/get_data.Rd
  57. +14 −0 man/get_data.fitContinuous.Rd
  58. +14 −0 man/get_data.ouchtree.Rd
  59. +14 −0 man/get_phy.Rd
  60. +14 −0 man/get_phy.fitContinuous.Rd
  61. +14 −0 man/get_phy.ouchtree.Rd
  62. +14 −0 man/loglik.Rd
  63. +14 −0 man/loglik.browntree.Rd
  64. +18 −0 man/loglik.fitContinuous.Rd
  65. +14 −0 man/loglik.hansentree.Rd
  66. +0 −132 man/montecarlotest.Rd
  67. +20 −0 man/mrcaOUCH.Rd
  68. +29 −0 man/paintBranches.Rd
  69. +17 −0 man/plot.pmc.Rd
  70. +0 −138 man/plot.pow.Rd
  71. +16 −0 man/plot_pars.Rd
  72. +95 −0 man/pmc.Rd
  73. +47 −0 man/pmc_fit.Rd
  74. +29 −0 man/simulate.fitContinuous.Rd
  75. +10 −0 man/tree.Rd
  76. +19 −67 man/treepalette.Rd
  77. +22 −99 man/treepower.Rd
  78. +18 −0 man/update.fitContinuous.Rd
View
@@ -1,11 +1,32 @@
Package: pmc
Type: Package
Title: Phylogenetic Monte Carlo
-Version: 0.0-1
+Version: 0.0-2
Author: Carl Boettiger <cboettig@gmail.com>
Maintainer: Carl Boettiger <cboettig@gmail.com>
-Description: Monte Carlo based model choice for applied phylogenetics of continuous traits
-Depends: geiger, ape, ouch, mcmcTools, TreeSim, laser, phytools, snowfall
-Imports: odesolve
+Description: Monte Carlo based model choice for applied phylogenetics of
+ continuous traits
URL: http://www.carlboettiger.info
License: BSD
+Imports:
+ ape,
+ geiger,
+ ouch,
+ reshape,
+ snowfall,
+ TreeSim
+Depends:
+ ggplot2
+Collate:
+ 'format_data.R'
+ 'pmc.R'
+ 'powercurve.R'
+ 'wrappers_geiger.R'
+ 'wrappers_laser.R'
+ 'wrappers_ouch.R'
+ 'wrappers_treepar.R'
+ 'convert.R'
+ 'treepalette.R'
+ 'generics.R'
+ 'data_documentation.R'
+ 'maticce.R'
View
@@ -1,33 +1,28 @@
-#import(geiger)
-#import(ape)
-#import(ouch)
-#import(snowfall)
-#import(TreeSim)
-#import(odesolve)
-#import(laser)
-
-## pmc_model.R: a generic wrapper to help any packae with a fit
-## and simulate method use the pmc package functions
-export(pmc_model, simulate.pmc_model, update.pmc_model, getParameters.pmc_model, loglik.pmc_model, pmc)
-
-## montecarlotest.R fns -- provided by mcmcTools
-#export(plot.pow, montecarlotest, loglik, getParameters)
-
-## plot_functions.R
-export(plot_par_dists)
-
-## confidenceIntervals.R fns
-export(confidenceIntervals.pow)
-## treeformats.R
-export(convert, treepalette)
-##powercurves.R
+S3method(getParameters,browntree)
+S3method(getParameters,fitContinuous)
+S3method(getParameters,hansentree)
+S3method(get_data,fitContinuous)
+S3method(get_data,ouchtree)
+S3method(get_phy,fitContinuous)
+S3method(get_phy,ouchtree)
+S3method(loglik,fitContinuous)
+S3method(loglik,hansentree)
+S3method(plot,pmc)
+S3method(simulate,fitContinuous)
+S3method(update,fitContinuous)
+export(convert)
+export(format_data)
+export(mrcaOUCH)
+export(paintBranches)
+export(plot_pars)
+export(pmc)
+export(pmc_fit)
+export(treepalette)
export(treepower)
-
-## Object oriented structures for common phylogenetic models
-## allows the existing functions to use the montecarlotest() functions suite
-
-## object_oriented_geiger.R fns
-export(fitContinuous_object, simulate.fitContinuous, update.fitContinuous, loglik.fitContinuous, getParameters.fitContinuous, fitcts)
-## object_oriented_ouch.R fns
-export(loglik.browntree, loglik.hansentree, getParameters.browntree, getParameters.hansentree)
-
+import(TreeSim)
+import(ape)
+import(geiger)
+import(ggplot2)
+import(ouch)
+import(reshape)
+import(snowfall)
View
@@ -1,42 +0,0 @@
-#blomberg_power.R
-
-blomberg_power <- function(phy, nboot=200, cpu=2, threshold =.95){
-
- initBM <- function(phy, sigma2 = 10, root = 0){
- bm <- list(Trait1=list(beta=sigma2), tree=phy, root=root, model="BM")
- class(bm) <- "fitContinuous"
- bm
- }
-
- K_dist_bm <- sfSapply(1:nboot, function(i){
- bm <- initBM(phy)
- x <- simulate(bm) ## simulate and estimate blomberg's stat nboot times
- out <- phylosignal(x, phy, reps=100) ## blomberg reshuffles reps times
- out$K
- })
-
-
- K_dist_null <- sfSapply(1:nboot, function(i){
- bm <- initBM(phy)
- x <- simulate(bm) ## Will replace this data with independent normals of same statistics
- y <- rnorm(length(x), mean=mean(x), sd=sd(x))
- out <- phylosignal(y, phy, reps=100)
- out$K
- })
-
-
- threshold_tail <- sort(K_dist_null)[ round(threshold*nboot) ]
- power <- sum(K_dist_bm > threshold_tail)/nboot
-
- overlap <- K_dist_bm %*% K_dist_null
- out <- list(overlap=overlap, power=power, null_dist =K_dist_null, test_dist=K_dist_bm, phy=phy)
-
- plt <- function(){
- plot(density(K_dist_bm), col="darkred", lwd=3, ylim=c(0,3), main=paste("overlap = ", overlap))
- lines(density(K_dist_null), col="darkblue", lwd=3)
- }
- social_plot(plt(), file="blombergK.png", tags=tags, comment=paste("Nnode = ", phy$Nnode))
- out
-}
-
-
View
@@ -1,24 +0,0 @@
-#confidenceIntervals.R
-
-ci <- function(dist, thresh=.95){
- n <- length(dist)
- lower <- (1-thresh)/2
- upper <- thresh+lower
- sort(dist)[c(round(lower*n), round(n*upper))]
-}
-ci_all_pars <- function(par_dists, thresh=.95){
- sapply(1:dim(par_dists)[1], function(i) ci(par_dists[i,], thresh))
-}
-
-confidenceIntervals.pow <- function(pow, thresh=.95){
- test_ci <- ci_all_pars(pow$test_par_dist)
- null_ci <- ci_all_pars(pow$null_par_dist)
- colnames(test_ci) <- names(getParameters(pow$test))
- rownames(test_ci) <- c(paste("lower", thresh, ":"), paste("upper", thresh, ":"))
- colnames(null_ci) <- names(getParameters(pow$null))
- rownames(null_ci) <- c(paste("lower", thresh, ":"), paste("upper", thresh, ":"))
-
- list(test=test_ci, null=null_ci)
-}
-
-
@@ -1,7 +1,19 @@
-# treeformats.R
-# Convert toggles between ouch and ape format trees
-
-convert <- function(ot, regimes=NULL){
+#' toggles between ouch and ape format trees
+#' @param ot a phylogenetic tree in ouch or ape format
+#' @param regimes if given in ape format, are appended to
+#' phylo format as phy$regimes. If the ouchtree is a fitted
+#' hansen object, regimes will automatically be imported from it
+#' unless other regime choice is given here.
+#' @param safe mode for going from ape to ouch. After converting, this
+#' writes to a temporary nexus file and reads the tree back in, because
+#' phylo format does not have a unique specification for a unique tree,
+#' resulting in all kinds of silly problems when developers haven't been careful.
+#' Defaults to true, and will clean up after itself.
+#' @return a phylogenetic tree in the opposite format
+#' @export
+convert <- function(ot, regimes=NULL, safe=TRUE){
+ if(!is.null(regimes))
+ safe<-FALSE # cannot write to nexus if regimes are required
if(is(ot, "ouchtree")){
n <- ot@nnodes
@@ -34,6 +46,12 @@ convert <- function(ot, regimes=NULL){
tree <- list(edge=edge, Nnode = (n-1)/2, tip.label = labels, edge.length= lengths )
class(tree) <- "phylo"
+ if(safe){
+ write.nexus(file="tmp3612411.nex", tree)
+ tree <- read.nexus("tmp3612411.nex")
+ unlink("tmp.nex")
+ }
+
if (is(ot, "hansentree")) {
regimes <- ot@regimes[[1]][-1]
tree$regimes <- regimes
@@ -52,30 +70,3 @@ convert <- function(ot, regimes=NULL){
-
-# coloring for trees
-treepalette <- function(apetree, colormap = c("rainbow", "heat.colors", "terrain.colors", "topo.colors", "cm.colors", "gray"), custom=NULL, rev=FALSE ){
- colormap <- match.arg(colormap)
- if(colormap=="rainbow")
- levels(apetree$regimes) <- rainbow(length(levels(apetree$regimes)))
- if(colormap=="heat.colors")
- levels(apetree$regimes) <- heat.colors(length(levels(apetree$regimes)))
- if(colormap=="terrain.colors")
- levels(apetree$regimes) <- terrain.colors(length(levels(apetree$regimes)))
- if(colormap=="topo.colors")
- levels(apetree$regimes) <- topo.colors(length(levels(apetree$regimes)))
- if(colormap=="cm.colors")
- levels(apetree$regimes) <- cm.colors(length(levels(apetree$regimes)))
- if(colormap=="gray"){
- n <-length(levels(apetree$regimes))+2
- levels(apetree$regimes) <- gray((1:n)/n)
- }
- if(!is.null(custom))
- levels(apetree$regimes) <- custom
- if(rev==TRUE)
- levels(apetree$regimes) <- rev(levels(apetree$regimes))
- as.character(apetree$regimes)
-}
-
-
-
View
@@ -0,0 +1,19 @@
+#' The anoles data set
+#'
+#' as from ouch with additional regimes added and minor formatting changes
+#' @name anoles
+#' @docType data
+# @references
+#' @keywords data
+NULL
+
+#' The phylogeny for the anoles data set
+#'
+#' The bimaculus phylogeny, as from the ouch package
+#' @name tree
+#' @docType data
+# @references
+#' @keywords data
+NULL
+
+
Oops, something went wrong.

0 comments on commit db9fc59

Please sign in to comment.