Skip to content

Commit

Permalink
Run article code as vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Feb 21, 2018
1 parent 692d16a commit 292fbea
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ tests/testthat/Rplots.pdf
vignettes/examples_cache/
vignettes/examples_files/
vignettes/*.fas
vignettes/article_cache/
122 changes: 122 additions & 0 deletions vignettes/article.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
title: "rbeast2: BEAUti 2, BEAST2 and Tracer for R"
author: "Richel J.C. Bilderbeek"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{rbeast2: BEAUti 2, BEAST2 and Tracer for R}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r create_files, include = FALSE}
file.copy(rbeast2::get_path("anthus_aco.fas"), "test_output_0.fas")
file.copy(rbeast2::get_path("anthus_aco.fas"), "my_fasta.fas")
file.copy(rbeast2::get_path("anthus_aco.fas"), "my_alignment.fas")
file.copy(rbeast2::get_path("anthus_aco.fas"), "anthus_aco.fas")
file.copy(rbeast2::get_path("anthus_nd2.fas"), "anthus_nd2.fas")
```

This vignette does the same as the code in the article.

```{r}
library(rbeast2)
mcmc <- create_mcmc(chain_length = 2000, store_every = 1000)
```

```{r cache=TRUE}
out <- run_beast2("anthus_aco.fas", mcmc = mcmc)
```


```{r cache=TRUE}
out <- run_beast2(
"anthus_aco.fas",
site_models = create_hky_site_model(),
clock_models = create_rln_clock_model(),
tree_priors = create_bd_tree_prior(),
mcmc = mcmc
)
```


```{r cache=TRUE}
out <- run_beast2(
c("anthus_aco.fas", "anthus_nd2.fas"),
site_models = list(
create_tn93_site_model(),
create_gtr_site_model()
),
mcmc = mcmc
)
```

```{r cache=TRUE}
out <- run_beast2(
"anthus_aco.fas",
tree_priors = create_yule_tree_prior(
birth_rate_distr = create_exp_distr()
),
mcmc = mcmc
)
```

```{r cache=TRUE}
out <- run_beast2(
"anthus_aco.fas",
tree_priors = create_yule_tree_prior(
birth_rate_distr = create_exp_distr(
mean = create_mean_param(value = 1.0)
)
),
mcmc = mcmc
)
```

```{r cache=TRUE}
out <- run_beast2(
"anthus_aco.fas",
posterior_crown_age = 15,
mcmc = mcmc
)
```


```{r}
traces <- remove_burn_ins(out$estimates)
```


```{r}
esses <- calc_esses(
traces,
sample_interval = 1000
)
```

```{r}
sum_stats <- calc_summary_stats(
traces,
sample_interval = 1000
)
```


```{r cache=TRUE}
plot_densitree(out$anthus_aco_trees)
```

```{r cleanup, include = FALSE}
file.remove("test_output_0.fas")
file.remove("my_fasta.fas")
file.remove("my_alignment.fas")
file.remove("anthus_aco.fas")
file.remove("anthus_nd2.fas")
```

0 comments on commit 292fbea

Please sign in to comment.