skyplotr is an R package providing functions for plotting the population size trajectory across time. The plots created by skyplotr are ggplot objects, which means that after a plot is created it can be further customized using various functions from the ggplot2 package.
- Install the latest development version from GitHub (requires devtools package):
devtools::install_github("4ment/skyplotr")
HCV.tsv
contains 1000 MCMC samples obtained from BEAST. This analysis involves a nucleotide alignment of Hepatitis C Virus (HCV), utilizing the piecewise-constant coalescent model (aka skygrid). This model comprises 75 epochs with a cutoff set at 400.
library(dplyr)
library(ggplot2)
library(skyplotr)
samples <- read.csv("data-raw/HCV-skygrid.tsv", sep = "\t")
root_height <- samples$treeModel.rootHeight
log_pop_size <- select(samples, starts_with("skygrid.logPopSize"))
cutoff <- samples$skygrid.cutOff[1]
skygrid <- prepare_skygrid(root_height, log_pop_size, cutoff, age_of_youngest=1994)
skygrid <- mutate(skygrid, across(all_of(c("trajectory", "trajectory_low", "trajectory_high"))), exp)
plot_title <- ggtitle("Population size trajectory",
"with median and 95% intervals")
skyplot(skygrid, fill="darkcyan") + plot_title + ylab("Effective population size")