This repository contains matrices simulated by @OReilly2016 using the HKY85 model from a 75-leaf reference tree (orReferenceTree), containing 100, 350 and 1000 discrete characters.

This document details a protocol for analysing these matrices using the Mk model and under parsimony, in order to generate optimal trees that can be compared to the generative tree. These analyses are the subject of @Smith2019.

Initial configuration

The files required to reproduce these analyses are included in the R package directory on installation, and can be downloaded from Github.

If you have RStudio, you can open the R Markdown file used to generate this document (vignettes/Conduct-analyses.Rmd) to run the R scripts that will copy all necessary files and begin analyses on your behalf.

You will need to specify some paths for automatic downloading:

# Directory in which to install MrBayes
BAYES_DIR <- "C:/Research/MrBayes"

# Directory in which to conduct parsimony analysis
HOME <- "C:/Research/oreilly" # Must not end in a trailing '/'

# GitHub remote
INST_ROOT <- "https://raw.githubusercontent.com/ms609/OReillyEtAl2016/master/inst/"

Bayesian analysis

bayesgen.pl — Generate MrBayes files

A Perl script to execute analysis using Markov models in MrBayes.

The script reads the datasets of O'Reilly et al. [-@OReilly2016], appends a MrBayes block to the Nexus files, and executes a MrBayes run, saving the consensus trees and preparing them for analysis in R.

Before running the script:

MRBAYES_RELEASE <- "https://github.com/NBISweden/MrBayes/releases/download/v3.2.6/MrBayes-3.2.6_WIN32_x64.zip"
zipFile <- tempfile(fileext='.zip')
download.file(MRBAYES_RELEASE, destfile=zipFile, method='auto', mode='wb')
unzip(zipFile, c('MrBayes/mrbayes_x64.exe', 'MrBayes/mrbayes_x86.exe'), 
      exdir=BAYES_DIR, junkpaths=TRUE)
file.remove(zipFile)
tempFile <- tempfile(fileext='.zip')
download.file("https://datadryad.org/bitstream/handle/10255/dryad.112089/oreilly2016matrices.zip", tempFile)
unzip(tempFile, exdir=paste0(HOME, '/Matrices'))
file.remove(tempFile)
download.file(paste0(INST_ROOT, "analysis-bayesian/mrbayesblock.nex"),
              paste0(HOME, '/Matrices/mrbayesblock.nex'))

bayesGenPath <- paste0(BAYES_DIR, '/bayesgen.pl')
download.file(paste0(INST_ROOT, "analysis-bayesian/bayesgen.pl"), bayesGenPath)
bayesGen <- readLines(bayesGenPath)
bayesGen[5] <- paste0('$dir = "', HOME, '/Matrices";')
bayesGen[6] <- paste0('$bayes_dir = "', BAYES_DIR, '";')
writeLines(bayesGen, bayesGenPath)

t2nexPath <- paste0(BAYES_DIR, '/t2nex.pl')
download.file(paste0(INST_ROOT, "analysis-bayesian/t2nex.pl"), t2nexPath)
t2nex <- readLines(t2nexPath)
t2nex[2] <- paste0('$dir = "', HOME, '/Matrices";')
writeLines(t2nex, t2nexPath)

Parsimony analysis

mptgen.pl — Generate parsimony trees in TNT

A Perl script to generate most parsimonious trees by parsimony search in TNT.

The script generates TNT scripts to perform parsimony analysis on each of the O'Reilly et al. datasets, under equal and implied weights, with and without suboptimal trees. It then executes these scripts and converts the output into a format suitable for analysis in R.

Before running the script, you'll need an installation of Perl. Strawberry Perl works on MS Windows.

Then:

N_CHAR <- c(100, 350, 1000)
sapply(paste0(HOME, '/', c('', 'Matrices', 'Trees')), dir.create)
sapply(N_CHAR, function (nChar) 
  sapply(paste0(HOME, '/Trees/', 
                c('eq', 'k2', 'k3', 'k5', 'k10', 'k20', 'k200'),
                '.', nChar), dir.create, showWarnings=FALSE))
zipFile <- paste0(HOME, '/TNT.ZIP')
# This is the Windows path; use the appropriate path for your operating system
download.file("http://www.lillo.org.ar/phylogeny/tnt/ZIPCHTNT.ZIP", 
              destfile=zipFile, method='auto', mode='wb')
unzip(zipFile, 'tnt.exe', exdir=HOME)
file.remove(zipFile)
tnt2nexPath <-  paste0(HOME, '/tnt2nex.pl')
mptgenPath <-  paste0(HOME, '/mptgen.pl')

download.file(paste0(INST_ROOT, "analysis-parsimony/tnt2nex.pl"), tnt2nexPath)
tnt2nex <- readLines(tnt2nexPath)
tnt2nex[3] <- paste0('$dir = "', HOME, '";')
writeLines(tnt2nex, tnt2nexPath)

download.file(paste0(INST_ROOT, "analysis-parsimony/mptgen.pl"), mptgenPath)
mptgen <- readLines(mptgenPath)
mptgen[3] <- paste0('$dir = "', HOME, '";')
writeLines(mptgen, mptgenPath)
download.file(paste0(INST_ROOT, "analysis-parsimony/tnt_template.run"), 
              paste0(HOME, '/tnt_template.run'))
tempFile <- tempfile(fileext='.zip')
download.file("https://datadryad.org/bitstream/handle/10255/dryad.112089/oreilly2016matrices.zip", tempFile)
unzip(tempFile, exdir=paste0(HOME, '/Matrices'))
## Optionally: 
file.remove(tempFile)

Data analysis

Once the data have been generated, they can be analysed using [https://github.com/ms609/OReillyEtAl2016/blob/master/data-raw/GenerateData.Rmd].

References



ms609/OReillyEtAl2016 documentation built on March 3, 2024, 1:18 p.m.