mauricer demo

Richèl J.C. Bilderbeek

2020-08-07

Introduction

mauricer is an R package to handle BEAST2 package management from R, similar to the BEAST2 package manager.

The BEAST2 package manager

The BEAST2 package manager

In this vignette, we will:

To do so, we’ll need to load mauricer. We’ll also load testthat for testing:

library(mauricer)
#> Loading required package: beastier
library(testthat)

To install BEAST2 packages, one needs

If there is no internet connection, or if BEAST2 is not installed, this vignette will be close to empty.

if (!curl::has_internet()) {
  print("No internet connection")
}
if (!beastier::is_beast2_installed()) {
  print("No BEAST2 installed")
}

List all BEAST2 packages

Use get_beast2_pkg_names to get a data frame with the name, version and install status of all BEAST2 packages:

if (curl::has_internet() && beastier::is_beast2_installed()) {
  beast2_packages <- get_beast2_pkg_names()
  knitr::kable(head(beast2_packages))
}
name installed_version latest_version dependencies description
BEAST 2.6.2 2.6.3 BEAST package
Babel NA 0.3.1 BEASTLabs BABEL = BEAST analysis backing effective linguistics
bacter NA 2.2.3 Bacterial ARG inference.
BADTRIP NA 1.0.0 Infer transmission time for non-haplotype data and epi data
BASTA NA 3.0.1 Bayesian structured coalescent approximation
bdmm NA 1.0 MASTER, MultiTypeTree Multitype birth-death model (aka birth-death-migration model)

Install the first non-installed BEAST2 package

Find a package that is not installed:

if (curl::has_internet() && beastier::is_beast2_installed()) {
  package_name <- beast2_packages[
    beast2_packages$installed_version == "NA",
  ]$name[1]
  print(package_name)
}
#> [1] "Babel"

Install that package:

if (curl::has_internet() && beastier::is_beast2_installed()) {
  install_beast2_pkg(package_name)
}

Verify the BEAST2 package is indeed installed

Use is_beast2_pkg_installed:

if (curl::has_internet() && beastier::is_beast2_installed()) {
  expect_true(is_beast2_pkg_installed(package_name))
}

Uninstall the BEAST2 package

Use uninstall_beast2_pkg:

if (curl::has_internet() && beastier::is_beast2_installed()) {
  uninstall_beast2_pkg(package_name)
}