I am new to bioinformatics, but have been using R for some time. I'd like to use R to run some phylogentic analysis, specifically I want to call Mr. Bayes through the mrbayes()
wrapper in the ips
package written and maintained by Christoph Heibl to make reproducible results and easily manageable scripts (for me). I have downloaded the .exe and can work through/interpret tutorial examples with the Mr. Bayes interface. However, when I make block code in R and attempt to run the MCMCs I get an error. How can I get R to properly call Mr. Bayes and allow me to run the MCMCs from within R? See below for my attempt, mostly lifted from the CRAN ips
vignette.
# get some data included in the ips package
data(ips.cox1)
# truncate the seqences for a quick analysis
ips <- ips.cox1[, 100:140]
# set the working directory to the .exe location
setwd("C:/Users/Gregory/Programs/MrBayes/")
# set parameters, create the Mr. Bayes block code, and run the MCMCs
mrbayes(ips, file = "", ngen = 100, run = TRUE)
###NEXUS
###[created by ips on Wed Feb 08 14:57:29 2017]
###begin data;
###dimensions ntax=26 nchar=41;
###format datatype=dna missing=N gap=-;
### matrix
###Ips_avulsus ctcttagggtttgtagtttgagctcaccacatatttacagt
###Ips_confusus cttctaggctttgtagtatgagcccaccatatattcacagt
###Ips_cribricollis ttattaggatttgtagtatgagcccatcatatattcacagt
###Ips_borealis cttctaggttttgtagtttgagctcatcatatatttacagt
###Ips_pilifrons cttctaggttttgtagtttgagctcatcatatatttacagt
###Ips_nitidus cttttaggatttgtagtatgagcccaccatatatttacagt
###Ips_sexdentatus cttttaggttttgtagtttgagctcaccatatatttaccgt
###Ips_hoppingi cttctaggctttgtagtatgagcccaccatatattcacagt
###Ips_perturbatus cttctaggttttgtagtttgagctcaccatatatttacagt
###Ips_acuminatus cttttaggatttgtggtctgagcacaccacatattcacagt
###Ips_apache ctacttggatttgtagtctgagctcaccatatattcacagt
###Ips_bonanseai cttttaggatttgtcgtgtgagctcatcatatattcacagt
###Ips_cembrae nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
###Ips_duplicatus agattttggcttcttcccccctctctagccctccttatcat
###Ips_typographus cttttaggatttgtagtatgagctcaccatatatttacagt
###Ips_hunteri cttctaggttttgtagtttgagctcaccatatatttacagt
###Ips_shangrila ctcttaggtttcgtagtttgagctcatcatatatttacagt
###Ips_subelongatus cttttaggcttcgttgtatgagcacatcatatatttacagt
###Ips_tridens cttctaggttttgtagtttgagctcatcatatatttacagt
###Ips_amitinus cttttaggatttgtagtatgagctcaccatatatttaccgt
###Orthotomicus_mannsfeldi nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
###Orthotomicus_suturalis ttattaggatttgtagtttgagctcaccacatatttactat
###Orthotomicus_proximus ctactaggcttcgtagtgtgagcccaccacatattcactgt
###Orthotomicus_erosus cttctgggtttcgtggtgtgggctcaccacatattcaccgt
###Pityogenes_bistridentatus cttctaggatttgtagtttgagcacatcatatatttactat
###Pityogenes_trepanatus ttactaggatttgttgtttgagcccaccatatattcacaat
###;
###end;
###begin mrbayes;
###lset nst=6 rates=invgamma ngammacat=4;
###mcmc nruns=2 ngen=100 printfreq=100 samplefreq=10 nchains=4 savebrlens=yes temp=0.2;
###sumt filename= burnin=10 contype=allcompat;
###end;
###Error in file(file, "r") : cannot open the connection
###In addition: Warning messages:
###1: running command 'mrbayes .bayes' had status 127
###2: In file(file, "r") :
### cannot open file '.con.tre': No such file or directory
I do not know how to interpret the last few lines here. The NEXUS file seems to be made correctly, with all parameters set mostly to default values. I'm not sure what the file "r" is nor what status 127 is. The consensus tree cannot be called because it hasn't been made presumably.
Is mrbayes correctly installed = in your PATH variable?
I'm not sure - my suspicion is that R wasn't calling Mr. Bayes properly. How can a check this? And, perhaps more importantly, how can I fix this?
I know it is not an answer, but don't run MrBayes on your local machine, except if it is a beast (ho ho). Use CIPRES supercluster which runs MrBayes on 8 cores. It is much faster and cheaper. There is no reason to not use it. The support is excellent and answers within the hour, sometimes.
Those errors look like python code to me. "r" means you open the file for reading. The software cannot find a file
.con.tre
, which is a rather strange name. Are you sure that the file argument in this line:mrbayes(ips, file = "", ngen = 100, run = TRUE)
has to be empty?UPDATE: the file argument must be included if
run = TRUE
because the function calls the NEXUS file named viafile =
to run the MCMCs.OLD: My understanding is that it does not not have to be empty, but it is empty in the vignette. If I include a
file =
name then the block code (parameters and data NEXUS file) are stored as that file name in my directory, which I can successfully view afterwards. However, after the file is written the same error occurs when attempting the MCMCs.