Estimate joint allele frequency spectrum
joint_spectrum(afs)
A matrix or data frame of allele frequencies
A data frame with columns pattern
and proportion
if (FALSE) {
dat = plink_to_afs('/my/plink/file', pops = c('pop1', 'pop2', 'pop3', 'pop4', 'pop5'))
# Spectrum across all SNPs
joint_spectrum(dat$afs)
# Stratify by allele frequency in one population
dat$afs %>% as_tibble %>% select(1:4) %>%
group_by(grp = cut(pop1, 10)) %>%
group_modify(joint_spectrum) %>%
ungroup
# Stratify by mutation class
dat$afs %>% as_tibble %>% select(1:4) %>%
mutate(mut = paste(dat$snpfile$A1, dat$snpfile$A2)) %>%
group_by(mut) %>%
group_modify(joint_spectrum) %>%
ungroup
}