tests/testthat/test_obtainDatedPosteriorTreesMrB.R

test_that("obtainDatedPosteriorTreesMrB works", {


#library(paleotree)
#setwd("C://Users//dwbapst//workspace//paleotree//tests//testthat")

set.seed(44)

fileTest <- "data//retio_dating.run1.t"

MCCT <- obtainDatedPosteriorTreesMrB(
	runFile = fileTest,
	nRuns = 2, 
	burnin = 0.5,
	getFixedTimes = FALSE,
	outputTrees = "MCCT", 
	file = NULL)

expect_message(
MAP <- obtainDatedPosteriorTreesMrB(
	runFile = fileTest,
	nRuns = 2, 
	burnin = 0.5, 
	getFixedTimes = TRUE,
	outputTrees = "MAPosteriori", 
	file = NULL)
)
		
MAPr <- obtainDatedPosteriorTreesMrB(
 	runFile = fileTest,
 	nRuns = 2, 
	burnin = 0.5, 
	getFixedTimes = TRUE,
	outputTrees = "MAPriori", 
	file = NULL)

expect_message(
expect_warning(		
MaxLike <- obtainDatedPosteriorTreesMrB(
 	runFile = fileTest,
 	nRuns = 2, 
	burnin = 0.5, 
	getFixedTimes = TRUE,
	outputTrees = "MaxLikelihood", 
	file = NULL)
))

# get a root age from the fixed ages for tips
	# but root age already exists so this should return an error
expect_error(
setRootAge(tree = MCCT)
)

#pull a hundred trees randomly from the posterior
hundredRandomlySelectedTrees <- obtainDatedPosteriorTreesMrB(
 	runFile = fileTest,
 	nRuns = 2, 
	burnin = 0.5, 
	getFixedTimes = TRUE,
 	getRootAges = TRUE,
	outputTrees = 100, 
	file = NULL)

testthat::skip_on_cran()
testthat::skip_on_ci()	
testthat::expect_equal_to_reference(hundredRandomlySelectedTrees, update=TRUE,
	file = ".//references//datedPosteriorTreesMrB//hundredRandom") 

})
dwbapst/paleotree documentation built on Aug. 30, 2022, 6:44 a.m.