inst/doc/maticce.R

### R code from vignette source 'maticce.Rnw'

###################################################
### code chunk number 1: startAnalysis
###################################################
library(maticce) # load maticce and required packages
data(carex) # load dataset
attach(carex) # attach dataset to search path
# convert the Bayes consensus to an ouchtree object...
ovales.tree <- ape2ouch(ovales.tree) 
# ... then convert the first 10 trees visited in the MCMC 
#     analysis to ouchtree objects
trees <- lapply(ovales.bayesTrees[1:10], ape2ouch) 


###################################################
### code chunk number 2: paintingOne
###################################################
ou2 <- paintBranches(list(ovales.nodes[[2]]), ovales.tree)


###################################################
### code chunk number 3: ov2
###################################################
plot(ovales.tree, regimes = ou2, cex = 1.2)


###################################################
### code chunk number 4: runBatch
###################################################
# First, analyze with maxNodes set to 2
ha.4.2 <- runBatchHansen(ovales.tree, ovales.data, 
          ovales.nodes[1:4], maxNodes = 2)
print(summary(ha.4.2))
# Then, analyze with maxNodes set to 4
ha.4.4 <- runBatchHansen(ovales.tree, ovales.data, 
          ovales.nodes[1:4], maxNodes = 4)
print(summary(ha.4.4))
# Then, assess the effects of phylogenetic uncertainty by 
#   analyzing over a set of trees
ha.4.2.multi <- runBatchHansen(trees, ovales.data, 
                ovales.nodes[1:4], maxNodes = 2)
print(summary(ha.4.2.multi))


###################################################
### code chunk number 5: ouSim
###################################################
ouSim.ha.4.2 <- ouSim(ha.4.2, tree = ovales.tree)
plot(ouSim.ha.4.2, colors = ou2)


###################################################
### code chunk number 6: ha
###################################################
ha.4.2[['regMatrix']][['overall']]


###################################################
### code chunk number 7: haLnl
###################################################
# ha.4.2[['hansens']][[1]][c(7, 11, 'brown'), ]
ha.4.2[['hansens']][[1]][c(7, 11), ]


###################################################
### code chunk number 8: haWeights
###################################################
# summary(ha.4.2)[['modelsMatrix']][[1]][c(7, 11, 'brown'), ]
summary(ha.4.2)[['modelsMatrix']][[1]][c(7, 11), ]


###################################################
### code chunk number 9: multiModel
###################################################
layout(matrix(1:9, 3, 3))
for(i in 1:8) {   
  mm <- multiModel(carex[['ovales.tree']], ovales.data, 
        ovales.nodes[[i]])
  pie(mm[['IC']][['BICwi']], labels = mm[['IC']][['names']], 
    col = rainbow(length(mm[['IC']][['names']])), 
    main = paste("Node",i,"BICwi"))
  }

Try the maticce package in your browser

Any scripts or data that you put into this service are public.

maticce documentation built on May 2, 2019, 6:13 p.m.