https://github.com/4ment/skyplotr
https://github.com/4ment/skyplotr
beast coalescent ggplot2 mcmc visualization
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/4ment/skyplotr
- Owner: 4ment
- License: gpl-3.0
- Created: 2024-03-07T23:51:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-21T01:32:59.000Z (over 1 year ago)
- Last Synced: 2025-09-08T21:44:29.353Z (9 months ago)
- Topics: beast, coalescent, ggplot2, mcmc, visualization
- Language: R
- Homepage:
- Size: 715 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# skyplotr
[](https://www.gnu.org/licenses/gpl-3.0)
### Overview
**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.
### Installation
* Install the latest development version from GitHub (requires [devtools](https://github.com/hadley/devtools) package):
```r
devtools::install_github("4ment/skyplotr")
```
### Example
`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.
```r
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")
```
