knitr::opts_chunk$set(echo = TRUE) library(tidyverse) library(adegenet)
Utilities for tidy population genetics analysis in R
remotes::install_github("chollenbeck/pantomime")
library(pantomime) library(related) data(nancycats) # From adegenet # Extract allele frequencies from a genind object cats1 <- nancycats[pop = 1] df <- get_allele_freqs(cats1) head(df)
Get locus-by-locus statistics:
cat_stats <- get_locus_stats(cats1, hwe_test = TRUE) cat_stats
Get locus diversity statistics:
cat_div <- get_locus_diversity(cats1) cat_div
Run a quick PCA of the data
pca_tbl <- qpca(cats1) ggplot(pca_tbl, aes(x = Axis1, y = Axis2, col = pop)) + geom_point()
# Calculate relatedness from a genind object rel <- genind2related(cats1) coanc <- coancestry(genotype.data = rel$gdata, ritland = 1) # From the 'related' package # Convert to tibble rel_tbl <- coanc$relatedness %>% as_tibble() head(rel_tbl)
Quickly visualize the distribution of Ritland relatedness coefficients:
ggplot(rel_tbl, aes(x = ritland)) + geom_histogram()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.