WIP: Exploring how (and when) PCA patterns recapitulate geographical history of populations, inspired by this figure by Novembre et al. (2008).
Novembre et al., 2008
library(slendr)init_env()library(admixr)library(cowplot)source("files/popgen/popgen_utils.R")model <-landscape_model(rate =0.3, Ne =10000)# pdf("exercise5.pdf", width = 8, height = 5)# for (n in c(50, 25, 10, 5, 2, 1)) { n <-10 schedule <-landscape_sampling(model, n) ts <-msprime(model, samples = schedule, sequence_length =20e6, recombination_rate =1e-8) %>%ts_mutate(1e-8)
Warning: The `samples =` argument is now deprecated in favor of `schedule =`
to avoid frequent clumsiness in downstream statistical code.
Your code will keep working for the foreseeable future but when
you get a chance, please update it accordingly.
Warning: The `samples =` argument is now deprecated in favor of `schedule =`
to avoid frequent clumsiness in downstream statistical code.
Your code will keep working for the foreseeable future but when
you get a chance, please update it accordingly.
ts_eigenstrat(ts, "files/popgen/spatial_pca2")
1076 multiallelic sites (0.424% out of 253526 total) detected and removed
EIGENSTRAT object
=================
components:
ind file: files/popgen/spatial_pca2.ind
snp file: files/popgen/spatial_pca2.snp
geno file: files/popgen/spatial_pca2.geno
read_ind(eigenstrat("files/popgen/spatial_pca2"))
# A tibble: 455 × 3
id sex label
<chr> <chr> <chr>
1 p1_1 U p1_1
2 p1_2 U p1_2
3 p1_3 U p1_3
4 p1_4 U p1_4
5 p1_5 U p1_5
6 p1_6 U p1_6
7 p1_7 U p1_7
8 p1_8 U p1_8
9 p1_9 U p1_9
10 p1_10 U p1_10
# ℹ 445 more rows