Tiny question - MCMCTreeR

37 views
Skip to first unread message

Ziv Lieberman

unread,
Apr 29, 2025, 4:24:57 PMApr 29
to PAML discussion group
Hi all,
I know MCMCTreeR is its own entity, but I figured some users here might have a tip. I am just trying to run priorPosterior() to plot my effective priors (so with MCMCPosterior = NULL).
It seems to want the same tree used as input for the MCMCTree analysis - so, a Newick string with the calibrations in PAML format and preceded by m n <taxa> <trees>. However, priorPosterior() throws an error with scan() saying that the number of entries in row 2 are wrong? Looking at the code, it is trying to read the tree as a table....
Any idea what I'm missing?
Thanks!
-Ziv

Sishuo Wang

unread,
May 6, 2025, 9:59:44 PMMay 6
to PAML discussion group
Hi Ziv,

Thx for the questions! would you pls mind providing some codes and data if any so that anyone that might be familiar with the issue can more easily follow? Thanks!


best,
sishuo

Ziv Lieberman

unread,
May 6, 2025, 10:18:51 PMMay 6
to PAML discussion group
Sure thing!
Please find attached the calibrated topology (file 'calibration_topo.trees') . I am using the MCMC trace from a run with usedata=0 (file 'datafree-m-ir_run-0.trace') which is unfortunately too large a file for me to attach here; please access it at https://drive.google.com/file/d/1A92AO2oZwdYwJMG0VzhwZTT_k3qk2hPQ/view?usp=sharing .

The documentation for MCMCtreeR::priorPosterior gives the usage as:
priorPosterior(MCMCPrior, MCMCPosterior = NULL, inputTree, return.density = FALSE, rootCalibration = NULL)
where MCMCPrior is the "prior of MCMC file from MCMCtree analysis using data=0" and inputTree is "phylogeny in MCMCtree format used in MCMCtree analysis".
The example on the man page is
  priorPosterior(MCMCPrior, # MCMCPosterior=MCMCtree.output$MCMCtree.posterior, # path.to.input.tree) .

I have tried:
library(MCMCtreeR)
priorPosterior(MCMCPrior='datafree-m-ir_run-0.trace', inputTree='calibration_topo.trees')

# As well as reading in the trace first:
priors <- mcmc(read.table('datafree-m-ir_run-0.trace', header=T))
priorPosterior(MCMCPrior=priors, inputTree='calibration_topo.trees')

And also reading the tree in first and using it is a variable instead of using the path to the input tree as the help page suggests.
All methods give me the error:
"Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :   line 2 did not have 2 elements".
This seems to result from the fact that the code for priorPosterior( ) reads the tree as a table:
 s <- utils::read.table(inputTree, row.names = 1)[, 2]
 s <- strsplit(as.character(s), "'")[[1]]

But of course, the tree is not a table.
While I know it would be best to be able to provide the trace file too for troubleshooting, I will say that there seem to be no issues with the trace being read as an MCMC object, or with just directing priorPosterior() to the trace filepath.
Thanks!
calibration_topo.trees
Reply all
Reply to author
Forward
0 new messages