Caetanods / ratematrix

Bayesian estimation of the evolutionary rate matrix.
9 stars 3 forks source link

mergeMCMC does not work with single rate fit #49

Closed acope3 closed 5 years ago

acope3 commented 5 years ago

Attempting to merge two MCMC's fails when the first MCMC passed is a single rate fit. My guess is this is because the mergePosterior function checks if the first object in the list inherits ratematrix_multi_chain instead of inheriting ratematrix_multi_chain or ratematrix_single_chain.

Caetanods commented 5 years ago

Thanks for the Bug report and I apologize for the delay in working with this. You are correct. I overlooked the single regime case when I implemented checks for argument format.

Note that the function you mention is now called mergePosterior.

Try the code below, it should be working now:

library( devtools )
install_github("Caetanods/ratematrix", ref = "master")
library( ratematrix )
data( centrarchidae )
phy.single <- mergeSimmap(phy = centrarchidae$phy.map, drop.regimes = TRUE)
single.list <- lapply(1:2, function(x) ratematrixMCMC(data = centrarchidae$data, phy = phy.single
                                                      , gen = 500, dir = "test_single") )
single.list.post <- lapply( single.list, readMCMC )
single.merge <- mergePosterior( single.list.post )
class( single.merge )