andrewparkermorgan / popcorn

MIT License
6 stars 0 forks source link

popcorn

A lightweight parser for various file formats produced by software used for population genetic analyses, plus a handufl of plotting utilities. The package makes use of tools from the tidyverse and generally tries to respect their idioms and vernacular.

Documentation is a work in progress.

Includes parsers for these formats, among others:

Credits

This package borrows internal functions from at least the following packages:

Examples

Suppose we ran ADIXTURE with $K = 3$ and bootstrap standard errors turned on like so:

$> admixture -B test.bed 3

We obtain these output files:

$> ls test*
test.3.Q   test.3.Q_bias   test.3.Q_se   test.3.P

The code below reads the result and makes the typical barplot of individual admixture proportions.

library(popcorn)
library(ggplot2)

pops <- read_fam("test.fam")
Q <- read_Q_matrix("test.3.Q")
so <- sort_by_cluster(Q)
QQ <- tidy(Q, pops)

plot_admixture(QQ, label = TRUE, sort.order = so)