LEA for microsatellite data

#Load LEA Libraries

library(LEA)
library(vcfR)
library(RColorBrewer)
library(adegenet)
#library(ape)
library(tidyverse)
## Warning in system("timedatectl", intern = TRUE): running command 'timedatectl'
## had status 1
library(here)
library(dplyr)
library(ggplot2)
library(colorout)
library(extrafont)
#library(scales)
library(stringr)
library(ggtext)

1. Use LEA for PCAs for all 1252 individuals in the microsat dataset

Import data for all 1252 individuals in the microsat dataset

Convert format (just matrix)

struct2geno("output/europe/lea/microsats/all_pops_microsat_matrix.str", ploidy=2, FORMAT=1)
## Input file in the STRUCTURE format. The genotypic matrix has 1252 individuals and 11 markers. 
## The number of extra rows is 0 and the number of extra columns is 0 .
## Missing alleles are encoded as -9 , converted as 9.
## Output files: output/europe/lea/microsats/all_pops_microsat_matrix.str.geno  .lfmm.

Convert format (with header and pop info)

struct2geno("output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str", ploidy=2, FORMAT=1, extra.row=1, extra.column=3)
## Input file in the STRUCTURE format. The genotypic matrix has 1252 individuals and 11 markers. 
## The number of extra rows is 1 and the number of extra columns is 3 .
## Missing alleles are encoded as -9 , converted as 9.
## Output files: output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.geno  .lfmm.

Check

a<-read.lfmm("output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.lfmm")
b<-read.geno("output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.geno")

PCA with LEA

#Create pca 

pc=pca("output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.lfmm", K=78, scale=TRUE) #set K to # of pops, with scaling
## [1] "******************************"
## [1] " Principal Component Analysis "
## [1] "******************************"
## summary of the options:
## 
##         -n (number of individuals)          1252
##         -L (number of loci)                 189
##         -K (number of principal components) 78
##         -x (genotype file)                  /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.lfmm
##         -a (eigenvalue file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -e (eigenvector file)               /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvectors
##         -d (standard deviation file)        /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.sdev
##         -p (projection file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.projections
##         -s data centered and scaled

The geno & lmff formats count the total # of different alleles (189 over the all 11 loci) and make a separate column for each one.

Test

# PC significant test: tracy-widom test
tw <- tracy.widom(pc)
## [1] "*******************"
## [1] " Tracy-Widom tests "
## [1] "*******************"
## summary of the options:
## 
##         -n (number of eigenvalues)          1252
##         -i (input file)                     /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -o (output file)                    /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.tracywidom
# plot the percentage of variance explained by each component
plot(tw$percentage, pch = 19, col = "blue", cex = .8)

Test

#increase K to see if its really leveling off
pc5=pca("output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.lfmm", K=100, scale=TRUE)
## [1] "******************************"
## [1] " Principal Component Analysis "
## [1] "******************************"
## summary of the options:
## 
##         -n (number of individuals)          1252
##         -L (number of loci)                 189
##         -K (number of principal components) 100
##         -x (genotype file)                  /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.lfmm
##         -a (eigenvalue file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -e (eigenvector file)               /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvectors
##         -d (standard deviation file)        /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.sdev
##         -p (projection file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.projections
##         -s data centered and scaled
# PC significant test: tracy-widom test
tw2 <- tracy.widom(pc5)
## [1] "*******************"
## [1] " Tracy-Widom tests "
## [1] "*******************"
## summary of the options:
## 
##         -n (number of eigenvalues)          1252
##         -i (input file)                     /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -o (output file)                    /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.tracywidom
# plot the percentage of variance explained by each component
plot(tw2$percentage, pch = 19, col = "blue", cex = .8)

pops_inds<-read.delim("output/europe/lea/microsats/pops_inds.txt")
pops <- as.factor(pops_inds$pops)
inds <- as.factor(pops_inds$inds)

Get values

# plot preparation
pc.coord <- as.data.frame(pc$projections)
colnames(pc.coord) <- paste0("PC", 1:78)
pc.coord$Individual <- inds
pc.coord$Population <- pops
# perc1 <- paste0(round(tw$percentage, digits = 3) * 100, "%")
perc <- paste0(round(pc$eigenvalues/sum(pc$eigenvalues), digits = 3) * 100, "%")
nb.cols <- 40
mycolors <- colorRampPalette(brewer.pal(8, "Set2"))(nb.cols)

Check R symbols for plot

#to see all shapes -> plot shapes - para escolher os simbolos
N = 100; M = 1000
good.shapes = c(1:25,33:127)
foo = data.frame( x = rnorm(M), y = rnorm(M), s = factor( sample(1:N, M, replace = TRUE) ) )
ggplot(aes(x,y,shape=s ), data=foo ) +
  scale_shape_manual(values=good.shapes[1:N]) +
  geom_point()

1.1. Get location info

sampling_loc <- readRDS(here("output/europe/lea/microsats/sampling_loc_euro_microsats.rds"))
head(sampling_loc)
##        Pop_City    Country   Latitude Longitude Continent Abbreviation Year
## 1         Limbe   Cameroon   4.023252  9.194771    Africa          LIB 2018
## 2     Morondava Madagascar -20.284200 44.279400    Africa          MAD 2016
## 3 Trois-Bassins    Reunion -21.109008 55.319206    Africa          TRO 2017
## 4       Dauguet  Mauritius -20.185300 57.521540    Africa          DAU 2022
## 5   Franceville      Gabon  -1.592070 13.532420    Africa          GAB 2015
## 6  Antananarivo Madagascar -18.879200 47.507900    Africa          ANT 2022
##           Region    Subregion order order2 orderold order_microsat microsats
## 1    West Africa       Africa    79     73       71             NA          
## 2    East Africa  East Africa    80     78       72             NA          
## 3   Indian Ocean Indian Ocean    81     81       73             NA          
## 4   Indian Ocean Indian Ocean    82     80       74             NA          
## 5 Central Africa       Africa    NA     72       NA             NA          
## 6    East Africa  East Africa    NA     76       NA             NA          
##   microsat_code alt_code  X  Country.1
## 1                        NA   Cameroon
## 2                        NA Madagascar
## 3                        NA    Reunion
## 4                        NA  Mauritius
## 5                        NA      Gabon
## 6                        NA Madagascar

Check pops

head(pc.coord$Population)
## [1] POP POP POP POP POP POP
## 78 Levels: ABAL ABSU ALD BUL CRO ESAB ESAC ESAG ESAL ESAY ESAZ ESBA ... TUH
#Check how many sampling localities
length(unique(pc.coord$Population))
## [1] 78

Check the regions

unique(sampling_loc$Region)
##  [1] "West Africa"     "East Africa"     "Indian Ocean"    "Central Africa" 
##  [5] "North Africa"    "North America"   "South America"   "Caribbean"      
##  [9] "East Asia"       "South Asia"      "Southeast Asia"  "Western Europe" 
## [13] "Southern Europe" "Eastern Europe"

Merge

merged_data <- merge(pc.coord, sampling_loc, by.x = "Population", by.y = "microsat_code")
## Warning in merge.data.frame(pc.coord, sampling_loc, by.x = "Population", :
## column names 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA',
## 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA' are duplicated in the
## result
head(merged_data)
##   Population         PC1       PC2        PC3       PC4     PC5      PC6
## 1       ABAL  0.00877431  1.369000 -0.1963400  0.250702 1.62377 0.449157
## 2       ABAL  2.58326000 -0.534200 -0.8467370 -3.134550 3.80737 1.725370
## 3       ABAL  0.85719000  0.643177 -0.1917340 -0.892656 2.64961 1.186340
## 4       ABAL -0.79535300 -0.251846 -0.0382649 -0.568964 1.62680 2.183020
## 5       ABAL -1.32405000  0.937741  0.6562720 -1.492850 1.23191 0.487348
## 6       ABAL -0.64127300  0.669102  0.4226620 -1.033730 1.49660 2.753390
##          PC7     PC8      PC9      PC10      PC11      PC12       PC13
## 1 -1.4439800 3.18513 0.639383 -1.144890 -1.429850  0.268293  0.8540540
## 2 -0.0215363 1.48119 9.450510 -2.007680 -4.867440 -0.446848  2.1329700
## 3 -2.5275200 5.27012 1.058880 -1.758050 -0.115702 -0.424934  0.3468560
## 4 -1.0005700 3.91958 1.293410 -0.574913 -0.317308  0.665134 -0.0179021
## 5 -0.1707220 1.26975 0.566264 -0.101184  0.138659 -0.182283  0.1573160
## 6 -1.6295400 3.71448 1.135530 -0.123937 -1.120620  0.790370  0.0802469
##        PC14      PC15      PC16      PC17      PC18       PC19      PC20
## 1 -0.293709 -1.230810  1.010810 -0.157491 -0.726088  0.0639361  0.251697
## 2 -3.091870 -3.060240 -7.472890 -1.119550  3.256520 -3.6018700  3.196100
## 3  0.165261 -0.476984 -0.613023 -1.115810 -0.803804  1.0436700  0.415681
## 4  0.547252 -1.656470  0.447462 -0.834954 -0.114963  1.8961400 -0.745853
## 5  0.734877 -0.869944  0.568171  1.053670 -0.473343  0.3189150 -0.254249
## 6  0.539670 -1.433180  1.082920 -0.654920 -0.657009  1.6471100 -2.056800
##        PC21       PC22      PC23       PC24      PC25      PC26       PC27
## 1 -0.127457 -1.5787900 -1.633910  0.1135310  0.501012 -0.677803 -0.0826617
## 2  3.416100  5.8827700 -1.993150 -3.4772100  3.386940 -1.253700  1.7784900
## 3 -0.244480 -1.7157400 -0.115025  0.6313840 -0.390972 -0.756339 -0.6411740
## 4 -0.613082  1.7817800  0.585116  0.0635944 -0.270778 -0.684693 -0.5296060
## 5  0.329502  2.0224000  0.812384 -0.0823769 -0.232288  0.225702 -0.0131700
## 6  0.254216 -0.0726163 -0.548757 -0.4733940 -1.384820 -0.397474  0.3885180
##         PC28      PC29       PC30      PC31      PC32       PC33       PC34
## 1  0.1000000  0.872799  0.1465980  0.649881  0.676590 -0.2071850  1.2283200
## 2 16.8056000 -3.959400  3.5369200 -3.076640 -3.982950  6.4364700 -4.0308800
## 3  0.0325239  0.878260 -0.0279853  0.272108  0.323691 -0.8692700 -0.0186884
## 4 -1.4680800  0.144564 -0.4091330  1.149630  1.136310 -0.9468010  0.4008170
## 5  0.2701460 -0.210177 -0.4702910 -0.225658  0.632686 -0.0434382  0.3331060
## 6 -0.2836400  1.226500 -0.2648440  1.015860  1.890200 -0.0613228  1.4776800
##        PC35      PC36      PC37       PC38      PC39      PC40      PC41
## 1 -2.113270 -0.390546  0.842062  1.0071400  1.178250  1.740850 -1.801970
## 2  5.561160  7.245600 -0.955977  1.8762000 -1.572310  1.642960  3.464600
## 3 -1.640670  0.587437  1.109410  1.5649500  1.033160  1.791890 -1.718900
## 4  0.463482  1.195330  2.246880  0.3656200 -0.506198  0.390102 -1.514620
## 5  0.878389  0.579588 -0.854790 -1.1016600 -1.079150 -1.062300  0.012638
## 6 -0.365265 -0.474052  0.756435 -0.0521233  0.959838  1.523970 -2.377970
##         PC42       PC43      PC44      PC45       PC46       PC47      PC48
## 1  0.0931708  0.7808960 -0.764832  0.324547 -0.4491130  0.7332000  1.233840
## 2  3.3276700 -2.5114600  6.607870 -5.463590  2.8344700 -1.4699700 -4.495540
## 3 -0.1611600 -0.3299160  0.100039 -0.100326 -0.0453126  1.0274700  0.901167
## 4 -1.2648200 -0.6656900 -0.480363 -0.399876 -0.7688140  0.0470733 -0.588436
## 5 -0.4214150  0.0238734  0.417468 -0.112449 -0.7981270 -1.2345200  0.196669
## 6 -0.6192670  0.3287100  1.389990 -0.542025 -1.7835900 -0.5393400  1.001920
##         PC49       PC50      PC51      PC52      PC53      PC54      PC55
## 1  0.3578760  0.6283360 -0.987798  0.484021 -1.620680 -0.194371  0.727974
## 2  0.0928247  1.2025600 -1.045430  5.164070  2.905660  0.938694 -0.628388
## 3 -0.6008610  0.3584080 -1.421970  0.135223 -2.438100 -0.126534  0.410990
## 4  0.6643640 -1.4847900 -0.476990 -0.377353 -0.803324 -0.237162 -0.821483
## 5  0.1295300  0.0501132 -0.181209 -0.162336  1.049550 -0.233240  0.981160
## 6  0.6847880 -1.9384000 -2.003610  1.859110 -2.175790 -1.124730  0.100910
##       PC56     PC57       PC58      PC59      PC60      PC61     PC62     PC63
## 1 0.293104 0.789918  1.0209200 -0.152347  1.249040  1.653820 0.169561 1.003450
## 2 1.916570 1.907160 -5.5803200 -2.381090 -1.487140 -1.637800 2.270710 4.315540
## 3 1.515370 0.958955  1.1191200 -0.294594  2.624660  0.229858 0.699524 0.521780
## 4 0.199009 0.646122  0.4735240 -1.575360  1.064110  0.987734 0.697924 0.364850
## 5 0.160839 0.136296  0.0178381 -0.700309 -0.116476 -0.377859 0.319015 0.581316
## 6 1.832880 0.993754  0.8343680 -1.676290  2.985440  0.280545 2.344050 1.551440
##        PC64       PC65      PC66      PC67       PC68      PC69       PC70
## 1 -0.827881 -0.2910710  0.615686  1.266050 -0.9911900 -1.303600 -1.5468200
## 2 -0.576342 -4.0132200  1.834790 -1.014590 -2.9709200 -2.466260 -2.0624900
## 3 -1.851480 -0.7058170  0.842489  0.507936  0.5103700 -0.950021 -0.5329190
## 4 -0.208167 -0.0273355 -0.224265  1.293310  0.3442410 -0.359308 -0.4339610
## 5  0.954906 -0.3521100 -0.466012  0.244793  0.0583201  0.754122  0.8448450
## 6 -0.365973 -0.4350440 -0.271286  1.298230  1.0547100 -1.299040 -0.0500293
##         PC71       PC72     PC73       PC74       PC75      PC76      PC77
## 1 -0.0896604  0.0877798 0.359638  0.3253770 -1.3434100 -0.744320  0.934413
## 2 -2.9071400  5.0530200 3.162850  4.1457000 -4.6777200  0.958086  2.051830
## 3 -0.0409303 -1.1691400 0.511829 -0.0768091  0.0098582 -1.468020  0.298208
## 4  1.2723400 -1.2489500 1.331020  0.0567503  0.2278340 -0.904971  0.138080
## 5 -0.6915800 -0.7444430 0.467130  0.1302500 -0.2079010 -0.469693 -0.859121
## 6 -0.1292010 -0.5881650 0.587161  1.2311200  0.5537720 -2.117880  0.667677
##       PC78         NA        NA         NA         NA         NA        NA
## 1 0.158237  0.6094890  1.639640 -0.3230100 -0.1071940  0.4531520 -0.506315
## 2 2.809170 -3.7451100  2.367100  2.1744600 -1.9577100 -0.5474710  1.706620
## 3 0.278865  0.3059890  1.318650  0.0100375 -0.2367660 -0.1950700 -0.640249
## 4 0.918591 -0.0071644  0.325599 -0.1797980 -0.0384726  0.7400370  0.391723
## 5 0.410215  1.0875600 -0.253908 -0.5796910 -0.9856400  0.3133510  0.500686
## 6 0.816792  0.0202096  0.556907 -0.1332520  0.8276600  0.0428036 -0.970149
##          NA         NA         NA         NA       NA         NA         NA
## 1 -0.651822  0.1734340  0.2338320  0.0825088 0.891726 -2.7632600 -0.1845890
## 2 -3.312840 -0.1765680  3.4487400  3.4500400 1.678550  0.4952220 -0.3307410
## 3  0.285000 -0.3012880 -0.9725250  0.8508640 0.553726 -0.9051990  0.5487200
## 4 -0.487853  0.5659820  0.3375970  1.0073100 0.783500  0.0873463 -1.2243800
## 5  0.610826  0.0130786  0.7010930 -0.3221770 0.126408 -0.8882510  0.0507999
## 6  0.134844 -0.3524970 -0.0550495  1.2426300 0.106922 -1.3703300 -0.2328170
##          NA        NA         NA        NA        NA         NA        NA
## 1  1.030990 -0.371989  0.0360283  0.139100  1.189670 -0.3677630  0.372016
## 2  1.860700  1.200380 -0.7093400 -4.509810 -2.182100  4.1388600  1.824170
## 3 -0.802689 -0.673432 -0.0995038 -0.146875  1.765680 -0.5243150 -0.211918
## 4 -0.811018 -0.994080 -0.4811040  0.934041 -1.720850 -0.5456870 -0.892199
## 5  0.163414 -1.118780  0.1503110 -0.381400 -0.790367  0.0745188 -0.435167
## 6 -0.945040 -0.678831 -0.1374350  0.569430  1.717280 -0.8053680  0.167912
##          NA        NA  Individual Pop_City Country Latitude Longitude Continent
## 1 -1.187940  0.668069 ABAL-ABAL01    Gagra Georgia       NA        NA    Europe
## 2  1.661660 -0.131579 ABAL-ABAL02    Gagra Georgia       NA        NA    Europe
## 3 -1.288060  0.562719 ABAL-ABGL05    Gagra Georgia       NA        NA    Europe
## 4 -0.973319 -0.144043 ABAL-ABIN01    Gagra Georgia       NA        NA    Europe
## 5 -0.230312 -0.372178 ABAL-ABIN02    Gagra Georgia       NA        NA    Europe
## 6 -1.654420  0.358537 ABAL-ABIN06    Gagra Georgia       NA        NA    Europe
##   Abbreviation Year         Region   Subregion order order2 orderold
## 1         <NA>      Eastern Europe East Europe    NA     NA       NA
## 2         <NA>      Eastern Europe East Europe    NA     NA       NA
## 3         <NA>      Eastern Europe East Europe    NA     NA       NA
## 4         <NA>      Eastern Europe East Europe    NA     NA       NA
## 5         <NA>      Eastern Europe East Europe    NA     NA       NA
## 6         <NA>      Eastern Europe East Europe    NA     NA       NA
##   order_microsat microsats alt_code  X Country.1
## 1             93       yes     ABAL NA   Georgia
## 2             93       yes     ABAL NA   Georgia
## 3             93       yes     ABAL NA   Georgia
## 4             93       yes     ABAL NA   Georgia
## 5             93       yes     ABAL NA   Georgia
## 6             93       yes     ABAL NA   Georgia

1.2. Create PCA plots

ggsave(
  here("output/europe/lea/microsats/PCA_lea_microsats_all_pc1_pc2.pdf"
  ),
  width  = 8,
  height = 6,
  units  = "in"
)

PC1 and PC3

ggsave(
  here("output/europe/lea/microsats/PCA_lea_euro_microsats_pc1_pc3.pdf"
  ),
  width  = 8,
  height = 6,
  units  = "in"
)

PC2 and PC3

ggsave(
  here("output/europe/lea/microsats/PCA_lea_euro_microsats_pc2_pc3.pdf"
  ),
  width  = 8,
  height = 6,
  units  = "in"
)

2. Use LEA for PCAs for all 24 pops in the microsat dataset that overlap with SNP datasets

Import data for all 637 individuals in the microsat dataset that overlap

Convert format (just matrix)

struct2geno("output/europe/lea/microsats/overlap/overlap_pops_microsat_matrix.str", ploidy=2, FORMAT=1)
## Input file in the STRUCTURE format. The genotypic matrix has 637 individuals and 11 markers. 
## The number of extra rows is 0 and the number of extra columns is 0 .
## Missing alleles are encoded as -9 , converted as 9.
## Output files: output/europe/lea/microsats/overlap/overlap_pops_microsat_matrix.str.geno  .lfmm.

Convert format (with header and pop info)

struct2geno("output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str", ploidy=2, FORMAT=1, extra.row=1, extra.column=3)
## Input file in the STRUCTURE format. The genotypic matrix has 637 individuals and 11 markers. 
## The number of extra rows is 1 and the number of extra columns is 3 .
## Missing alleles are encoded as -9 , converted as 9.
## Output files: output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.geno  .lfmm.

Check

a<-read.lfmm("output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.lfmm")
b<-read.geno("output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.geno")

PCA with LEA

#Create pca 
pc=pca("output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.lfmm", K=24, scale=TRUE) #set K to # of pops, with scaling
## [1] "******************************"
## [1] " Principal Component Analysis "
## [1] "******************************"
## summary of the options:
## 
##         -n (number of individuals)          637
##         -L (number of loci)                 163
##         -K (number of principal components) 24
##         -x (genotype file)                  /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.lfmm
##         -a (eigenvalue file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -e (eigenvector file)               /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvectors
##         -d (standard deviation file)        /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.sdev
##         -p (projection file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.projections
##         -s data centered and scaled

The geno & lmff formats count the total # of different alleles (189 over the all 11 loci) and make a separate column for each one.

Test

# PC significant test: tracy-widom test
tw <- tracy.widom(pc)
## [1] "*******************"
## [1] " Tracy-Widom tests "
## [1] "*******************"
## summary of the options:
## 
##         -n (number of eigenvalues)          637
##         -i (input file)                     /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -o (output file)                    /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.tracywidom
# plot the percentage of variance explained by each component
plot(tw$percentage, pch = 19, col = "blue", cex = .8)

Test

#increase K to see if its really leveling off
pc5=pca("output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.lfmm", K=100, scale=TRUE)
## [1] "******************************"
## [1] " Principal Component Analysis "
## [1] "******************************"
## summary of the options:
## 
##         -n (number of individuals)          637
##         -L (number of loci)                 163
##         -K (number of principal components) 100
##         -x (genotype file)                  /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.lfmm
##         -a (eigenvalue file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -e (eigenvector file)               /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvectors
##         -d (standard deviation file)        /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.sdev
##         -p (projection file)                /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.projections
##         -s data centered and scaled
# PC significant test: tracy-widom test
tw2 <- tracy.widom(pc5)
## [1] "*******************"
## [1] " Tracy-Widom tests "
## [1] "*******************"
## summary of the options:
## 
##         -n (number of eigenvalues)          637
##         -i (input file)                     /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.eigenvalues
##         -o (output file)                    /gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/lea/microsats/overlap/albo_microsat_structure_format_no_pops.str.pca/albo_microsat_structure_format_no_pops.str.tracywidom
# plot the percentage of variance explained by each component
plot(tw2$percentage, pch = 19, col = "blue", cex = .8)

pops_inds<-read.delim("output/europe/lea/microsats/overlap/pops_inds_overlap.txt")
pops <- as.factor(pops_inds$pops)
inds <- as.factor(pops_inds$inds)

Get values

# plot preparation
pc.coord <- as.data.frame(pc$projections)
colnames(pc.coord) <- paste0("PC", 1:25)
pc.coord$Individual <- inds
pc.coord$Population <- pops
# perc1 <- paste0(round(tw$percentage, digits = 3) * 100, "%")
perc <- paste0(round(pc$eigenvalues/sum(pc$eigenvalues), digits = 3) * 100, "%")
nb.cols <- 40
mycolors <- colorRampPalette(brewer.pal(8, "Set2"))(nb.cols)

Check R symbols for plot

#to see all shapes -> plot shapes - para escolher os simbolos
N = 100; M = 1000
good.shapes = c(1:25,33:127)
foo = data.frame( x = rnorm(M), y = rnorm(M), s = factor( sample(1:N, M, replace = TRUE) ) )
ggplot(aes(x,y,shape=s ), data=foo ) +
  scale_shape_manual(values=good.shapes[1:N]) +
  geom_point()

2.1. Get location info

sampling_loc <- readRDS(here("output/europe/lea/microsats/overlap/sampling_loc_euro_microsats_overlap.rds"))
head(sampling_loc)

Check pops

head(pc.coord$Population)
## [1] FRS FRS FRS FRS FRS FRS
## 24 Levels: ALD BAR BUL CRO FRS GES GRA GRC ITB ITP ITR MAL POP ROS SER ... TUH
#Check how many sampling localities
length(unique(pc.coord$Population))
## [1] 24

Check the regions

unique(sampling_loc$Region)
##  [1] "West Africa"     "East Africa"     "Indian Ocean"    "Central Africa" 
##  [5] "North Africa"    "North America"   "South America"   "Caribbean"      
##  [9] "East Asia"       "South Asia"      "Southeast Asia"  "Western Europe" 
## [13] "Southern Europe" "Eastern Europe"

Merge

merged_data <- merge(pc.coord, sampling_loc, by.x = "Population", by.y = "Abbreviation")
## Warning in merge.data.frame(pc.coord, sampling_loc, by.x = "Population", :
## column names 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA',
## 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA',
## 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA',
## 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA',
## 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA',
## 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA' are duplicated
## in the result
head(merged_data)
##   Population       PC1     PC2        PC3        PC4       PC5       PC6
## 1        ALD  0.698471 3.57132 -1.9624800  -2.326840 -2.187760  4.368360
## 2        ALD -1.282020 1.50613  1.0982600  -0.280080  0.401259 -0.560525
## 3        ALD -1.725390 7.03502 -5.2634600 -12.714900 -0.221334  5.738240
## 4        ALD -0.407496 1.65721  0.2099280  -0.704761 -2.277190  0.469798
## 5        ALD -1.826950 2.50270  0.0548872  -0.991471 -0.166945  1.309480
## 6        ALD -1.105960 1.12714  0.4043540  -1.654250 -0.104622  0.381118
##           PC7       PC8       PC9       PC10      PC11       PC12        PC13
## 1 -1.39272000 -0.623150 -0.428381   0.977395 -1.435360   0.113058  -0.7688780
## 2 -0.00519542  0.176090  0.142589   0.614280  0.398314  -0.725768   0.0193667
## 3 -0.48600600 -9.820110  2.117210 -10.835300 -9.411410 -11.938600 -18.4070000
## 4 -1.11728000 -0.437404 -0.151463   0.802418 -1.059460  -1.198420  -0.7277870
## 5  0.48191900 -0.496835 -0.339839   0.822011 -1.215380   1.722310  -0.9356270
## 6  0.36948100 -1.617500  0.346523   0.150369 -0.440423  -0.533261  -0.2814980
##        PC14       PC15       PC16       PC17       PC18      PC19      PC20
## 1  0.523284 -0.0846775  0.6187920 -1.2227300  1.3997400  2.544390  1.154420
## 2 -1.011710  0.6321620 -0.1435840  0.2418510 -0.0241966 -0.458097 -0.280941
## 3  5.024880 -2.8998400  6.0352800  8.0233800  1.9536800  1.551090  2.649140
## 4  0.379008 -1.3290700 -0.0757638  0.1182260 -0.2679400  0.600152 -0.576345
## 5 -0.811757  0.2853090 -1.4765400 -0.6539260 -0.7468110  0.743164  0.719815
## 6  1.157490  0.1479980  1.3034700  0.0644328  1.5430200 -1.385400  0.159654
##        PC21       PC22      PC23      PC24      PC25         NA        NA
## 1  2.798800 -0.8668530 -0.893769 -0.518312  0.954192 -0.0318777 -0.680019
## 2 -0.575512  0.1007430  0.820903  0.354643 -0.194333  0.6924590 -0.469862
## 3 -4.627220  2.2264300  1.686030 -1.132490  0.442185  2.1978300 -0.722641
## 4  0.891981  0.4824820  0.842317  0.659477 -1.435800  0.4299440 -1.437520
## 5 -0.072382  0.2714280 -1.722170 -0.639923 -1.804780 -0.7598550  0.636633
## 6  1.512730 -0.0298175  2.326510  0.618038  1.126820  0.6224380 -0.566179
##           NA        NA         NA        NA        NA        NA         NA
## 1  0.1510160 -0.312330  0.0264672  0.798141 -0.238629  1.806570 -1.0534600
## 2 -0.1837100  0.257606 -0.3573480 -1.582280 -0.139481 -0.497385  0.2175460
## 3  0.8023310  0.755818  2.4919200 -2.009470 -0.280948  2.741590 -0.3009660
## 4 -0.0579024 -0.611098 -0.0217611 -0.391084 -1.278700 -1.206850 -0.0439436
## 5 -0.9795680  0.988997  0.9152320  0.140619 -0.927399 -0.412198 -0.7593510
## 6 -1.9184100  0.931455 -2.1932900 -0.374895  0.546309 -2.243620  0.1528920
##          NA         NA         NA         NA         NA        NA        NA
## 1 -1.930270 -0.0670539 -1.0926300  1.6738700  1.6929300 -1.371650 -0.447140
## 2  0.379590 -0.1775830 -0.4643830 -0.0838132 -0.0198599 -0.403583 -0.179195
## 3  1.051060  0.3068260  0.3280540 -0.0819166 -1.7824100  0.925345 -1.426750
## 4  0.187538  1.3208900  0.0402874  0.2380560  1.5556000 -0.996612  0.821319
## 5 -0.752639  0.1507500  0.4697400 -0.7462870 -0.9211040 -0.662627  0.488643
## 6  1.342290  0.8543080  1.1728500 -0.0499146  0.7886100  0.428899 -0.354037
##           NA        NA        NA        NA         NA        NA         NA
## 1  0.2101360  1.400080  0.663587 -0.983880 -1.3834800  0.607370  1.9973300
## 2  0.0444056 -1.012380  0.405831 -0.167073 -0.3394280  0.249337 -0.1811830
## 3 -0.1700320  1.291990 -3.357070  0.675858 -0.0715562 -0.738702 -1.6622900
## 4  0.4287450  0.478359  0.510094 -0.511880 -1.1691100 -1.763110 -0.4953880
## 5  0.4687750 -1.160500  1.324900 -1.099170 -0.2363720  0.893497 -0.0382572
## 6  0.1683970 -0.612109  1.790430 -0.995328  0.6376180 -0.519765  0.8174510
##           NA         NA        NA        NA         NA        NA        NA
## 1 -0.7389720 1.43413000 -0.700617 -0.116900  2.5129100 -1.480250  2.287230
## 2  0.5318840 0.00617738 -0.158840  0.757342 -0.0385116 -0.456860 -0.276871
## 3  0.9893160 0.32990300  1.301320 -0.858437 -1.3811000  1.409480 -1.605880
## 4 -0.5964540 0.10058800 -0.567534 -0.119752  0.4999330 -0.518738  1.958420
## 5  0.0380366 0.37830500 -1.875080  0.593708  0.1098250  0.627317  1.523820
## 6  0.5046100 1.15298000 -0.645987 -0.638111 -0.3546860  0.485700 -0.147141
##           NA        NA        NA         NA         NA         NA        NA
## 1 -0.0873631  1.324420  1.030560 -0.0928464 -0.9161940  0.3585160 -1.903700
## 2  0.4590490  0.253185  0.142081  0.3126680 -0.8262450 -0.4281430  0.120144
## 3  0.4813870 -0.132648 -1.100590  0.4878170  2.0190200 -1.0761400  0.993266
## 4  0.1345250  1.858470  0.869570  0.2970590 -1.4701200 -0.7974180  0.183197
## 5  1.7707200  0.560674 -0.126030  1.0078200 -0.0615558 -0.3118510 -0.732798
## 6 -0.2068020  0.752193  1.663710 -0.5991100 -0.4392770  0.0908075 -0.675817
##           NA         NA        NA         NA        NA         NA         NA
## 1 -0.7626520 -0.3978460 -0.173804  0.2913160 -1.763220  0.4776450  0.5653930
## 2  0.1890350  0.0161558 -0.312300  0.2796600  0.136673 -0.0454728 -0.0664771
## 3  0.0388421  1.2004800 -0.226208 -0.1664260  0.742102  0.9309480 -0.7576780
## 4  0.8707380 -0.0782472  0.104718 -0.6799830 -0.829604 -0.4490080 -0.5283610
## 5 -0.1663930 -0.1370370  0.960454  0.2681270 -1.078570  0.1363060  0.3240740
## 6  0.1475610  0.0399107 -1.112540 -0.0175588 -1.564690 -0.6035330  0.9426480
##           NA        NA        NA        NA        NA        NA        NA
## 1 -0.5803020 -0.714653 -1.095730  2.975520  1.124200  0.174368 -1.213940
## 2 -0.3962720  0.722120  0.647739 -0.133890 -0.243601  0.391365  0.539170
## 3 -0.0579069 -0.170478  0.668946 -0.661380 -0.474271 -0.332283  0.836012
## 4 -0.2544110 -0.327040 -0.938008  0.267276  1.041450  1.168440  0.754096
## 5  1.1968100  0.316377  0.277828  0.681194 -0.197814 -0.520826 -0.201468
## 6 -1.4287500  0.663574  0.461189 -1.425820  0.975066  0.374083 -0.919549
##          NA        NA         NA         NA        NA         NA        NA
## 1 -1.353470 -0.310123 -0.7408270 -0.3621710 -0.245125  0.3098190 -0.541746
## 2  0.981182 -0.752702  0.2954600 -0.2367250  0.421407 -0.1030330  0.286959
## 3  0.799905 -0.394641  0.0815951 -0.0446451 -0.157017  0.0640644 -0.230498
## 4 -1.070380 -0.338628  0.4366010  0.2055020 -0.499523  0.7012410  0.569468
## 5  0.080759 -1.032380  0.2184040 -0.0464710 -0.323673 -0.3806580 -1.136770
## 6 -1.598090  1.138800  0.7361020  0.7495980  0.862790 -0.5897430  0.448477
##          NA        NA        NA          NA         NA         NA          NA
## 1  0.624851 -0.479968  1.552000  0.00685162 -1.2182900  0.0689886 -0.87565700
## 2  0.502318 -0.138598 -0.881338 -0.26289100  1.0125300 -0.5580920  0.00824656
## 3 -0.181947  0.273156 -0.290570  0.38732400 -0.2916290  0.3645220  0.69619800
## 4 -1.317700 -1.611050  1.227520  0.03983320  1.4005000 -0.8560040 -1.35840000
## 5 -0.491547 -1.158500 -1.154240  1.06984000  0.0822953  1.5502300  0.47828800
## 6  0.526832  0.622868 -0.163840 -1.50887000  0.7219100 -0.4196710  0.30387200
##           NA        NA         NA         NA         NA        NA         NA
## 1  1.2701100  1.379420 -1.1603400  0.4629720 -0.0801278 -1.522340  0.4337860
## 2 -0.1387570 -0.281442 -0.0415016  0.5093030  0.5899420  0.653486  0.2111890
## 3  0.1449100 -0.227795  0.2013120  0.3456560 -0.4122290  0.374329 -0.6210730
## 4  0.4470770 -0.260693 -0.6624260 -0.0457854  0.2651160 -0.726507  0.0599057
## 5  0.1345910  1.263300  0.8107960 -0.0688320 -0.2883060 -0.211662  0.7277630
## 6 -0.0330995 -0.238729 -0.9153360  0.7228670 -0.6094860 -0.214246  0.0833169
##           NA        NA         NA Individual Pop_City Country Latitude
## 1  0.0521699 -1.564840  0.3100130     ALDU01   Durres Albania 41.29704
## 2  0.7497710 -0.371592  0.0128836     ALDU02   Durres Albania 41.29704
## 3  0.3198370  0.519285 -0.3084790     ALDU03   Durres Albania 41.29704
## 4 -0.3832370  0.417437  1.1807000     ALDU04   Durres Albania 41.29704
## 5  0.2920350 -0.930505 -0.5807450     ALDU05   Durres Albania 41.29704
## 6 -0.0285530 -0.073519  1.2085300     ALDU06   Durres Albania 41.29704
##   Longitude Continent Year          Region   Subregion order order2 orderold
## 1  19.50373    Europe 2018 Southern Europe East Europe    33     25       25
## 2  19.50373    Europe 2018 Southern Europe East Europe    33     25       25
## 3  19.50373    Europe 2018 Southern Europe East Europe    33     25       25
## 4  19.50373    Europe 2018 Southern Europe East Europe    33     25       25
## 5  19.50373    Europe 2018 Southern Europe East Europe    33     25       25
## 6  19.50373    Europe 2018 Southern Europe East Europe    33     25       25
##   order_microsat microsats microsat_code alt_code  X Country.1
## 1             61       yes           ALD     ALDU NA   Albania
## 2             61       yes           ALD     ALDU NA   Albania
## 3             61       yes           ALD     ALDU NA   Albania
## 4             61       yes           ALD     ALDU NA   Albania
## 5             61       yes           ALD     ALDU NA   Albania
## 6             61       yes           ALD     ALDU NA   Albania

2.2. Create PCA plots

ggsave(
  here("output/europe/lea/microsats/overlap/PCA_lea_microsats_overlap_pc1_pc2.pdf"
  ),
  width  = 8,
  height = 6,
  units  = "in"
)

PC1 and PC3

ggsave(
  here("output/europe/lea/microsats/overlap/PCA_lea_microsats_overlap_pc1_pc3.pdf"
  ),
  width  = 8,
  height = 6,
  units  = "in"
)

PC2 and PC3

ggsave(
  here("output/europe/lea/microsats/overlap/PCA_lea_microsats_overlap_pc2_pc3.pdf"
  ),
  width  = 8,
  height = 6,
  units  = "in"
)

DAPC for microsatellite data.

3. DAPC for all 1252 individuals in the micosats dataset

Load libraries & data files

library(ade4)
library(adegenet)
library(here)
#Install SNPRelate (required for dartR)
#  if (!require("BiocManager", quietly = TRUE))
#    install.packages("BiocManager")
# BiocManager::install("SNPRelate")
library(dartR)
## Loading required package: dartR.data
## **** Welcome to dartR.data [Version 1.0.8 ] ****
## Registered S3 method overwritten by 'pegas':
##   method      from
##   print.amova ade4
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
## Registered S3 method overwritten by 'genetics':
##   method      from 
##   [.haplotype pegas
## **** Welcome to dartR [Version 2.9.7 ] ****
## Be aware that owing to CRAN requirements and compatibility reasons not all functions of the package may run after the basic installation, as some packages could still be missing. Hence for a most enjoyable experience we recommend to run the function
## gl.install.vanilla.dartR()
## This installs all missing and required packages for your version of dartR. In case something fails during installation please refer to this tutorial: https://github.com/green-striped-gecko/dartR/wiki/Installation-tutorial.
## 
## For information how to cite dartR, please use:
## citation('dartR')
## Global verbosity is set to: 2
## 
## **** Have fun using dartR! ****
## 
## Attaching package: 'dartR'
## The following objects are masked from 'package:dartR.data':
## 
##     bandicoot.gl, possums.gl, testset.gl, testset.gs

Load .gen file with microsat data from all individuals

all_pops <- read.genepop("output/europe/dapc/microsats/for_dapc_albo_microsat_europe.gen", ncode=3L)
## 
##  Converting data from a Genepop .gen file to a genind object... 
## 
## 
## File description:  ARBOMONITOR_Aedes_albopictus                                           
## 
## ...done.
all_pops
## /// GENIND OBJECT /////////
## 
##  // 1,252 individuals; 11 loci; 189 alleles; size: 1 Mb
## 
##  // Basic content
##    @tab:  1252 x 189 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 7-28)
##    @loc.fac: locus factor for the 189 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: read.genepop(file = "output/europe/dapc/microsats/for_dapc_albo_microsat_europe.gen", 
##     ncode = 3L)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 1-60)
pop(all_pops)
##    [1] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##    [7] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [13] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [19] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [25] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [31] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [37] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [43] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [49] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [55] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [61] POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15 
##   [67] POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15 
##   [73] POL-PTQT15  POL-PTQT15  POL-PTQT15  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11 
##   [79] SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11 
##   [85] SPB-ESBD11  SPB-ESBD11  ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07
##   [91] ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
##   [97] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
##  [103] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
##  [109] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15
##  [115] ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15
##  [121] ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESAL-ESAL06 ESAL-ESAL06
##  [127] ESAL-ESAL06 ESAL-ESAL06 ESAL-ESAL06 ESAL-ESAL06 SPS-ESUP10  SPS-ESUP10 
##  [133] SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10 
##  [139] SPS-ESUP10  SPS-ESUP10  ESMN-ESMN04 ESMN-ESMN04 ESMN-ESMN04 ESLS-ESLS03
##  [145] ESLS-ESLS03 ESLS-ESLS03 ESMV-ESMV03 ESMV-ESMV03 ESMV-ESMV03 ESFU-ESFU03
##  [151] ESFU-ESFU03 ESFU-ESFU03 ESBM-ESBT03 ESBM-ESBT03 ESBM-ESBT03 ESBM-ESBT03
##  [157] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10
##  [163] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10
##  [169] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESGD-ESGD02 ESGD-ESGD02 ESBN-ESBN06
##  [175] ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESSL-ESSL03
##  [181] ESSL-ESSL03 ESSL-ESSL03 ESMC-ESMT03 ESMC-ESMT03 ESMC-ESMT03 ESMC-ESMT03
##  [187] ESVN-ESVN04 ESPT-ESPT03 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15
##  [193] ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15
##  [199] ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESBY-ESBY06 ESBY-ESBY06
##  [205] ESBY-ESBY06 ESBY-ESBY06 ESBY-ESBY06 ESBY-ESBY06 ESNI-ESNI10 ESNI-ESNI10
##  [211] ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10
##  [217] ESNI-ESNI10 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06
##  [223] ESNU-ESNU06 ESIR-ESIR03 ESIR-ESIR03 ESIR-ESIR03 ESAG-ESAG10 ESAG-ESAG10
##  [229] ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10
##  [235] ESAG-ESAG10 ESAG-ESAG10 ESAZ-ESAZ04 ESAZ-ESAZ04 ESAZ-ESAZ04 ESAZ-ESAZ04
##  [241] ESCN-ESCN04 ESCN-ESCN04 ESCN-ESCN04 ESCN-ESCN04 ESCT-ESTT01 ESCT-ESTT01
##  [247] ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01
##  [253] ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01
##  [259] ESCT-ESTT01 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
##  [265] ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
##  [271] ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
##  [277] ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06
##  [283] ESCH-ESCH02 ESCH-ESCH02 ESLM-ESLM04 ESLM-ESLM04 ESLM-ESLM04 ESLM-ESLM04
##  [289] ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESAY-ESAY10
##  [295] ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10
##  [301] ESAY-ESAY10 ESAY-ESAY10 SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
##  [307] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
##  [313] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
##  [319] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  ESBS-ESBC07 ESBS-ESBC07
##  [325] ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07
##  [331] ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07
##  [337] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15
##  [343] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15
##  [349] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10
##  [355] ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10
##  [361] ESTS-ESTS10 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
##  [367] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
##  [373] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
##  [379] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
##  [385] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESCP-ESCP19
##  [391] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
##  [397] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
##  [403] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
##  [409] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
##  [415] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
##  [421] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
##  [427] SPM-ESMG19  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45 
##  [433] FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45 
##  [439] FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45 
##  [445] FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45 
##  [451] FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45  FRS-FRMH45 
##  [457] FRS-FRMH45  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30 
##  [463] STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30 
##  [469] STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30 
##  [475] STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30 
##  [481] STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30  STS-FRST30 
##  [487] STS-FRST30  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
##  [493] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
##  [499] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
##  [505] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
##  [511] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
##  [517] ITB-ITBO15  ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
##  [523] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
##  [529] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
##  [535] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
##  [541] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
##  [547] ITRO-ITRO17 SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
##  [553] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
##  [559] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
##  [565] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
##  [571] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
##  [577] SLO-SLGO39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
##  [583] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
##  [589] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
##  [595] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
##  [601] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
##  [607] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
##  [613] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
##  [619] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
##  [625] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
##  [631] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
##  [637] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
##  [643] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
##  [649] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
##  [655] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
##  [661] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
##  [667] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
##  [673] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
##  [679] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
##  [685] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
##  [691] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  SER-SRNO30 
##  [697] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [703] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [709] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [715] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [721] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  ROTI-ROTI30 ROTI-ROTI30
##  [727] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [733] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [739] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [745] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [751] ROTI-ROTI30 ROTI-ROTI30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [757] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [763] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [769] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [775] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [781] RODE-RODE30 RODE-RODE30 ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [787] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [793] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [799] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [805] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [811] ROS-ROSM30  ROS-ROSM30  GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
##  [817] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
##  [823] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
##  [829] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
##  [835] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
##  [841] GRTA-GRTT05 GRTA-GRTT05 BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
##  [847] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
##  [853] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
##  [859] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
##  [865] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
##  [871] BUL-BULO34  ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
##  [877] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
##  [883] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
##  [889] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
##  [895] ROPL-ROPL30 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
##  [901] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
##  [907] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
##  [913] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
##  [919] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
##  [925] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
##  [931] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
##  [937] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
##  [943] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
##  [949] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
##  [955] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
##  [961] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
##  [967] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
##  [973] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
##  [979] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRKV-GRKV15
##  [985] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
##  [991] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
##  [997] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [1003] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [1009] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 ROBU-ROBU29 ROBU-ROBU29
## [1015] ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29
## [1021] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [1027] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [1033] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [1039] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [1045] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [1051] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [1057] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [1063] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [1069] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [1075] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 ROCO-ROCO30 ROCO-ROCO30
## [1081] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [1087] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [1093] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [1099] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [1105] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [1111] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [1117] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [1123] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [1129] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [1135] RURM-RURM07 RURM-RURM07 RURM-RURM07 SOC-RUSO10  SOC-RUSO10  SOC-RUSO10 
## [1141] SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10 
## [1147] SOC-RUSO10  TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15
## [1153] TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15
## [1159] TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10
## [1165] RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10
## [1171] RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20
## [1177] RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20
## [1183] RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04
## [1189] ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04
## [1195] ABAL-ABKO04 TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10
## [1201] TRRI-TRRI10 ABSU-ABSU05 ABSU-ABSU05 ABSU-ABSU05 ABSU-ABSU05 ABSU-ABSU05
## [1207] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [1213] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [1219] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [1225] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [1231] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  GEPO-GEPO05
## [1237] GEPO-GEPO05 GEPO-GEPO05 GEPO-GEPO05 GEPO-GEPO05 TRAR-TRAR14 TRAR-TRAR14
## [1243] TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14
## [1249] TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14
## 78 Levels: POP-PTPN60 POL-PTQT15 SPB-ESBD11 ESAC-ESAC07 ... TRAR-TRAR14

covert it to genind format

# import the data
nInd(all_pops)
## [1] 1252
nLoc(all_pops)
## [1] 11
nPop(all_pops)
## [1] 78
indNames(all_pops)
##    [1] "POP-PTPN01"  "POP-PTPN02"  "POP-PTPN03"  "POP-PTPN04"  "POP-PTPN05" 
##    [6] "POP-PTPN06"  "POP-PTPN07"  "POP-PTPN08"  "POP-PTPN09"  "POP-PTPN10" 
##   [11] "POP-PTPN11"  "POP-PTPN12"  "POP-PTPN13"  "POP-PTPN14"  "POP-PTPN15" 
##   [16] "POP-PTPN16"  "POP-PTPN17"  "POP-PTPN18"  "POP-PTPN19"  "POP-PTPN20" 
##   [21] "POP-PTPN21"  "POP-PTPN22"  "POP-PTPN23"  "POP-PTPN24"  "POP-PTPN25" 
##   [26] "POP-PTPN26"  "POP-PTPN27"  "POP-PTPN28"  "POP-PTPN29"  "POP-PTPN30" 
##   [31] "POP-PTPN31"  "POP-PTPN32"  "POP-PTPN33"  "POP-PTPN34"  "POP-PTPN35" 
##   [36] "POP-PTPN36"  "POP-PTPN37"  "POP-PTPN38"  "POP-PTPN39"  "POP-PTPN40" 
##   [41] "POP-PTPN41"  "POP-PTPN42"  "POP-PTPN43"  "POP-PTPN44"  "POP-PTPN45" 
##   [46] "POP-PTPN46"  "POP-PTPN47"  "POP-PTPN48"  "POP-PTPN49"  "POP-PTPN50" 
##   [51] "POP-PTPN51"  "POP-PTPN52"  "POP-PTPN53"  "POP-PTPN54"  "POP-PTPN55" 
##   [56] "POP-PTPN56"  "POP-PTPN57"  "POP-PTPN58"  "POP-PTPN59"  "POP-PTPN60" 
##   [61] "POL-PTQT01"  "POL-PTQT02"  "POL-PTQT03"  "POL-PTQT04"  "POL-PTQT05" 
##   [66] "POL-PTQT06"  "POL-PTQT07"  "POL-PTQT08"  "POL-PTQT09"  "POL-PTQT10" 
##   [71] "POL-PTQT11"  "POL-PTQT12"  "POL-PTQT13"  "POL-PTQT14"  "POL-PTQT15" 
##   [76] "SPB-ESBD01"  "SPB-ESBD02"  "SPB-ESBD03"  "SPB-ESBD04"  "SPB-ESBD05" 
##   [81] "SPB-ESBD06"  "SPB-ESBD07"  "SPB-ESBD08"  "SPB-ESBD09"  "SPB-ESBD10" 
##   [86] "SPB-ESBD11"  "ESAC-ESAC01" "ESAC-ESAC02" "ESAC-ESAC03" "ESAC-ESAC04"
##   [91] "ESAC-ESAC05" "ESAC-ESAC06" "ESAC-ESAC07" "ESMO-ESMO01" "ESMO-ESMO02"
##   [96] "ESMO-ESMO03" "ESMO-ESMO04" "ESMO-ESMO05" "ESMO-ESMO06" "ESMO-ESMO07"
##  [101] "ESMO-ESMO08" "ESMO-ESMO09" "ESMO-ESMO10" "ESMO-ESMO11" "ESMO-ESMO12"
##  [106] "ESMO-ESMO13" "ESMO-ESMO14" "ESMO-ESMO15" "ESMO-ESMO16" "ESMO-ESMO17"
##  [111] "ESMO-ESMO18" "ESSV-ESSV01" "ESSV-ESSV02" "ESSV-ESSV03" "ESSV-ESSV05"
##  [116] "ESSV-ESSV06" "ESSV-ESSV07" "ESSV-ESSV08" "ESSV-ESSV09" "ESSV-ESSV10"
##  [121] "ESSV-ESSV11" "ESSV-ESSV12" "ESSV-ESSV13" "ESSV-ESSV15" "ESAL-ESAL01"
##  [126] "ESAL-ESAL02" "ESAL-ESAL03" "ESAL-ESAL04" "ESAL-ESAL05" "ESAL-ESAL06"
##  [131] "SPS-ESUP01"  "SPS-ESUP02"  "SPS-ESUP03"  "SPS-ESUP04"  "SPS-ESUP05" 
##  [136] "SPS-ESUP06"  "SPS-ESUP07"  "SPS-ESUP08"  "SPS-ESUP09"  "SPS-ESUP10" 
##  [141] "ESMN-ESMN01" "ESMN-ESMN03" "ESMN-ESMN04" "ESLS-ESLS01" "ESLS-ESLS02"
##  [146] "ESLS-ESLS03" "ESMV-ESMV01" "ESMV-ESMV02" "ESMV-ESMV03" "ESFU-ESFU01"
##  [151] "ESFU-ESFU02" "ESFU-ESFU03" "ESBM-ESBM01" "ESBM-ESBT01" "ESBM-ESBT02"
##  [156] "ESBM-ESBT03" "ESTM-ESTM01" "ESTM-ESTM02" "ESTM-ESTO01" "ESTM-ESTO02"
##  [161] "ESTM-ESTO03" "ESTM-ESTY01" "ESTM-ESTY02" "ESTM-ESTY03" "ESTM-ESTY04"
##  [166] "ESTM-ESTY05" "ESTM-ESTY06" "ESTM-ESTY07" "ESTM-ESTY08" "ESTM-ESTY09"
##  [171] "ESTM-ESTY10" "ESGD-ESGD01" "ESGD-ESGD02" "ESBN-ESBN01" "ESBN-ESBN02"
##  [176] "ESBN-ESBN03" "ESBN-ESBN04" "ESBN-ESBN05" "ESBN-ESBN06" "ESSL-ESSL01"
##  [181] "ESSL-ESSL02" "ESSL-ESSL03" "ESMC-ESMC03" "ESMC-ESMT01" "ESMC-ESMT02"
##  [186] "ESMC-ESMT03" "ESVN-ESVN04" "ESPT-ESPT03" "ESAB-ESAB01" "ESAB-ESAB02"
##  [191] "ESAB-ESAB03" "ESAB-ESAB04" "ESAB-ESAB05" "ESAB-ESAB06" "ESAB-ESAB07"
##  [196] "ESAB-ESAB09" "ESAB-ESAB10" "ESAB-ESAB11" "ESAB-ESAB12" "ESAB-ESAB13"
##  [201] "ESAB-ESAB14" "ESAB-ESAB15" "ESBY-ESBY01" "ESBY-ESBY02" "ESBY-ESBY03"
##  [206] "ESBY-ESBY04" "ESBY-ESBY05" "ESBY-ESBY06" "ESNI-ESNI01" "ESNI-ESNI02"
##  [211] "ESNI-ESNI04" "ESNI-ESNI05" "ESNI-ESNI06" "ESNI-ESNI07" "ESNI-ESNI08"
##  [216] "ESNI-ESNI09" "ESNI-ESNI10" "ESNU-ESNU01" "ESNU-ESNU02" "ESNU-ESNU03"
##  [221] "ESNU-ESNU04" "ESNU-ESNU05" "ESNU-ESNU06" "ESIR-ESIR01" "ESIR-ESIR02"
##  [226] "ESIR-ESIR03" "ESAG-ESAG01" "ESAG-ESAG02" "ESAG-ESAG03" "ESAG-ESAG04"
##  [231] "ESAG-ESAG05" "ESAG-ESAG06" "ESAG-ESAG07" "ESAG-ESAG08" "ESAG-ESAG09"
##  [236] "ESAG-ESAG10" "ESAZ-ESAZ01" "ESAZ-ESAZ02" "ESAZ-ESAZ03" "ESAZ-ESAZ04"
##  [241] "ESCN-ESCN01" "ESCN-ESCN02" "ESCN-ESCN03" "ESCN-ESCN04" "ESCT-ESCT01"
##  [246] "ESCT-ESCT02" "ESCT-ESLA01" "ESCT-ESLA02" "ESCT-ESLU01" "ESCT-ESLU02"
##  [251] "ESCT-ESLU03" "ESCT-ESLU04" "ESCT-ESLU05" "ESCT-ESLU06" "ESCT-ESLU07"
##  [256] "ESCT-ESLU08" "ESCT-ESLU09" "ESCT-ESLU10" "ESCT-ESTT01" "ESMU-ESCV01"
##  [261] "ESMU-ESCV02" "ESMU-ESCV03" "ESMU-ESCV04" "ESMU-ESMU01" "ESMU-ESMU02"
##  [266] "ESMU-ESMU03" "ESMU-ESRM01" "ESMU-ESRM02" "ESMU-ESRM03" "ESMU-ESRM04"
##  [271] "ESMU-ESRM05" "ESMU-ESRM06" "ESMU-ESRM07" "ESMU-ESRM08" "ESMU-ESRM09"
##  [276] "ESMU-ESRM10" "ESPP-ESPP01" "ESPP-ESPP02" "ESPP-ESPP03" "ESPP-ESPP04"
##  [281] "ESPP-ESPP05" "ESPP-ESPP06" "ESCH-ESCH01" "ESCH-ESCH02" "ESLM-ESLM01"
##  [286] "ESLM-ESLM02" "ESLM-ESLM03" "ESLM-ESLM04" "ESCA-ESCA01" "ESCA-ESCA02"
##  [291] "ESCA-ESCA03" "ESCA-ESCA04" "ESCA-ESCA05" "ESAY-ESAY01" "ESAY-ESAY02"
##  [296] "ESAY-ESAY03" "ESAY-ESAY04" "ESAY-ESAY05" "ESAY-ESAY06" "ESAY-ESAY07"
##  [301] "ESAY-ESAY09" "ESAY-ESAY10" "SPC-ESVL01"  "SPC-ESVL02"  "SPC-ESVL03" 
##  [306] "SPC-ESVL04"  "SPC-ESVL05"  "SPC-ESVL06"  "SPC-ESVL07"  "SPC-ESVL08" 
##  [311] "SPC-ESVL09"  "SPC-ESVL10"  "SPC-ESVL11"  "SPC-ESVL12"  "SPC-ESVL13" 
##  [316] "SPC-ESVL14"  "SPC-ESVL15"  "SPC-ESVL16"  "SPC-ESVL17"  "SPC-ESVL18" 
##  [321] "SPC-ESVL19"  "SPC-ESVL20"  "ESBS-ESBS01" "ESBS-ESBS02" "ESBS-ESBS03"
##  [326] "ESBS-ESBS04" "ESBS-ESBS05" "ESBS-ESBS06" "ESBS-ESBS07" "ESBS-ESBC01"
##  [331] "ESBS-ESBC02" "ESBS-ESBC03" "ESBS-ESBC04" "ESBS-ESBC05" "ESBS-ESBC06"
##  [336] "ESBS-ESBC07" "ESBE-ESBE01" "ESBE-ESBE02" "ESBE-ESBE03" "ESBE-ESBE04"
##  [341] "ESBE-ESBE05" "ESBE-ESBE06" "ESBE-ESBE07" "ESBE-ESBE08" "ESBE-ESBE09"
##  [346] "ESBE-ESBE10" "ESBE-ESBE11" "ESBE-ESBE12" "ESBE-ESBE13" "ESBE-ESBE14"
##  [351] "ESBE-ESBE15" "ESTS-ESTS01" "ESTS-ESTS02" "ESTS-ESTS03" "ESTS-ESTS04"
##  [356] "ESTS-ESTS05" "ESTS-ESTS06" "ESTS-ESTS07" "ESTS-ESTS08" "ESTS-ESTS09"
##  [361] "ESTS-ESTS10" "ESBA-ESBA01" "ESBA-ESBA02" "ESBA-ESBA03" "ESBA-ESBA04"
##  [366] "ESBA-ESBA05" "ESBA-ESBA06" "ESBA-ESBA07" "ESBA-ESBA08" "ESBA-ESBA09"
##  [371] "ESBA-ESBA10" "ESBA-ESBA11" "ESBA-ESBA12" "ESBA-ESBA13" "ESBA-ESBA14"
##  [376] "ESBA-ESBA15" "ESBA-ESBA16" "ESBA-ESBA17" "ESBA-ESBA18" "ESBA-ESBA19"
##  [381] "ESBA-ESBA20" "ESBA-ESBA21" "ESBA-ESBA22" "ESBA-ESBA23" "ESBA-ESBA24"
##  [386] "ESBA-ESBA25" "ESBA-ESBA26" "ESBA-ESBA27" "ESBA-ESBA28" "ESCP-ESCP01"
##  [391] "ESCP-ESCP02" "ESCP-ESCP03" "ESCP-ESCP04" "ESCP-ESCP05" "ESCP-ESCP06"
##  [396] "ESCP-ESCP07" "ESCP-ESCP08" "ESCP-ESCP09" "ESCP-ESCP10" "ESCP-ESCP11"
##  [401] "ESCP-ESCP12" "ESCP-ESCP13" "ESCP-ESCP14" "ESCP-ESCP15" "ESCP-ESCP16"
##  [406] "ESCP-ESCP17" "ESCP-ESCP18" "ESCP-ESCP19" "SPM-ESMG01"  "SPM-ESMG02" 
##  [411] "SPM-ESMG03"  "SPM-ESMG04"  "SPM-ESMG05"  "SPM-ESMG06"  "SPM-ESMG07" 
##  [416] "SPM-ESMG08"  "SPM-ESMG09"  "SPM-ESMG10"  "SPM-ESMG11"  "SPM-ESMG12" 
##  [421] "SPM-ESMG13"  "SPM-ESMG14"  "SPM-ESMG15"  "SPM-ESMG16"  "SPM-ESMG17" 
##  [426] "SPM-ESMG18"  "SPM-ESMG19"  "FRS-FRMH01"  "FRS-FRMH02"  "FRS-FRMH03" 
##  [431] "FRS-FRMH04"  "FRS-FRMH05"  "FRS-FRMH06"  "FRS-FRMH07"  "FRS-FRMH08" 
##  [436] "FRS-FRMH09"  "FRS-FRMH10"  "FRS-FRMH11"  "FRS-FRMH12"  "FRS-FRMH13" 
##  [441] "FRS-FRMH14"  "FRS-FRMH15"  "FRS-FRMH16"  "FRS-FRMH17"  "FRS-FRMH18" 
##  [446] "FRS-FRMH19"  "FRS-FRMH20"  "FRS-FRMH36"  "FRS-FRMH37"  "FRS-FRMH38" 
##  [451] "FRS-FRMH39"  "FRS-FRMH40"  "FRS-FRMH41"  "FRS-FRMH42"  "FRS-FRMH43" 
##  [456] "FRS-FRMH44"  "FRS-FRMH45"  "STS-FRST01"  "STS-FRST02"  "STS-FRST03" 
##  [461] "STS-FRST04"  "STS-FRST05"  "STS-FRST06"  "STS-FRST07"  "STS-FRST08" 
##  [466] "STS-FRST09"  "STS-FRST10"  "STS-FRST11"  "STS-FRST12"  "STS-FRST13" 
##  [471] "STS-FRST14"  "STS-FRST15"  "STS-FRST16"  "STS-FRST17"  "STS-FRST18" 
##  [476] "STS-FRST19"  "STS-FRST20"  "STS-FRST21"  "STS-FRST22"  "STS-FRST23" 
##  [481] "STS-FRST24"  "STS-FRST25"  "STS-FRST26"  "STS-FRST27"  "STS-FRST28" 
##  [486] "STS-FRST29"  "STS-FRST30"  "ITB-ITBL01"  "ITB-ITBL02"  "ITB-ITBL03" 
##  [491] "ITB-ITBL04"  "ITB-ITBL05"  "ITB-ITBL06"  "ITB-ITBL07"  "ITB-ITBL08" 
##  [496] "ITB-ITBL09"  "ITB-ITBL10"  "ITB-ITBL11"  "ITB-ITBL12"  "ITB-ITBL13" 
##  [501] "ITB-ITBL14"  "ITB-ITBL15"  "ITB-ITBO01"  "ITB-ITBO02"  "ITB-ITBO03" 
##  [506] "ITB-ITBO04"  "ITB-ITBO05"  "ITB-ITBO06"  "ITB-ITBO07"  "ITB-ITBO08" 
##  [511] "ITB-ITBO09"  "ITB-ITBO10"  "ITB-ITBO11"  "ITB-ITBO12"  "ITB-ITBO13" 
##  [516] "ITB-ITBO14"  "ITB-ITBO15"  "ITRO-ITRM01" "ITRO-ITRM02" "ITRO-ITRM03"
##  [521] "ITRO-ITRM04" "ITRO-ITRM05" "ITRO-ITRM06" "ITRO-ITRM07" "ITRO-ITRM08"
##  [526] "ITRO-ITRM09" "ITRO-ITRM10" "ITRO-ITRM11" "ITRO-ITRM12" "ITRO-ITRM13"
##  [531] "ITRO-ITRO01" "ITRO-ITRO02" "ITRO-ITRO03" "ITRO-ITRO04" "ITRO-ITRO05"
##  [536] "ITRO-ITRO06" "ITRO-ITRO07" "ITRO-ITRO08" "ITRO-ITRO09" "ITRO-ITRO10"
##  [541] "ITRO-ITRO11" "ITRO-ITRO12" "ITRO-ITRO13" "ITRO-ITRO14" "ITRO-ITRO15"
##  [546] "ITRO-ITRO16" "ITRO-ITRO17" "SLO-SLGO01"  "SLO-SLGO02"  "SLO-SLGO03" 
##  [551] "SLO-SLGO04"  "SLO-SLGO05"  "SLO-SLGO06"  "SLO-SLGO07"  "SLO-SLGO08" 
##  [556] "SLO-SLGO09"  "SLO-SLGO10"  "SLO-SLGO11"  "SLO-SLGO12"  "SLO-SLGO13" 
##  [561] "SLO-SLGO14"  "SLO-SLGO15"  "SLO-SLGO25"  "SLO-SLGO26"  "SLO-SLGO27" 
##  [566] "SLO-SLGO28"  "SLO-SLGO29"  "SLO-SLGO30"  "SLO-SLGO31"  "SLO-SLGO32" 
##  [571] "SLO-SLGO33"  "SLO-SLGO34"  "SLO-SLGO35"  "SLO-SLGO36"  "SLO-SLGO37" 
##  [576] "SLO-SLGO38"  "SLO-SLGO39"  "MAL-MTLU01"  "MAL-MTLU02"  "MAL-MTLU03" 
##  [581] "MAL-MTLU04"  "MAL-MTLU05"  "MAL-MTLU06"  "MAL-MTLU07"  "MAL-MTLU08" 
##  [586] "MAL-MTLU09"  "MAL-MTLU10"  "MAL-MTLU11"  "MAL-MTLU12"  "MAL-MTLU13" 
##  [591] "MAL-MTLU14"  "MAL-MTLU15"  "MAL-MTLU16"  "MAL-MTLU17"  "MAL-MTLU18" 
##  [596] "MAL-MTLU19"  "MAL-MTLU20"  "MAL-MTLU31"  "MAL-MTLU32"  "MAL-MTLU33" 
##  [601] "MAL-MTLU34"  "MAL-MTLU35"  "MAL-MTLU36"  "MAL-MTLU37"  "MAL-MTLU38" 
##  [606] "MAL-MTLU39"  "ITP-ITBR01"  "ITP-ITBR02"  "ITP-ITBR03"  "ITP-ITBR04" 
##  [611] "ITP-ITBR05"  "ITP-ITBR06"  "ITP-ITBR07"  "ITP-ITBR08"  "ITP-ITBR09" 
##  [616] "ITP-ITBR10"  "ITP-ITBR11"  "ITP-ITBR12"  "ITP-ITBR13"  "ITP-ITBR14" 
##  [621] "ITP-ITBR15"  "ITP-ITBR16"  "ITP-ITBR17"  "ITP-ITBR18"  "ITP-ITBR19" 
##  [626] "ITP-ITBR20"  "ITP-ITBR21"  "ITP-ITVL01"  "ITP-ITVL02"  "ITP-ITVL03" 
##  [631] "ITP-ITVL04"  "ITP-ITVL05"  "ITP-ITVL06"  "ITP-ITVL07"  "ITP-ITVL08" 
##  [636] "ITP-ITVL09"  "CRO-CRPL01"  "CRO-CRPL02"  "CRO-CRPL03"  "CRO-CRPL04" 
##  [641] "CRO-CRPL05"  "CRO-CRPL06"  "CRO-CRPL07"  "CRO-CRPL08"  "CRO-CRPL09" 
##  [646] "CRO-CRPL10"  "CRO-CRPL11"  "CRO-CRPL12"  "CRO-CRPL13"  "CRO-CRPL14" 
##  [651] "CRO-CRPL15"  "CRO-CRPL16"  "CRO-CRPL17"  "CRO-CRPL18"  "CRO-CRPL19" 
##  [656] "CRO-CRPL20"  "CRO-CRPL21"  "CRO-CRPL22"  "CRO-CRPL23"  "CRO-CRPL24" 
##  [661] "CRO-CRPL25"  "CRO-CRPL26"  "CRO-CRPL27"  "CRO-CRPL28"  "CRO-CRPL29" 
##  [666] "CRO-CRPL30"  "ALD-ALDU01"  "ALD-ALDU02"  "ALD-ALDU03"  "ALD-ALDU04" 
##  [671] "ALD-ALDU05"  "ALD-ALDU06"  "ALD-ALDU07"  "ALD-ALDU08"  "ALD-ALDU09" 
##  [676] "ALD-ALDU10"  "ALD-ALDU11"  "ALD-ALDU12"  "ALD-ALDU13"  "ALD-ALDU14" 
##  [681] "ALD-ALDU15"  "ALD-ALDU16"  "ALD-ALDU17"  "ALD-ALDU18"  "ALD-ALDU19" 
##  [686] "ALD-ALDU20"  "ALD-ALDU21"  "ALD-ALDU22"  "ALD-ALDU23"  "ALD-ALDU25" 
##  [691] "ALD-ALDU26"  "ALD-ALDU27"  "ALD-ALDU28"  "ALD-ALDU29"  "ALD-ALDU30" 
##  [696] "SER-SRNO01"  "SER-SRNO02"  "SER-SRNO03"  "SER-SRNO04"  "SER-SRNO05" 
##  [701] "SER-SRNO06"  "SER-SRNO07"  "SER-SRNO08"  "SER-SRNO09"  "SER-SRNO10" 
##  [706] "SER-SRNO11"  "SER-SRNO12"  "SER-SRNO14"  "SER-SRNO15"  "SER-SRNO16" 
##  [711] "SER-SRNO17"  "SER-SRNO18"  "SER-SRNO19"  "SER-SRNO20"  "SER-SRNO21" 
##  [716] "SER-SRNO22"  "SER-SRNO23"  "SER-SRNO24"  "SER-SRNO25"  "SER-SRNO26" 
##  [721] "SER-SRNO27"  "SER-SRNO28"  "SER-SRNO29"  "SER-SRNO30"  "ROTI-ROTI01"
##  [726] "ROTI-ROTI03" "ROTI-ROTI04" "ROTI-ROTI05" "ROTI-ROTI06" "ROTI-ROTI07"
##  [731] "ROTI-ROTI08" "ROTI-ROTI09" "ROTI-ROTI10" "ROTI-ROTI11" "ROTI-ROTI12"
##  [736] "ROTI-ROTI13" "ROTI-ROTI14" "ROTI-ROTI15" "ROTI-ROTI16" "ROTI-ROTI17"
##  [741] "ROTI-ROTI18" "ROTI-ROTI19" "ROTI-ROTI21" "ROTI-ROTI22" "ROTI-ROTI23"
##  [746] "ROTI-ROTI24" "ROTI-ROTI25" "ROTI-ROTI26" "ROTI-ROTI27" "ROTI-ROTI28"
##  [751] "ROTI-ROTI29" "ROTI-ROTI30" "RODE-RODE01" "RODE-RODE02" "RODE-RODE03"
##  [756] "RODE-RODE04" "RODE-RODE05" "RODE-RODE06" "RODE-RODE07" "RODE-RODE08"
##  [761] "RODE-RODE09" "RODE-RODE10" "RODE-RODE11" "RODE-RODE12" "RODE-RODE13"
##  [766] "RODE-RODE14" "RODE-RODE15" "RODE-RODE16" "RODE-RODE17" "RODE-RODE18"
##  [771] "RODE-RODE19" "RODE-RODE20" "RODE-RODE21" "RODE-RODE22" "RODE-RODE23"
##  [776] "RODE-RODE24" "RODE-RODE25" "RODE-RODE26" "RODE-RODE27" "RODE-RODE28"
##  [781] "RODE-RODE29" "RODE-RODE30" "ROS-ROSM01"  "ROS-ROSM02"  "ROS-ROSM03" 
##  [786] "ROS-ROSM04"  "ROS-ROSM05"  "ROS-ROSM06"  "ROS-ROSM07"  "ROS-ROSM08" 
##  [791] "ROS-ROSM09"  "ROS-ROSM10"  "ROS-ROSM11"  "ROS-ROSM12"  "ROS-ROSM13" 
##  [796] "ROS-ROSM14"  "ROS-ROSM15"  "ROS-ROSM16"  "ROS-ROSM17"  "ROS-ROSM18" 
##  [801] "ROS-ROSM19"  "ROS-ROSM20"  "ROS-ROSM21"  "ROS-ROSM22"  "ROS-ROSM23" 
##  [806] "ROS-ROSM24"  "ROS-ROSM25"  "ROS-ROSM26"  "ROS-ROSM27"  "ROS-ROSM28" 
##  [811] "ROS-ROSM29"  "ROS-ROSM30"  "GRTA-GRTA01" "GRTA-GRTA02" "GRTA-GRTA03"
##  [816] "GRTA-GRTA04" "GRTA-GRTA05" "GRTA-GRTA06" "GRTA-GRTA07" "GRTA-GRTA08"
##  [821] "GRTA-GRTA09" "GRTA-GRTA10" "GRTA-GRTA11" "GRTA-GRTA12" "GRTA-GRTA13"
##  [826] "GRTA-GRTA14" "GRTA-GRTA15" "GRTA-GRTA23" "GRTA-GRTA24" "GRTA-GRTA25"
##  [831] "GRTA-GRTA26" "GRTA-GRTA27" "GRTA-GRTI01" "GRTA-GRTI02" "GRTA-GRTI03"
##  [836] "GRTA-GRTI04" "GRTA-GRTI05" "GRTA-GRTT01" "GRTA-GRTT02" "GRTA-GRTT03"
##  [841] "GRTA-GRTT04" "GRTA-GRTT05" "BUL-BULO01"  "BUL-BULO02"  "BUL-BULO03" 
##  [846] "BUL-BULO04"  "BUL-BULO05"  "BUL-BULO06"  "BUL-BULO07"  "BUL-BULO08" 
##  [851] "BUL-BULO09"  "BUL-BULO10"  "BUL-BULO11"  "BUL-BULO12"  "BUL-BULO13" 
##  [856] "BUL-BULO14"  "BUL-BULO15"  "BUL-BULO16"  "BUL-BULO17"  "BUL-BULO18" 
##  [861] "BUL-BULO20"  "BUL-BULO25"  "BUL-BULO26"  "BUL-BULO27"  "BUL-BULO28" 
##  [866] "BUL-BULO29"  "BUL-BULO30"  "BUL-BULO31"  "BUL-BULO32"  "BUL-BULO33" 
##  [871] "BUL-BULO34"  "ROPL-ROPL02" "ROPL-ROPL03" "ROPL-ROPL05" "ROPL-ROPL07"
##  [876] "ROPL-ROPL08" "ROPL-ROPL11" "ROPL-ROPL12" "ROPL-ROPL13" "ROPL-ROPL14"
##  [881] "ROPL-ROPL15" "ROPL-ROPL16" "ROPL-ROPL17" "ROPL-ROPL18" "ROPL-ROPL19"
##  [886] "ROPL-ROPL20" "ROPL-ROPL21" "ROPL-ROPL22" "ROPL-ROPL23" "ROPL-ROPL25"
##  [891] "ROPL-ROPL26" "ROPL-ROPL27" "ROPL-ROPL28" "ROPL-ROPL29" "ROPL-ROPL30"
##  [896] "GRPA-GRPA01" "GRPA-GRPA02" "GRPA-GRPA03" "GRPA-GRPA04" "GRPA-GRPA05"
##  [901] "GRPA-GRPI01" "GRPA-GRPI02" "GRPA-GRPI03" "GRPA-GRPI04" "GRPA-GRPI06"
##  [906] "GRPA-GRPP01" "GRPA-GRPP02" "GRPA-GRPP03" "GRPA-GRPP04" "GRPA-GRPP05"
##  [911] "GRPA-GRPR01" "GRPA-GRPR02" "GRPA-GRPR03" "GRPA-GRPR04" "GRPA-GRPR05"
##  [916] "GRPA-GRPR06" "GRPA-GRPR07" "GRPA-GRPR08" "GRPA-GRPR09" "GRPA-GRPR10"
##  [921] "GRPA-GRPU01" "GRPA-GRPU02" "GRPA-GRPU03" "GRPA-GRPU04" "GRA-GRAA01" 
##  [926] "GRA-GRAA02"  "GRA-GRAA03"  "GRA-GRAA04"  "GRA-GRAA05"  "GRA-GRAA06" 
##  [931] "GRA-GRAA07"  "GRA-GRAA08"  "GRA-GRAE01"  "GRA-GRAE02"  "GRA-GRAE03" 
##  [936] "GRA-GRAE04"  "GRA-GRAE05"  "GRA-GRAE06"  "GRA-GRAE07"  "GRA-GRAE08" 
##  [941] "GRA-GRAH01"  "GRA-GRAH02"  "GRA-GRAH05"  "GRA-GRAH06"  "GRA-GRAH07" 
##  [946] "GRA-GRAI01"  "GRA-GRAN01"  "GRA-GRAN02"  "GRA-GRAN03"  "GRA-GRAN04" 
##  [951] "GRA-GRAN05"  "GRA-GRAN06"  "GRA-GRAN07"  "GRA-GRAN08"  "GRC-GRCA01" 
##  [956] "GRC-GRCA02"  "GRC-GRCA03"  "GRC-GRCA04"  "GRC-GRCA05"  "GRC-GRCC01" 
##  [961] "GRC-GRCC02"  "GRC-GRCC03"  "GRC-GRCC04"  "GRC-GRCC05"  "GRC-GRCC06" 
##  [966] "GRC-GRCC08"  "GRC-GRCC09"  "GRC-GRCC10"  "GRC-GRCC11"  "GRC-GRCC12" 
##  [971] "GRC-GRCC13"  "GRC-GRCC14"  "GRC-GRCC15"  "GRC-GRCC16"  "GRC-GRCC17" 
##  [976] "GRC-GRCC18"  "GRC-GRCC19"  "GRC-GRCC20"  "GRC-GRCC21"  "GRC-GRCC22" 
##  [981] "GRC-GRCC23"  "GRC-GRCC24"  "GRC-GRCC25"  "GRKV-GRKA01" "GRKV-GRKA02"
##  [986] "GRKV-GRKA03" "GRKV-GRKA04" "GRKV-GRKA05" "GRKV-GRKB01" "GRKV-GRKB02"
##  [991] "GRKV-GRKB03" "GRKV-GRKB04" "GRKV-GRKL01" "GRKV-GRKL02" "GRKV-GRKL03"
##  [996] "GRKV-GRKL04" "GRKV-GRKL05" "GRKV-GRKV01" "GRKV-GRKV02" "GRKV-GRKV03"
## [1001] "GRKV-GRKV04" "GRKV-GRKV05" "GRKV-GRKV06" "GRKV-GRKV07" "GRKV-GRKV08"
## [1006] "GRKV-GRKV09" "GRKV-GRKV10" "GRKV-GRKV11" "GRKV-GRKV12" "GRKV-GRKV13"
## [1011] "GRKV-GRKV14" "GRKV-GRKV15" "ROBU-ROBU11" "ROBU-ROBU13" "ROBU-ROBU16"
## [1016] "ROBU-ROBU17" "ROBU-ROBU19" "ROBU-ROBU26" "ROBU-ROBU28" "ROBU-ROBU29"
## [1021] "TUA-TRLG01"  "TUA-TRLG02"  "TUA-TRLG03"  "TUA-TRLG04"  "TUA-TRLG05" 
## [1026] "TUA-TRLG06"  "TUA-TRLG07"  "TUA-TRLG08"  "TUA-TRLG09"  "TUA-TRLG10" 
## [1031] "TUA-TRLG11"  "TUA-TRLG12"  "TUA-TRLG13"  "TUA-TRLG14"  "TUA-TRLG15" 
## [1036] "TUA-TRLG16"  "TUA-TRLG17"  "TUA-TRLG18"  "TUA-TRLG19"  "TUA-TRLG20" 
## [1041] "TUA-TRLG21"  "TUA-TRLG22"  "TUA-TRLG23"  "TUA-TRLG24"  "TUA-TRLG25" 
## [1046] "TUA-TRLG26"  "TUA-TRLG27"  "TUA-TRLG28"  "TUA-TRLG29"  "TUA-TRLG30" 
## [1051] "TRGN-TRGN01" "TRGN-TRGN02" "TRGN-TRGN03" "TRGN-TRGN04" "TRGN-TRGN05"
## [1056] "TRGN-TRGN06" "TRGN-TRGN07" "TRGN-TRGN08" "TRGN-TRGN09" "TRGN-TRGN10"
## [1061] "TRGN-TRGN11" "TRGN-TRGN12" "TRGN-TRGN13" "TRGN-TRGN14" "TRGN-TRGN15"
## [1066] "TRGN-TRGN16" "TRGN-TRGN17" "TRGN-TRGN18" "TRGN-TRGN19" "TRGN-TRGN20"
## [1071] "TRGN-TRGN21" "TRGN-TRGN22" "TRGN-TRGN23" "TRGN-TRGN24" "TRGN-TRGN25"
## [1076] "TRGN-TRGN26" "TRGN-TRGN27" "TRGN-TRGN28" "ROCO-ROCO01" "ROCO-ROCO02"
## [1081] "ROCO-ROCO03" "ROCO-ROCO04" "ROCO-ROCO05" "ROCO-ROCO06" "ROCO-ROCO08"
## [1086] "ROCO-ROCO09" "ROCO-ROCO10" "ROCO-ROCO11" "ROCO-ROCO12" "ROCO-ROCO13"
## [1091] "ROCO-ROCO14" "ROCO-ROCO15" "ROCO-ROCO16" "ROCO-ROCO17" "ROCO-ROCO18"
## [1096] "ROCO-ROCO19" "ROCO-ROCO20" "ROCO-ROCO21" "ROCO-ROCO22" "ROCO-ROCO23"
## [1101] "ROCO-ROCO24" "ROCO-ROCO25" "ROCO-ROCO26" "ROCO-ROCO27" "ROCO-ROCO28"
## [1106] "ROCO-ROCO29" "ROCO-ROCO30" "TRIS-TRIT01" "TRIS-TRIT02" "TRIS-TRIT04"
## [1111] "TRIS-TRIT05" "TRIS-TRIT07" "TRIS-TRIT08" "TRIS-TRIT09" "TRIS-TRIS01"
## [1116] "TRIS-TRIS02" "TRIS-TRIS03" "TRIS-TRIS04" "TRIS-TRIS05" "TRIS-TRIS06"
## [1121] "TRIS-TRIS07" "TRIS-TRIS08" "TRIS-TRIS09" "TRIS-TRIS10" "TRIS-TRIS11"
## [1126] "TRIS-TRIS12" "TRIS-TRIS13" "TRIS-TRIS14" "TRIS-TRIS15" "TRIS-TRIS16"
## [1131] "TRIS-TRIS17" "TRIS-TRIS18" "TRIS-TRIS19" "TRIS-TRIS20" "RURM-RURM02"
## [1136] "RURM-RURM06" "RURM-RURM07" "SOC-RUSO01"  "SOC-RUSO02"  "SOC-RUSO03" 
## [1141] "SOC-RUSO04"  "SOC-RUSO05"  "SOC-RUSO06"  "SOC-RUSO07"  "SOC-RUSO08" 
## [1146] "SOC-RUSO09"  "SOC-RUSO10"  "TRTR-TRTR01" "TRTR-TRTR02" "TRTR-TRTR03"
## [1151] "TRTR-TRTR04" "TRTR-TRTR05" "TRTR-TRTR06" "TRTR-TRTR07" "TRTR-TRTR08"
## [1156] "TRTR-TRTR09" "TRTR-TRTR10" "TRTR-TRTR11" "TRTR-TRTR12" "TRTR-TRTR13"
## [1161] "TRTR-TRTR15" "RUPL-RUPL01" "RUPL-RUPL02" "RUPL-RUPL03" "RUPL-RUPL04"
## [1166] "RUPL-RUPL05" "RUPL-RUPL07" "RUPL-RUPL08" "RUPL-RUPL09" "RUPL-RUPL10"
## [1171] "RUBE-RUBE06" "RUBE-RUBE07" "RUBE-RUBE08" "RUBE-RUBE09" "RUBE-RUBE10"
## [1176] "RUBE-RUBE11" "RUBE-RUBE12" "RUBE-RUBE13" "RUBE-RUBE14" "RUBE-RUBE15"
## [1181] "RUBE-RUBE16" "RUBE-RUBE17" "RUBE-RUBE18" "RUBE-RUBE19" "RUBE-RUBE20"
## [1186] "ABAL-ABAL01" "ABAL-ABAL02" "ABAL-ABGL05" "ABAL-ABIN01" "ABAL-ABIN02"
## [1191] "ABAL-ABIN06" "ABAL-ABIN07" "ABAL-ABKH01" "ABAL-ABKH02" "ABAL-ABKO04"
## [1196] "TRRI-TRRI02" "TRRI-TRRI03" "TRRI-TRRI04" "TRRI-TRRI05" "TRRI-TRRI06"
## [1201] "TRRI-TRRI10" "ABSU-ABSU01" "ABSU-ABSU02" "ABSU-ABSU03" "ABSU-ABSU04"
## [1206] "ABSU-ABSU05" "TUH-TRHO01"  "TUH-TRHO02"  "TUH-TRHO03"  "TUH-TRHO04" 
## [1211] "TUH-TRHO05"  "TUH-TRHO06"  "TUH-TRHO07"  "TUH-TRHO08"  "TUH-TRHO09" 
## [1216] "TUH-TRHO10"  "TUH-TRHO11"  "TUH-TRHO12"  "TUH-TRHO13"  "TUH-TRHO14" 
## [1221] "TUH-TRHO15"  "TUH-TRHO16"  "TUH-TRHO17"  "TUH-TRHO18"  "TUH-TRHO19" 
## [1226] "TUH-TRHO20"  "TUH-TRHO21"  "TUH-TRHO22"  "TUH-TRHO23"  "TUH-TRHO24" 
## [1231] "TUH-TRHO25"  "TUH-TRHO26"  "TUH-TRHO27"  "TUH-TRHO28"  "TUH-TRHO29" 
## [1236] "GEPO-GEPO01" "GEPO-GEPO02" "GEPO-GEPO03" "GEPO-GEPO04" "GEPO-GEPO05"
## [1241] "TRAR-TRAR01" "TRAR-TRAR02" "TRAR-TRAR03" "TRAR-TRAR04" "TRAR-TRAR06"
## [1246] "TRAR-TRAR07" "TRAR-TRAR08" "TRAR-TRAR10" "TRAR-TRAR11" "TRAR-TRAR12"
## [1251] "TRAR-TRAR13" "TRAR-TRAR14"

Save it as rds

saveRDS(
  all_pops, here(
    "output/europe/dapc/microsats/microsats_europe_all.rds"
  )
)

To load it

europe_all <- readRDS(
  here(
    "output/europe/dapc/microsats/microsats_europe_all.rds"
  )
)

3.1. Add countries

strata(europe_all) <- data.frame(pop(europe_all))

# Currently set on just 
head(pop(europe_all)) 
## [1] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
## 78 Levels: POP-PTPN60 POL-PTQT15 SPB-ESBD11 ESAC-ESAC07 ... TRAR-TRAR14
#pops <- as.data.frame(pop(europe_all))
#write.csv(pops, here("DAPC/pops.csv"))

3.2. Get Sample Locations

Import sample data Load the csv

sampling_loc <- read.csv(here("output/europe/dapc/microsats/sampling_loc_euro_microsats.csv"))
sampling_loc <- as.data.frame(sampling_loc)

head(sampling_loc)
##        Pop_City    Country  Latitude Longitude Continent Abbreviation
## 1      Gravatai     Brazil -29.93760 -50.99070  Americas          GRV
## 2 Puerto Iguazu  Argentina -25.59720 -54.57860  Americas          POR
## 3      Vohimasy Madagascar -22.81591  47.75026    Africa          VOH
## 4 Trois-Bassins    Reunion -21.10901  55.31921    Africa          TRO
## 5     Morondava Madagascar -20.28420  44.27940    Africa          MAD
## 6       Dauguet  Mauritius -20.18530  57.52154    Africa          DAU
##          Year        Region    Subregion order order2 orderold order_microsat
## 1        2018 South America                  8     NA       82             NA
## 2        2018 South America                 NA     NA       NA             NA
## 3 2016 & 2017   East Africa  East Africa    NA     79       NA             NA
## 4        2017  Indian Ocean Indian Ocean    81     81       73             NA
## 5        2016   East Africa  East Africa    80     78       72             NA
## 6        2022  Indian Ocean Indian Ocean    82     80       74             NA
##   microsats microsat_code alt_code  X  Country.1 X.1 X.2 X.3 X.4 X.5 X.6
## 1                                  NA     Brazil  NA  NA  NA  NA  NA  NA
## 2                                  NA  Argentina  NA  NA  NA  NA  NA  NA
## 3                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 4                                  NA    Reunion  NA  NA  NA  NA  NA  NA
## 5                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 6                                  NA  Mauritius  NA  NA  NA  NA  NA  NA

Save it as rds

saveRDS(
  sampling_loc, here(
    "output/europe/dapc/microsats/sampling_loc_euro_microsats.rds"
  )
)

To load it

sampling_loc <- readRDS(here("sampling_loc_euro_microsats.rds"))
head(sampling_loc)
##        Pop_City    Country  Latitude Longitude Continent Abbreviation
## 1      Gravatai     Brazil -29.93760 -50.99070  Americas          GRV
## 2 Puerto Iguazu  Argentina -25.59720 -54.57860  Americas          POR
## 3      Vohimasy Madagascar -22.81591  47.75026    Africa          VOH
## 4 Trois-Bassins    Reunion -21.10901  55.31921    Africa          TRO
## 5     Morondava Madagascar -20.28420  44.27940    Africa          MAD
## 6       Dauguet  Mauritius -20.18530  57.52154    Africa          DAU
##          Year        Region    Subregion order order2 orderold order_microsat
## 1        2018 South America                  8     NA       82             NA
## 2        2018 South America                 NA     NA       NA             NA
## 3 2016 & 2017   East Africa  East Africa    NA     79       NA             NA
## 4        2017  Indian Ocean Indian Ocean    81     81       73             NA
## 5        2016   East Africa  East Africa    80     78       72             NA
## 6        2022  Indian Ocean Indian Ocean    82     80       74             NA
##   microsats microsat_code alt_code  X  Country.1 X.1 X.2 X.3 X.4 X.5 X.6
## 1                                  NA     Brazil  NA  NA  NA  NA  NA  NA
## 2                                  NA  Argentina  NA  NA  NA  NA  NA  NA
## 3                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 4                                  NA    Reunion  NA  NA  NA  NA  NA  NA
## 5                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 6                                  NA  Mauritius  NA  NA  NA  NA  NA  NA

Load the csv

countr <- read.csv(here("output/europe/dapc/microsats/DAPC_countries_microsats.csv"
))
df <- as.data.frame(countr)

head(df)
##   pop  country
## 1 POP Portugal
## 2 POP Portugal
## 3 POP Portugal
## 4 POP Portugal
## 5 POP Portugal
## 6 POP Portugal
europe_all@pop <- as.factor(df$country)
europe_all$pop
##    [1] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##    [9] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [17] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [25] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [33] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [41] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [49] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [57] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [65] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [73] Portugal Portugal Portugal Spain    Spain    Spain    Spain    Spain   
##   [81] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##   [89] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##   [97] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [105] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [113] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [121] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [129] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [137] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [145] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [153] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [161] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [169] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [177] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [185] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [193] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [201] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [209] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [217] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [225] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [233] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [241] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [249] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [257] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [265] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [273] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [281] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [289] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [297] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [305] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [313] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [321] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [329] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [337] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [345] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [353] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [361] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [369] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [377] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [385] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [393] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [401] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [409] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [417] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [425] Spain    Spain    Spain    France   France   France   France   France  
##  [433] France   France   France   France   France   France   France   France  
##  [441] France   France   France   France   France   France   France   France  
##  [449] France   France   France   France   France   France   France   France  
##  [457] France   France   France   France   France   France   France   France  
##  [465] France   France   France   France   France   France   France   France  
##  [473] France   France   France   France   France   France   France   France  
##  [481] France   France   France   France   France   France   France   Italy   
##  [489] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [497] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [505] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [513] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [521] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [529] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [537] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [545] Italy    Italy    Italy    Slovenia Slovenia Slovenia Slovenia Slovenia
##  [553] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
##  [561] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
##  [569] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
##  [577] Slovenia Malta    Malta    Malta    Malta    Malta    Malta    Malta   
##  [585] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
##  [593] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
##  [601] Malta    Malta    Malta    Malta    Malta    Malta    Italy    Italy   
##  [609] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [617] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [625] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
##  [633] Italy    Italy    Italy    Italy    Croatia  Croatia  Croatia  Croatia 
##  [641] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
##  [649] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
##  [657] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
##  [665] Croatia  Croatia  Albania  Albania  Albania  Albania  Albania  Albania 
##  [673] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
##  [681] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
##  [689] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Serbia  
##  [697] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
##  [705] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
##  [713] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
##  [721] Serbia   Serbia   Serbia   Serbia   Romania  Romania  Romania  Romania 
##  [729] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [737] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [745] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [753] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [761] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [769] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [777] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [785] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [793] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [801] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [809] Romania  Romania  Romania  Romania  Greece   Greece   Greece   Greece  
##  [817] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [825] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [833] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [841] Greece   Greece   Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
##  [849] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
##  [857] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
##  [865] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Romania 
##  [873] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [881] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [889] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Greece  
##  [897] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [905] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [913] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [921] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [929] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [937] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [945] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [953] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [961] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [969] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [977] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [985] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [993] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [1001] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [1009] Greece   Greece   Greece   Greece   Romania  Romania  Romania  Romania 
## [1017] Romania  Romania  Romania  Romania  Turkey   Turkey   Turkey   Turkey  
## [1025] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1033] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1041] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1049] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1057] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1065] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1073] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Romania  Romania 
## [1081] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [1089] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [1097] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [1105] Romania  Romania  Romania  Turkey   Turkey   Turkey   Turkey   Turkey  
## [1113] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1121] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1129] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Russia   Russia  
## [1137] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [1145] Russia   Russia   Russia   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1153] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1161] Turkey   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [1169] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [1177] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [1185] Russia   Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia 
## [1193] Georgia  Georgia  Georgia  Turkey   Turkey   Turkey   Turkey   Turkey  
## [1201] Turkey   Georgia  Georgia  Georgia  Georgia  Georgia  Turkey   Turkey  
## [1209] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1217] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1225] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1233] Turkey   Turkey   Turkey   Georgia  Georgia  Georgia  Georgia  Georgia 
## [1241] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [1249] Turkey   Turkey   Turkey   Turkey  
## 15 Levels: Albania Bulgaria Croatia France Georgia Greece Italy ... Turkey

Save the genind object

saveRDS(europe_all, here("output/europe/dapc/microsats/microsat_country.rds"
))

Load the genind object

microsat_country <- readRDS(here("output/europe/dapc/microsats/microsat_country.rds"
))

3.3. Scale

microsat_country <- scaleGen(europe_all, NA.method="mean")
class(microsat_country)
## [1] "matrix" "array"
dim(microsat_country)
## [1] 1252  189
microsat_country[1:5,1:5]
##               MIC2.180    MIC2.183   MIC2.186  MIC2.181  MIC2.184
## POP-PTPN01  7.65828619  8.78896690 -0.0492656 -1.064093 -1.444994
## POP-PTPN02  7.65828619  8.78896690 -0.0492656 -1.064093 -1.444994
## POP-PTPN03  7.65828619  8.78896690 -0.0492656 -1.064093 -1.444994
## POP-PTPN04 -0.09339373 17.66347120 -0.0492656 -1.064093 -1.444994
## POP-PTPN05 15.40996612 -0.08553739 -0.0492656 -1.064093 -1.444994
# Get the populations from the genlight object
populations <- europe_all$pop

3.4. Find clusters

grp <- find.clusters(microsat_country, max.n.clust=20)
#retained 200
#Choose the number of clusters (>=2): 70?

Save the genind object

saveRDS(grp, here("output/europe/dapc/microsats/grp_20.rds"
))

Load the genind object

grp <- readRDS(here("output/europe/dapc/microsats/grp_20.rds"))
names(grp)
## [1] "Kstat" "stat"  "grp"   "size"
grp$size #group sizes for our clusters
##  [1] 410   6   7   1  77   4   1   6  75  12   4   8   5   4  17 393  14  12 121
## [20]  75
table(pop(europe_all), grp$grp)
##           
##              1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17
##   Albania    2   0   0   0   3   0   0   0   2   0   0   0   0   1   0  21   0
##   Bulgaria   3   0   0   0   1   0   0   0   1   0   0   0   0   0   0  24   0
##   Croatia    3   0   0   0   1   0   0   0   9   0   0   0   0   0   0  17   0
##   France    17   1   0   0   4   0   0   0   1   0   0   0   1   0   0  14   0
##   Georgia    7   0   0   0   0   0   0   0   0   0   0   1   0   0   0  12   0
##   Greece    17   0   5   0   2   0   0   0  12   2   0   6   1   0   0 101   0
##   Italy     20   3   0   0   3   0   0   0   7   0   0   0   0   0   1  29   0
##   Malta     17   0   0   0   1   0   0   0   0   0   0   0   0   0   3   6   0
##   Portugal  23   0   0   0  21   0   0   0   0   2   0   0   0   3   0   1   0
##   Romania   75   1   1   0  13   0   0   1   0   4   0   0   0   0   0  25   0
##   Russia    13   0   1   0   0   0   0   0   0   0   0   0   0   0   1  22   0
##   Serbia     2   0   0   0   1   0   0   0   5   0   0   0   0   0   0  21   0
##   Slovenia   7   0   0   0   1   0   0   0   0   0   0   0   0   0   2  20   0
##   Spain    133   1   0   1   7   4   1   5  33   4   0   1   2   0   9  64  14
##   Turkey    71   0   0   0  19   0   0   0   5   0   4   0   1   0   1  16   0
##           
##             18  19  20
##   Albania    0   0   0
##   Bulgaria   0   0   0
##   Croatia    0   0   0
##   France     0   0  22
##   Georgia    0   0   0
##   Greece     0   1   0
##   Italy      0   0  27
##   Malta      0   2   0
##   Portugal  12  13   0
##   Romania    0  29   0
##   Russia     0   0   0
##   Serbia     0   0   0
##   Slovenia   0   0   0
##   Spain      0  73   0
##   Turkey     0   3  26

3.5. Run dapc

dapc1 <- dapc(microsat_country, grp$grp)
#200 PCs retained
#21 discriminant functions retained

Save the genind object

saveRDS(dapc1, here("output/europe/dapc/microsats/dapc1.rds"
))

Load the genind object

dapc1 <- readRDS(here("output/europe/dapc/microsats/dapc1.rds"
))
dapc1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1)
## 
## $n.pca: 175 first PCs of PCA used
## $n.da: 20 discriminant functions saved
## $var (proportion of conserved variance): 1
## 
## $eig (eigenvalues): 1.27e+32 8.011e+31 7193000 1991000 874600 ...
## 
##   vector    length content                   
## 1 $eig      20     eigenvalues               
## 2 $grp      1252   prior group assignment    
## 3 $prior    20     prior group probabilities 
## 4 $assign   1252   posterior group assignment
## 5 $pca.cent 189    centring vector of PCA    
## 6 $pca.norm 189    scaling vector of PCA     
## 7 $pca.eig  175    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          1252 175  retained PCs of PCA                              
## 2 $means        20   175  group means                                      
## 3 $loadings     175  20   loadings of variables                            
## 4 $ind.coord    1252 20   coordinates of individuals (principal components)
## 5 $grp.coord    20   20   coordinates of groups                            
## 6 $posterior    1252 20   posterior membership probabilities               
## 7 $pca.loadings 189  175  PCA loadings of original variables               
## 8 $var.contr    189  20   contribution of original variables

3.6. Calculating the optimum PC number to rerun DAPC

optim.a.score(dapc1, n.pca=1:ncol(dapc1$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10) #calculating optimal number of PCs
#Optimal number = 26

3.7. Now do cross-validation

Cross-validation: The Discriminant Analysis of Principal Components (DAPC) relies on dimension reduction of the data using PCA followed by a linear discriminant analysis. How many PCA axes to retain is often a non-trivial question. Cross validation provides an objective way to decide how many axes to retain: different numbers are tried and the quality of the corresponding DAPC is assessed by cross- validation: DAPC is performed on a training set, typically made of 90% of the observations (comprising 90% of the observations in each subpopulation) , and then used to predict the groups of the 10% of remaining observations. The current method uses the average prediction success per group (result=“groupMean”), or the overall prediction success (result=“overall”). The number of PCs associated with the lowest Mean Squared Error is then retained in the DAPC.

xvalDapc(microsat_country, populations, n.pca.max = 200, n.da = NULL,
              training.set = 0.9, result = c("groupMean", "overall"),
              center = TRUE, scale = FALSE,
              n.pca=NULL, n.rep = 30, xval.plot = TRUE) 

## $`Cross-Validation Results`
##     n.pca   success
## 1      20 0.3803704
## 2      20 0.3743386
## 3      20 0.3492063
## 4      20 0.4496825
## 5      20 0.3478836
## 6      20 0.3787831
## 7      20 0.4215873
## 8      20 0.3866667
## 9      20 0.3936508
## 10     20 0.5329101
## 11     20 0.4070899
## 12     20 0.2666138
## 13     20 0.4225926
## 14     20 0.4067725
## 15     20 0.4477249
## 16     20 0.3144974
## 17     20 0.4384656
## 18     20 0.3810053
## 19     20 0.4119577
## 20     20 0.3601587
## 21     20 0.3852381
## 22     20 0.3339683
## 23     20 0.3551852
## 24     20 0.4291534
## 25     20 0.3813757
## 26     20 0.4636508
## 27     20 0.3746561
## 28     20 0.4000000
## 29     20 0.3001587
## 30     20 0.3591534
## 31     40 0.4014815
## 32     40 0.5032275
## 33     40 0.4540212
## 34     40 0.5309524
## 35     40 0.3625926
## 36     40 0.4295767
## 37     40 0.4317989
## 38     40 0.4034392
## 39     40 0.4986243
## 40     40 0.4070370
## 41     40 0.4193122
## 42     40 0.4125397
## 43     40 0.5560847
## 44     40 0.4148148
## 45     40 0.4339153
## 46     40 0.3826984
## 47     40 0.4620635
## 48     40 0.4858201
## 49     40 0.5643386
## 50     40 0.4430159
## 51     40 0.5651852
## 52     40 0.3759788
## 53     40 0.3482011
## 54     40 0.4398942
## 55     40 0.5004762
## 56     40 0.5459259
## 57     40 0.4444974
## 58     40 0.4215344
## 59     40 0.5525397
## 60     40 0.4694709
## 61     60 0.5136508
## 62     60 0.5874603
## 63     60 0.5248677
## 64     60 0.5771958
## 65     60 0.5021693
## 66     60 0.4938624
## 67     60 0.3812169
## 68     60 0.4451323
## 69     60 0.5495767
## 70     60 0.6119577
## 71     60 0.5438095
## 72     60 0.4853968
## 73     60 0.5820635
## 74     60 0.5888360
## 75     60 0.4204762
## 76     60 0.5418519
## 77     60 0.4534392
## 78     60 0.5828042
## 79     60 0.5733862
## 80     60 0.4167725
## 81     60 0.6570899
## 82     60 0.5355026
## 83     60 0.5387302
## 84     60 0.4422222
## 85     60 0.6008995
## 86     60 0.4447090
## 87     60 0.4502116
## 88     60 0.4382540
## 89     60 0.4997884
## 90     60 0.5159788
## 91     80 0.5016402
## 92     80 0.5256085
## 93     80 0.5351323
## 94     80 0.5039153
## 95     80 0.4835979
## 96     80 0.5193651
## 97     80 0.7158730
## 98     80 0.5348148
## 99     80 0.5354497
## 100    80 0.4386772
## 101    80 0.6655556
## 102    80 0.4986243
## 103    80 0.5143386
## 104    80 0.5882011
## 105    80 0.5593651
## 106    80 0.5699471
## 107    80 0.5148148
## 108    80 0.5728571
## 109    80 0.5321693
## 110    80 0.5275661
## 111    80 0.5325397
## 112    80 0.4971429
## 113    80 0.6362963
## 114    80 0.5637566
## 115    80 0.6120635
## 116    80 0.5335450
## 117    80 0.5846561
## 118    80 0.5204233
## 119    80 0.5384127
## 120    80 0.5888360
## 121   100 0.6215344
## 122   100 0.4435979
## 123   100 0.5726455
## 124   100 0.5843386
## 125   100 0.5219048
## 126   100 0.5629630
## 127   100 0.4852910
## 128   100 0.5256085
## 129   100 0.5006878
## 130   100 0.5580952
## 131   100 0.5483069
## 132   100 0.4713228
## 133   100 0.5832804
## 134   100 0.5300000
## 135   100 0.5112169
## 136   100 0.5162434
## 137   100 0.5710582
## 138   100 0.5670370
## 139   100 0.5332804
## 140   100 0.5221693
## 141   100 0.4648148
## 142   100 0.5294709
## 143   100 0.5885714
## 144   100 0.4835979
## 145   100 0.5417989
## 146   100 0.5568254
## 147   100 0.5642328
## 148   100 0.6224339
## 149   100 0.5621164
## 150   100 0.5435979
## 151   120 0.5678307
## 152   120 0.5415873
## 153   120 0.5459259
## 154   120 0.4814815
## 155   120 0.6589418
## 156   120 0.5680952
## 157   120 0.5138624
## 158   120 0.6082540
## 159   120 0.6787302
## 160   120 0.5043915
## 161   120 0.6173545
## 162   120 0.4959259
## 163   120 0.5917460
## 164   120 0.6396296
## 165   120 0.5987831
## 166   120 0.6071958
## 167   120 0.4485185
## 168   120 0.6123810
## 169   120 0.6121693
## 170   120 0.6193122
## 171   120 0.6490476
## 172   120 0.5127513
## 173   120 0.5700000
## 174   120 0.5770899
## 175   120 0.4765608
## 176   120 0.4871958
## 177   120 0.6631217
## 178   120 0.5650265
## 179   120 0.5742328
## 180   120 0.5332275
## 181   140 0.5956614
## 182   140 0.5964550
## 183   140 0.5204762
## 184   140 0.5443915
## 185   140 0.5690476
## 186   140 0.6707937
## 187   140 0.5868254
## 188   140 0.5999471
## 189   140 0.6210582
## 190   140 0.5529101
## 191   140 0.4768783
## 192   140 0.5835450
## 193   140 0.5232275
## 194   140 0.5255026
## 195   140 0.5404233
## 196   140 0.5884127
## 197   140 0.5737566
## 198   140 0.5286243
## 199   140 0.6272487
## 200   140 0.6931217
## 201   140 0.4797354
## 202   140 0.6017460
## 203   140 0.4987302
## 204   140 0.5443915
## 205   140 0.6802646
## 206   140 0.5434392
## 207   140 0.5418519
## 208   140 0.5268254
## 209   140 0.5853968
## 210   140 0.6353439
## 211   160 0.5572487
## 212   160 0.4794180
## 213   160 0.6719048
## 214   160 0.5330688
## 215   160 0.4447090
## 216   160 0.5863492
## 217   160 0.5867196
## 218   160 0.5035450
## 219   160 0.5864550
## 220   160 0.5056085
## 221   160 0.5649206
## 222   160 0.5011640
## 223   160 0.5588889
## 224   160 0.5445503
## 225   160 0.5539153
## 226   160 0.6515873
## 227   160 0.5532804
## 228   160 0.4708995
## 229   160 0.5087302
## 230   160 0.5884127
## 231   160 0.5582540
## 232   160 0.5349735
## 233   160 0.5757672
## 234   160 0.5722222
## 235   160 0.5639153
## 236   160 0.4694709
## 237   160 0.6046561
## 238   160 0.4814286
## 239   160 0.6240212
## 240   160 0.5404762
## 
## $`Median and Confidence Interval for Random Chance`
##       2.5%        50%      97.5% 
## 0.05324672 0.06543681 0.08107001 
## 
## $`Mean Successful Assignment by Number of PCs of PCA`
##        20        40        60        80       100       120       140       160 
## 0.3884832 0.4553686 0.5166437 0.5481728 0.5396014 0.5706790 0.5718677 0.5492187 
## 
## $`Number of PCs Achieving Highest Mean Success`
## [1] "140"
## 
## $`Root Mean Squared Error by Number of PCs of PCA`
##        20        40        60        80       100       120       140       160 
## 0.6136742 0.5480642 0.4879886 0.4551804 0.4623702 0.4335367 0.4315412 0.4538494 
## 
## $`Number of PCs Achieving Lowest MSE`
## [1] "140"
## 
## $DAPC
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1, n.pca = ..2, 
##     n.da = ..3)
## 
## $n.pca: 140 first PCs of PCA used
## $n.da: 14 discriminant functions saved
## $var (proportion of conserved variance): 0.921
## 
## $eig (eigenvalues): 190.2 129.1 106.2 95.35 79.23 ...
## 
##   vector    length content                   
## 1 $eig      14     eigenvalues               
## 2 $grp      1252   prior group assignment    
## 3 $prior    15     prior group probabilities 
## 4 $assign   1252   posterior group assignment
## 5 $pca.cent 189    centring vector of PCA    
## 6 $pca.norm 189    scaling vector of PCA     
## 7 $pca.eig  175    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          1252 140  retained PCs of PCA                              
## 2 $means        15   140  group means                                      
## 3 $loadings     140  14   loadings of variables                            
## 4 $ind.coord    1252 14   coordinates of individuals (principal components)
## 5 $grp.coord    15   14   coordinates of groups                            
## 6 $posterior    1252 15   posterior membership probabilities               
## 7 $pca.loadings 189  140  PCA loadings of original variables               
## 8 $var.contr    189  14   contribution of original variables

$n.pca: 160 first PCs of PCA used $n.da: 14 discriminant functions saved $var (proportion of conserved variance): 0.975

Run DAPC with object using x-val recommendations

dapc_micro_1 <- dapc(microsat_country, n.pca = 140, n.da = 14, grp = populations)
dapc_micro_1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..3, n.pca = 140, 
##     n.da = 14)
## 
## $n.pca: 140 first PCs of PCA used
## $n.da: 14 discriminant functions saved
## $var (proportion of conserved variance): 0.921
## 
## $eig (eigenvalues): 190.2 129.1 106.2 95.35 79.23 ...
## 
##   vector    length content                   
## 1 $eig      14     eigenvalues               
## 2 $grp      1252   prior group assignment    
## 3 $prior    15     prior group probabilities 
## 4 $assign   1252   posterior group assignment
## 5 $pca.cent 189    centring vector of PCA    
## 6 $pca.norm 189    scaling vector of PCA     
## 7 $pca.eig  175    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          1252 140  retained PCs of PCA                              
## 2 $means        15   140  group means                                      
## 3 $loadings     140  14   loadings of variables                            
## 4 $ind.coord    1252 14   coordinates of individuals (principal components)
## 5 $grp.coord    15   14   coordinates of groups                            
## 6 $posterior    1252 15   posterior membership probabilities               
## 7 $pca.loadings 189  140  PCA loadings of original variables               
## 8 $var.contr    189  14   contribution of original variables

dapc with optimal # of PCs recommended

dapc_micro_2 <- dapc(microsat_country, n.pca = 26, n.da = 14, grp = populations)
dapc_micro_2
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..3, n.pca = 26, 
##     n.da = 14)
## 
## $n.pca: 26 first PCs of PCA used
## $n.da: 14 discriminant functions saved
## $var (proportion of conserved variance): 0.294
## 
## $eig (eigenvalues): 122.3 70.07 55.45 46.08 25.06 ...
## 
##   vector    length content                   
## 1 $eig      14     eigenvalues               
## 2 $grp      1252   prior group assignment    
## 3 $prior    15     prior group probabilities 
## 4 $assign   1252   posterior group assignment
## 5 $pca.cent 189    centring vector of PCA    
## 6 $pca.norm 189    scaling vector of PCA     
## 7 $pca.eig  175    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          1252 26   retained PCs of PCA                              
## 2 $means        15   26   group means                                      
## 3 $loadings     26   14   loadings of variables                            
## 4 $ind.coord    1252 14   coordinates of individuals (principal components)
## 5 $grp.coord    15   14   coordinates of groups                            
## 6 $posterior    1252 15   posterior membership probabilities               
## 7 $pca.loadings 189  26   PCA loadings of original variables               
## 8 $var.contr    189  14   contribution of original variables

only 29% of variance retained with this one

Most contributing alleles

set.seed(4) 
contrib<-loadingplot(dapc_micro_1$var.contr,axis=2, thres=.0002,lab.jitter=3)

set.seed(4) 
contrib<-loadingplot(dapc_micro_2$var.contr,axis=2, thres=.0002,lab.jitter=3)

3.8. Plots

scatter(dapc_micro_1)

scatter(dapc_micro_2)

Check R symbols for plot

#to see all shapes -> plot shapes - para escolher os simbolos
N = 100; M = 1000
good.shapes = c(1:25,35:38,43,60,62:64)
foo = data.frame( x = rnorm(M), y = rnorm(M), s = factor( sample(1:N, M, replace = TRUE) ) )
ggplot(aes(x,y,shape=s ), data=foo ) +
  scale_shape_manual(values=good.shapes[1:N]) +
  geom_point()
## Warning: Removed 690 rows containing missing values or values outside the scale range
## (`geom_point()`).

#1:25,28:31,36,55:57
myCol2 <- c("#51f310", "#146c45", "#75d5e1", "#FF7F00", "magenta", "red",  "yellow3", "#52ef99", "#2524f9",  "#1E90FF", "purple", "#fda547", "#cf749b", "#332288", "#a41415")  

Plot using different discriminant functions

1 & 2

pdf(file = "output/europe/dapc/microsats/dapc_micro_all_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

For comparison

op <- par(cex = 0.39)
scatter(dapc_micro_2, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

1 & 3

pdf(file = "output/europe/dapc/microsats/dapc_micro_all_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/microsats/dapc_micro_all_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

2 & 3

pdf(file = "output/europe/dapc/microsats/dapc_micro_all_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

2 & 4

pdf(file = "output/europe/dapc/microsats/dapc_micro_all_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=4)

4. DAPC for subsets of pops (for all individuals in microsatellite dataset)

4.1. Iberia

4.1.1. Load .gen file with microsat data from all individuals

iberia <- read.genepop("output/europe/dapc/microsats/iberia/for_dapc_albo_microsats_iberia.gen", ncode=3L)
## 
##  Converting data from a Genepop .gen file to a genind object... 
## 
## 
## File description:  ARBOMONITOR_Aedes_albopictus_iberia                                            
## 
## ...done.
iberia
## /// GENIND OBJECT /////////
## 
##  // 427 individuals; 11 loci; 159 alleles; size: 330.7 Kb
## 
##  // Basic content
##    @tab:  427 x 159 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 5-24)
##    @loc.fac: locus factor for the 159 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: read.genepop(file = "output/europe/dapc/microsats/iberia/for_dapc_albo_microsats_iberia.gen", 
##     ncode = 3L)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 1-60)
pop(iberia)
##   [1] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [7] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [13] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [19] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [25] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [31] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [37] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [43] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [49] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [55] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [61] POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15 
##  [67] POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15 
##  [73] POL-PTQT15  POL-PTQT15  POL-PTQT15  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11 
##  [79] SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11 
##  [85] SPB-ESBD11  SPB-ESBD11  ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07
##  [91] ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
##  [97] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
## [103] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
## [109] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15
## [115] ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15
## [121] ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESAL-ESAL06 ESAL-ESAL06
## [127] ESAL-ESAL06 ESAL-ESAL06 ESAL-ESAL06 ESAL-ESAL06 SPS-ESUP10  SPS-ESUP10 
## [133] SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10 
## [139] SPS-ESUP10  SPS-ESUP10  ESMN-ESMN04 ESMN-ESMN04 ESMN-ESMN04 ESLS-ESLS03
## [145] ESLS-ESLS03 ESLS-ESLS03 ESMV-ESMV03 ESMV-ESMV03 ESMV-ESMV03 ESFU-ESFU03
## [151] ESFU-ESFU03 ESFU-ESFU03 ESBM-ESBT03 ESBM-ESBT03 ESBM-ESBT03 ESBM-ESBT03
## [157] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10
## [163] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10
## [169] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESGD-ESGD02 ESGD-ESGD02 ESBN-ESBN06
## [175] ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESSL-ESSL03
## [181] ESSL-ESSL03 ESSL-ESSL03 ESMC-ESMT03 ESMC-ESMT03 ESMC-ESMT03 ESMC-ESMT03
## [187] ESVN-ESVN04 ESPT-ESPT03 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15
## [193] ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15
## [199] ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESBY-ESBY06 ESBY-ESBY06
## [205] ESBY-ESBY06 ESBY-ESBY06 ESBY-ESBY06 ESBY-ESBY06 ESNI-ESNI10 ESNI-ESNI10
## [211] ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10
## [217] ESNI-ESNI10 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06
## [223] ESNU-ESNU06 ESIR-ESIR03 ESIR-ESIR03 ESIR-ESIR03 ESAG-ESAG10 ESAG-ESAG10
## [229] ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10
## [235] ESAG-ESAG10 ESAG-ESAG10 ESAZ-ESAZ04 ESAZ-ESAZ04 ESAZ-ESAZ04 ESAZ-ESAZ04
## [241] ESCN-ESCN04 ESCN-ESCN04 ESCN-ESCN04 ESCN-ESCN04 ESCT-ESTT01 ESCT-ESTT01
## [247] ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01
## [253] ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01
## [259] ESCT-ESTT01 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
## [265] ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
## [271] ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
## [277] ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06
## [283] ESCH-ESCH02 ESCH-ESCH02 ESLM-ESLM04 ESLM-ESLM04 ESLM-ESLM04 ESLM-ESLM04
## [289] ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESAY-ESAY10
## [295] ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10
## [301] ESAY-ESAY10 ESAY-ESAY10 SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
## [307] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
## [313] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
## [319] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  ESBS-ESBC07 ESBS-ESBC07
## [325] ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07
## [331] ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07
## [337] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15
## [343] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15
## [349] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10
## [355] ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10
## [361] ESTS-ESTS10 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [367] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [373] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [379] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [385] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESCP-ESCP19
## [391] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
## [397] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
## [403] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
## [409] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
## [415] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
## [421] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
## [427] SPM-ESMG19 
## 42 Levels: POP-PTPN60 POL-PTQT15 SPB-ESBD11 ESAC-ESAC07 ... SPM-ESMG19
nInd(iberia)
## [1] 427
nLoc(iberia)
## [1] 11
nPop(iberia)
## [1] 42
indNames(iberia)
##   [1] "POP-PTPN01"  "POP-PTPN02"  "POP-PTPN03"  "POP-PTPN04"  "POP-PTPN05" 
##   [6] "POP-PTPN06"  "POP-PTPN07"  "POP-PTPN08"  "POP-PTPN09"  "POP-PTPN10" 
##  [11] "POP-PTPN11"  "POP-PTPN12"  "POP-PTPN13"  "POP-PTPN14"  "POP-PTPN15" 
##  [16] "POP-PTPN16"  "POP-PTPN17"  "POP-PTPN18"  "POP-PTPN19"  "POP-PTPN20" 
##  [21] "POP-PTPN21"  "POP-PTPN22"  "POP-PTPN23"  "POP-PTPN24"  "POP-PTPN25" 
##  [26] "POP-PTPN26"  "POP-PTPN27"  "POP-PTPN28"  "POP-PTPN29"  "POP-PTPN30" 
##  [31] "POP-PTPN31"  "POP-PTPN32"  "POP-PTPN33"  "POP-PTPN34"  "POP-PTPN35" 
##  [36] "POP-PTPN36"  "POP-PTPN37"  "POP-PTPN38"  "POP-PTPN39"  "POP-PTPN40" 
##  [41] "POP-PTPN41"  "POP-PTPN42"  "POP-PTPN43"  "POP-PTPN44"  "POP-PTPN45" 
##  [46] "POP-PTPN46"  "POP-PTPN47"  "POP-PTPN48"  "POP-PTPN49"  "POP-PTPN50" 
##  [51] "POP-PTPN51"  "POP-PTPN52"  "POP-PTPN53"  "POP-PTPN54"  "POP-PTPN55" 
##  [56] "POP-PTPN56"  "POP-PTPN57"  "POP-PTPN58"  "POP-PTPN59"  "POP-PTPN60" 
##  [61] "POL-PTQT01"  "POL-PTQT02"  "POL-PTQT03"  "POL-PTQT04"  "POL-PTQT05" 
##  [66] "POL-PTQT06"  "POL-PTQT07"  "POL-PTQT08"  "POL-PTQT09"  "POL-PTQT10" 
##  [71] "POL-PTQT11"  "POL-PTQT12"  "POL-PTQT13"  "POL-PTQT14"  "POL-PTQT15" 
##  [76] "SPB-ESBD01"  "SPB-ESBD02"  "SPB-ESBD03"  "SPB-ESBD04"  "SPB-ESBD05" 
##  [81] "SPB-ESBD06"  "SPB-ESBD07"  "SPB-ESBD08"  "SPB-ESBD09"  "SPB-ESBD10" 
##  [86] "SPB-ESBD11"  "ESAC-ESAC01" "ESAC-ESAC02" "ESAC-ESAC03" "ESAC-ESAC04"
##  [91] "ESAC-ESAC05" "ESAC-ESAC06" "ESAC-ESAC07" "ESMO-ESMO01" "ESMO-ESMO02"
##  [96] "ESMO-ESMO03" "ESMO-ESMO04" "ESMO-ESMO05" "ESMO-ESMO06" "ESMO-ESMO07"
## [101] "ESMO-ESMO08" "ESMO-ESMO09" "ESMO-ESMO10" "ESMO-ESMO11" "ESMO-ESMO12"
## [106] "ESMO-ESMO13" "ESMO-ESMO14" "ESMO-ESMO15" "ESMO-ESMO16" "ESMO-ESMO17"
## [111] "ESMO-ESMO18" "ESSV-ESSV01" "ESSV-ESSV02" "ESSV-ESSV03" "ESSV-ESSV05"
## [116] "ESSV-ESSV06" "ESSV-ESSV07" "ESSV-ESSV08" "ESSV-ESSV09" "ESSV-ESSV10"
## [121] "ESSV-ESSV11" "ESSV-ESSV12" "ESSV-ESSV13" "ESSV-ESSV15" "ESAL-ESAL01"
## [126] "ESAL-ESAL02" "ESAL-ESAL03" "ESAL-ESAL04" "ESAL-ESAL05" "ESAL-ESAL06"
## [131] "SPS-ESUP01"  "SPS-ESUP02"  "SPS-ESUP03"  "SPS-ESUP04"  "SPS-ESUP05" 
## [136] "SPS-ESUP06"  "SPS-ESUP07"  "SPS-ESUP08"  "SPS-ESUP09"  "SPS-ESUP10" 
## [141] "ESMN-ESMN01" "ESMN-ESMN03" "ESMN-ESMN04" "ESLS-ESLS01" "ESLS-ESLS02"
## [146] "ESLS-ESLS03" "ESMV-ESMV01" "ESMV-ESMV02" "ESMV-ESMV03" "ESFU-ESFU01"
## [151] "ESFU-ESFU02" "ESFU-ESFU03" "ESBM-ESBM01" "ESBM-ESBT01" "ESBM-ESBT02"
## [156] "ESBM-ESBT03" "ESTM-ESTM01" "ESTM-ESTM02" "ESTM-ESTO01" "ESTM-ESTO02"
## [161] "ESTM-ESTO03" "ESTM-ESTY01" "ESTM-ESTY02" "ESTM-ESTY03" "ESTM-ESTY04"
## [166] "ESTM-ESTY05" "ESTM-ESTY06" "ESTM-ESTY07" "ESTM-ESTY08" "ESTM-ESTY09"
## [171] "ESTM-ESTY10" "ESGD-ESGD01" "ESGD-ESGD02" "ESBN-ESBN01" "ESBN-ESBN02"
## [176] "ESBN-ESBN03" "ESBN-ESBN04" "ESBN-ESBN05" "ESBN-ESBN06" "ESSL-ESSL01"
## [181] "ESSL-ESSL02" "ESSL-ESSL03" "ESMC-ESMC03" "ESMC-ESMT01" "ESMC-ESMT02"
## [186] "ESMC-ESMT03" "ESVN-ESVN04" "ESPT-ESPT03" "ESAB-ESAB01" "ESAB-ESAB02"
## [191] "ESAB-ESAB03" "ESAB-ESAB04" "ESAB-ESAB05" "ESAB-ESAB06" "ESAB-ESAB07"
## [196] "ESAB-ESAB09" "ESAB-ESAB10" "ESAB-ESAB11" "ESAB-ESAB12" "ESAB-ESAB13"
## [201] "ESAB-ESAB14" "ESAB-ESAB15" "ESBY-ESBY01" "ESBY-ESBY02" "ESBY-ESBY03"
## [206] "ESBY-ESBY04" "ESBY-ESBY05" "ESBY-ESBY06" "ESNI-ESNI01" "ESNI-ESNI02"
## [211] "ESNI-ESNI04" "ESNI-ESNI05" "ESNI-ESNI06" "ESNI-ESNI07" "ESNI-ESNI08"
## [216] "ESNI-ESNI09" "ESNI-ESNI10" "ESNU-ESNU01" "ESNU-ESNU02" "ESNU-ESNU03"
## [221] "ESNU-ESNU04" "ESNU-ESNU05" "ESNU-ESNU06" "ESIR-ESIR01" "ESIR-ESIR02"
## [226] "ESIR-ESIR03" "ESAG-ESAG01" "ESAG-ESAG02" "ESAG-ESAG03" "ESAG-ESAG04"
## [231] "ESAG-ESAG05" "ESAG-ESAG06" "ESAG-ESAG07" "ESAG-ESAG08" "ESAG-ESAG09"
## [236] "ESAG-ESAG10" "ESAZ-ESAZ01" "ESAZ-ESAZ02" "ESAZ-ESAZ03" "ESAZ-ESAZ04"
## [241] "ESCN-ESCN01" "ESCN-ESCN02" "ESCN-ESCN03" "ESCN-ESCN04" "ESCT-ESCT01"
## [246] "ESCT-ESCT02" "ESCT-ESLA01" "ESCT-ESLA02" "ESCT-ESLU01" "ESCT-ESLU02"
## [251] "ESCT-ESLU03" "ESCT-ESLU04" "ESCT-ESLU05" "ESCT-ESLU06" "ESCT-ESLU07"
## [256] "ESCT-ESLU08" "ESCT-ESLU09" "ESCT-ESLU10" "ESCT-ESTT01" "ESMU-ESCV01"
## [261] "ESMU-ESCV02" "ESMU-ESCV03" "ESMU-ESCV04" "ESMU-ESMU01" "ESMU-ESMU02"
## [266] "ESMU-ESMU03" "ESMU-ESRM01" "ESMU-ESRM02" "ESMU-ESRM03" "ESMU-ESRM04"
## [271] "ESMU-ESRM05" "ESMU-ESRM06" "ESMU-ESRM07" "ESMU-ESRM08" "ESMU-ESRM09"
## [276] "ESMU-ESRM10" "ESPP-ESPP01" "ESPP-ESPP02" "ESPP-ESPP03" "ESPP-ESPP04"
## [281] "ESPP-ESPP05" "ESPP-ESPP06" "ESCH-ESCH01" "ESCH-ESCH02" "ESLM-ESLM01"
## [286] "ESLM-ESLM02" "ESLM-ESLM03" "ESLM-ESLM04" "ESCA-ESCA01" "ESCA-ESCA02"
## [291] "ESCA-ESCA03" "ESCA-ESCA04" "ESCA-ESCA05" "ESAY-ESAY01" "ESAY-ESAY02"
## [296] "ESAY-ESAY03" "ESAY-ESAY04" "ESAY-ESAY05" "ESAY-ESAY06" "ESAY-ESAY07"
## [301] "ESAY-ESAY09" "ESAY-ESAY10" "SPC-ESVL01"  "SPC-ESVL02"  "SPC-ESVL03" 
## [306] "SPC-ESVL04"  "SPC-ESVL05"  "SPC-ESVL06"  "SPC-ESVL07"  "SPC-ESVL08" 
## [311] "SPC-ESVL09"  "SPC-ESVL10"  "SPC-ESVL11"  "SPC-ESVL12"  "SPC-ESVL13" 
## [316] "SPC-ESVL14"  "SPC-ESVL15"  "SPC-ESVL16"  "SPC-ESVL17"  "SPC-ESVL18" 
## [321] "SPC-ESVL19"  "SPC-ESVL20"  "ESBS-ESBS01" "ESBS-ESBS02" "ESBS-ESBS03"
## [326] "ESBS-ESBS04" "ESBS-ESBS05" "ESBS-ESBS06" "ESBS-ESBS07" "ESBS-ESBC01"
## [331] "ESBS-ESBC02" "ESBS-ESBC03" "ESBS-ESBC04" "ESBS-ESBC05" "ESBS-ESBC06"
## [336] "ESBS-ESBC07" "ESBE-ESBE01" "ESBE-ESBE02" "ESBE-ESBE03" "ESBE-ESBE04"
## [341] "ESBE-ESBE05" "ESBE-ESBE06" "ESBE-ESBE07" "ESBE-ESBE08" "ESBE-ESBE09"
## [346] "ESBE-ESBE10" "ESBE-ESBE11" "ESBE-ESBE12" "ESBE-ESBE13" "ESBE-ESBE14"
## [351] "ESBE-ESBE15" "ESTS-ESTS01" "ESTS-ESTS02" "ESTS-ESTS03" "ESTS-ESTS04"
## [356] "ESTS-ESTS05" "ESTS-ESTS06" "ESTS-ESTS07" "ESTS-ESTS08" "ESTS-ESTS09"
## [361] "ESTS-ESTS10" "ESBA-ESBA01" "ESBA-ESBA02" "ESBA-ESBA03" "ESBA-ESBA04"
## [366] "ESBA-ESBA05" "ESBA-ESBA06" "ESBA-ESBA07" "ESBA-ESBA08" "ESBA-ESBA09"
## [371] "ESBA-ESBA10" "ESBA-ESBA11" "ESBA-ESBA12" "ESBA-ESBA13" "ESBA-ESBA14"
## [376] "ESBA-ESBA15" "ESBA-ESBA16" "ESBA-ESBA17" "ESBA-ESBA18" "ESBA-ESBA19"
## [381] "ESBA-ESBA20" "ESBA-ESBA21" "ESBA-ESBA22" "ESBA-ESBA23" "ESBA-ESBA24"
## [386] "ESBA-ESBA25" "ESBA-ESBA26" "ESBA-ESBA27" "ESBA-ESBA28" "ESCP-ESCP01"
## [391] "ESCP-ESCP02" "ESCP-ESCP03" "ESCP-ESCP04" "ESCP-ESCP05" "ESCP-ESCP06"
## [396] "ESCP-ESCP07" "ESCP-ESCP08" "ESCP-ESCP09" "ESCP-ESCP10" "ESCP-ESCP11"
## [401] "ESCP-ESCP12" "ESCP-ESCP13" "ESCP-ESCP14" "ESCP-ESCP15" "ESCP-ESCP16"
## [406] "ESCP-ESCP17" "ESCP-ESCP18" "ESCP-ESCP19" "SPM-ESMG01"  "SPM-ESMG02" 
## [411] "SPM-ESMG03"  "SPM-ESMG04"  "SPM-ESMG05"  "SPM-ESMG06"  "SPM-ESMG07" 
## [416] "SPM-ESMG08"  "SPM-ESMG09"  "SPM-ESMG10"  "SPM-ESMG11"  "SPM-ESMG12" 
## [421] "SPM-ESMG13"  "SPM-ESMG14"  "SPM-ESMG15"  "SPM-ESMG16"  "SPM-ESMG17" 
## [426] "SPM-ESMG18"  "SPM-ESMG19"

Save it as rds

saveRDS(
  iberia, here(
    "output/europe/dapc/microsats/iberia/microsats_europe_iberia.rds"
  )
)

To load it

iberia <- readRDS(
  here(
    "output/europe/dapc/microsats/iberia//microsats_europe_iberia.rds"
  )
)

4.1.2. Add countries

strata(iberia) <- data.frame(pop(iberia))

# Currently set on just 
head(pop(iberia)) 
## [1] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
## 42 Levels: POP-PTPN60 POL-PTQT15 SPB-ESBD11 ESAC-ESAC07 ... SPM-ESMG19
#pops_iberia <- as.data.frame(pop(iberia))
#write.csv(pops_iberia, here("DAPC/pops_iberia.csv"))

4.1.3. Get Sample Locations

Import sample data Load the csv

sampling_loc <- read.csv(here("output/europe/dapc/microsats/sampling_loc_euro_microsats.csv"))
sampling_loc <- as.data.frame(sampling_loc)

head(sampling_loc)
##        Pop_City    Country  Latitude Longitude Continent Abbreviation
## 1      Gravatai     Brazil -29.93760 -50.99070  Americas          GRV
## 2 Puerto Iguazu  Argentina -25.59720 -54.57860  Americas          POR
## 3      Vohimasy Madagascar -22.81591  47.75026    Africa          VOH
## 4 Trois-Bassins    Reunion -21.10901  55.31921    Africa          TRO
## 5     Morondava Madagascar -20.28420  44.27940    Africa          MAD
## 6       Dauguet  Mauritius -20.18530  57.52154    Africa          DAU
##          Year        Region    Subregion order order2 orderold order_microsat
## 1        2018 South America                  8     NA       82             NA
## 2        2018 South America                 NA     NA       NA             NA
## 3 2016 & 2017   East Africa  East Africa    NA     79       NA             NA
## 4        2017  Indian Ocean Indian Ocean    81     81       73             NA
## 5        2016   East Africa  East Africa    80     78       72             NA
## 6        2022  Indian Ocean Indian Ocean    82     80       74             NA
##   microsats microsat_code alt_code  X  Country.1 X.1 X.2 X.3 X.4 X.5 X.6
## 1                                  NA     Brazil  NA  NA  NA  NA  NA  NA
## 2                                  NA  Argentina  NA  NA  NA  NA  NA  NA
## 3                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 4                                  NA    Reunion  NA  NA  NA  NA  NA  NA
## 5                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 6                                  NA  Mauritius  NA  NA  NA  NA  NA  NA

Load the csv

countr <- read.csv(here("output/europe/dapc/microsats/iberia/DAPC_countries_microsats_iberia.csv"
))
df <- as.data.frame(countr)

head(df)
##   pop  country
## 1 POP Portugal
## 2 POP Portugal
## 3 POP Portugal
## 4 POP Portugal
## 5 POP Portugal
## 6 POP Portugal
iberia@pop <- as.factor(df$country)
iberia$pop
##   [1] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [9] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [17] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [25] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [33] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [41] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [49] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [57] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [65] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [73] Portugal Portugal Portugal Spain    Spain    Spain    Spain    Spain   
##  [81] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [89] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [97] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [105] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [113] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [121] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [129] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [137] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [145] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [153] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [161] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [169] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [177] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [185] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [193] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [201] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [209] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [217] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [225] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [233] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [241] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [249] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [257] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [265] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [273] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [281] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [289] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [297] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [305] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [313] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [321] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [329] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [337] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [345] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [353] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [361] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [369] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [377] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [385] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [393] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [401] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [409] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [417] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [425] Spain    Spain    Spain   
## Levels: Portugal Spain

Save the genind object

saveRDS(iberia, here("output/europe/dapc/microsats/iberia/microsat_country_iberia.rds"
))
iberia@pop <- as.factor(df$pop)
iberia$pop
##   [1] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [16] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [31] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [46] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [61] POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL 
##  [76] SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  ESAC ESAC ESAC ESAC
##  [91] ESAC ESAC ESAC ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO
## [106] ESMO ESMO ESMO ESMO ESMO ESMO ESSV ESSV ESSV ESSV ESSV ESSV ESSV ESSV ESSV
## [121] ESSV ESSV ESSV ESSV ESAL ESAL ESAL ESAL ESAL ESAL SPS  SPS  SPS  SPS  SPS 
## [136] SPS  SPS  SPS  SPS  SPS  ESMN ESMN ESMN ESLS ESLS ESLS ESMV ESMV ESMV ESFU
## [151] ESFU ESFU ESBM ESBM ESBM ESBM ESTM ESTM ESTM ESTM ESTM ESTM ESTM ESTM ESTM
## [166] ESTM ESTM ESTM ESTM ESTM ESTM ESGD ESGD ESBN ESBN ESBN ESBN ESBN ESBN ESSL
## [181] ESSL ESSL ESMC ESMC ESMC ESMC ESVN ESPT ESAB ESAB ESAB ESAB ESAB ESAB ESAB
## [196] ESAB ESAB ESAB ESAB ESAB ESAB ESAB ESBY ESBY ESBY ESBY ESBY ESBY ESNI ESNI
## [211] ESNI ESNI ESNI ESNI ESNI ESNI ESNI ESNU ESNU ESNU ESNU ESNU ESNU ESIR ESIR
## [226] ESIR ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAZ ESAZ ESAZ ESAZ
## [241] ESCN ESCN ESCN ESCN ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT
## [256] ESCT ESCT ESCT ESCT ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU
## [271] ESMU ESMU ESMU ESMU ESMU ESMU ESPP ESPP ESPP ESPP ESPP ESPP ESCH ESCH ESLM
## [286] ESLM ESLM ESLM ESCA ESCA ESCA ESCA ESCA ESAY ESAY ESAY ESAY ESAY ESAY ESAY
## [301] ESAY ESAY SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC 
## [316] SPC  SPC  SPC  SPC  SPC  SPC  SPC  ESBS ESBS ESBS ESBS ESBS ESBS ESBS ESBS
## [331] ESBS ESBS ESBS ESBS ESBS ESBS ESBE ESBE ESBE ESBE ESBE ESBE ESBE ESBE ESBE
## [346] ESBE ESBE ESBE ESBE ESBE ESBE ESTS ESTS ESTS ESTS ESTS ESTS ESTS ESTS ESTS
## [361] ESTS ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA
## [376] ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESCP
## [391] ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP
## [406] ESCP ESCP ESCP SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM 
## [421] SPM  SPM  SPM  SPM  SPM  SPM  SPM 
## 42 Levels: ESAB ESAC ESAG ESAL ESAY ESAZ ESBA ESBE ESBM ESBN ESBS ESBY ... SPS

Save the genind object

saveRDS(iberia, here("output/europe/dapc/microsats/iberia/microsat_pop_iberia.rds"
))

Load the genind object

microsat_pop_iberia <- readRDS(here("output/europe/dapc/microsats/iberia/microsat_pop_iberia.rds"
))

4.1.4. Scale

microsat_pop_iberia <- scaleGen(iberia, NA.method="mean")
class(microsat_pop_iberia)
dim(microsat_pop_iberia)
## NULL
microsat_pop_iberia[1:5,1:5]
## /// GENIND OBJECT /////////
## 
##  // 5 individuals; 1 locus; 5 alleles; size: 10.1 Kb
## 
##  // Basic content
##    @tab:  5 x 5 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 5-5)
##    @loc.fac: locus factor for the 5 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: .local(x = x, i = i, j = j, drop = drop)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 5-5)
##    @strata: a data frame with 1 columns ( pop.iberia. )
# Get the populations from the genlight object
#populations <- iberia$pop #to get individual locations (n=42)
populations <- iberia$pop

4.1.5. Find clusters

grp <- find.clusters(microsat_pop_iberia, max.n.clust=15)
#retained 200
#Choose the number of clusters (>=2): 12

Re-do allowing # of clusters to be # of pops

grp2 <- find.clusters(microsat_pop_iberia, max.n.clust=42)
#retained 200
#Choose the number of clusters (>=2): 

Save the genind object

saveRDS(grp, here("output/europe/dapc/microsats/iberia/grp_15.rds"
))

Load the genind object

grp <- readRDS(here("output/europe/dapc/microsats/iberia/grp_15.rds"))
names(grp)
## [1] "Kstat" "stat"  "grp"   "size"
grp$size #group sizes for our clusters
##  [1]  46  11  18   1  15 111  38   1   1   4   1 180
table(pop(iberia), grp$grp)
##       
##         1  2  3  4  5  6  7  8  9 10 11 12
##   ESAB  0  0  0  0  0  0  0  0  0  0  0 14
##   ESAC  0  0  0  0  0  7  0  0  0  0  0  0
##   ESAG  0  0  0  0  0  0  0  0  0  0  0 10
##   ESAL  0  0  0  0  0  6  0  0  0  0  0  0
##   ESAY  1  0  0  0  0  0  0  0  0  0  0  8
##   ESAZ  0  0  0  0  0  0  0  0  0  0  0  4
##   ESBA  0  2  0  1  0 17  4  1  0  0  0  3
##   ESBE  0  0  0  0  0  2  0  0  0  0  0 13
##   ESBM  4  0  0  0  0  0  0  0  0  0  0  0
##   ESBN  5  0  0  0  0  0  0  0  0  0  0  1
##   ESBS  0  0  0  0  0  2  0  0  0  0  0 12
##   ESBY  0  0  0  0  0  0  0  0  0  0  0  6
##   ESCA  0  0  0  0  0  1  0  0  0  0  0  4
##   ESCH  0  0  0  0  0  0  0  0  0  0  0  2
##   ESCN  0  0  0  0  0  0  0  0  0  0  0  4
##   ESCP 15  0  0  0  0  4  0  0  0  0  0  0
##   ESCT  0  0  0  0  0  2  0  0  0  0  0 13
##   ESFU  2  0  0  0  0  0  0  0  0  0  0  1
##   ESGD  0  0  0  0  0  0  0  0  0  0  0  2
##   ESIR  0  0  0  0  0  0  0  0  0  0  0  3
##   ESLM  0  0  0  0  0  0  0  0  0  0  0  4
##   ESLS  1  0  0  0  0  0  0  0  0  0  0  2
##   ESMC  1  0  0  0  0  0  0  0  0  0  0  3
##   ESMN  1  0  0  0  0  0  0  0  0  0  0  2
##   ESMO  0  0 18  0  0  0  0  0  0  0  0  0
##   ESMU  1  0  0  0  0  0  0  0  0  0  0 16
##   ESMV  0  0  0  0  0  1  0  0  0  0  0  2
##   ESNI  0  0  0  0  0  0  0  0  0  0  0  9
##   ESNU  0  0  0  0  0  0  0  0  0  0  0  6
##   ESPP  1  0  0  0  0  0  0  0  0  1  0  4
##   ESPT  0  0  0  0  0  0  1  0  0  0  0  0
##   ESSL  0  0  0  0  0  0  0  0  0  3  0  0
##   ESSV  0  0  0  0  0  3  0  0  1  0  0  9
##   ESTM  9  0  0  0  0  1  0  0  0  0  0  5
##   ESTS  3  0  0  0  0  0  0  0  0  0  0  7
##   ESVN  0  0  0  0  0  0  0  0  0  0  1  0
##   POL   0  0  0  0  0  0 15  0  0  0  0  0
##   POP   1  9  0  0 15 17 17  0  0  0  0  1
##   SPB   0  0  0  0  0 11  0  0  0  0  0  0
##   SPC   0  0  0  0  0 19  1  0  0  0  0  0
##   SPM   1  0  0  0  0 18  0  0  0  0  0  0
##   SPS   0  0  0  0  0  0  0  0  0  0  0 10

4.1.6. Run dapc

dapc1 <- dapc(microsat_pop_iberia, grp$grp)
#200 PCs retained
#12 discriminant functions retained

Save the genind object

saveRDS(dapc1, here("output/europe/dapc/microsats/iberia//dapc1.rds"
))

Load the genind object

dapc1 <- readRDS(here("output/europe/dapc/microsats/iberia/dapc1.rds"
))
dapc1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1)
## 
## $n.pca: 143 first PCs of PCA used
## $n.da: 12 discriminant functions saved
## $var (proportion of conserved variance): 1
## 
## $eig (eigenvalues): 3.116e+32 1.69e+32 1.399e+32 9.196e+31 1928000 ...
## 
##   vector    length content                   
## 1 $eig      12     eigenvalues               
## 2 $grp      427    prior group assignment    
## 3 $prior    12     prior group probabilities 
## 4 $assign   427    posterior group assignment
## 5 $pca.cent 159    centring vector of PCA    
## 6 $pca.norm 159    scaling vector of PCA     
## 7 $pca.eig  143    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          427  143  retained PCs of PCA                              
## 2 $means        12   143  group means                                      
## 3 $loadings     143  12   loadings of variables                            
## 4 $ind.coord    427  12   coordinates of individuals (principal components)
## 5 $grp.coord    12   12   coordinates of groups                            
## 6 $posterior    427  12   posterior membership probabilities               
## 7 $pca.loadings 159  143  PCA loadings of original variables               
## 8 $var.contr    159  12   contribution of original variables

4.1.7. Calculating the optimum PC number to rerun DAPC

optim.a.score(dapc1, n.pca=1:ncol(dapc1$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10) #calculating optimal number of PCs
#Optimal number = 23

4.1.8. Now do cross-validation

Cross-validation: The Discriminant Analysis of Principal Components (DAPC) relies on dimension reduction of the data using PCA followed by a linear discriminant analysis. How many PCA axes to retain is often a non-trivial question. Cross validation provides an objective way to decide how many axes to retain: different numbers are tried and the quality of the corresponding DAPC is assessed by cross- validation: DAPC is performed on a training set, typically made of 90% of the observations (comprising 90% of the observations in each subpopulation) , and then used to predict the groups of the 10% of remaining observations. The current method uses the average prediction success per group (result=“groupMean”), or the overall prediction success (result=“overall”). The number of PCs associated with the lowest Mean Squared Error is then retained in the DAPC.

xvalDapc(microsat_pop_iberia, populations, n.pca.max = 200, n.da = NULL,
              training.set = 0.9, result = c("groupMean", "overall"),
              center = TRUE, scale = FALSE,
              n.pca=NULL, n.rep = 30, xval.plot = TRUE) 

n pcs = 40 40 discriminant functions saved proportion of conserved variance: 0.564

Run DAPC with object using x-val recommendations

dapc_iberia_1 <- dapc(microsat_pop_iberia, n.pca = 40, n.da = 40, grp = populations)
dapc_iberia_1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_iberia, n.pca = 40, n.da = 40, grp = populations)
## 
## $n.pca: 40 first PCs of PCA used
## $n.da: 40 discriminant functions saved
## $var (proportion of conserved variance): 0.858
## 
## $eig (eigenvalues): 64.99 33.61 27.25 21.95 17.35 ...
## 
##   vector    length content                   
## 1 $eig      40     eigenvalues               
## 2 $grp      427    prior group assignment    
## 3 $prior    42     prior group probabilities 
## 4 $assign   427    posterior group assignment
## 5 $pca.cent 159    centring vector of PCA    
## 6 $pca.norm 159    scaling vector of PCA     
## 7 $pca.eig  140    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          427  40   retained PCs of PCA                              
## 2 $means        42   40   group means                                      
## 3 $loadings     40   40   loadings of variables                            
## 4 $ind.coord    427  40   coordinates of individuals (principal components)
## 5 $grp.coord    42   40   coordinates of groups                            
## 6 $posterior    427  42   posterior membership probabilities               
## 7 $pca.loadings 159  40   PCA loadings of original variables               
## 8 $var.contr    159  40   contribution of original variables

dapc with optimal # of PCs recommended

dapc_iberia_2 <- dapc(microsat_pop_iberia, n.pca = 23, n.da = 12, grp = populations)
dapc_iberia_2
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_iberia, n.pca = 23, n.da = 12, grp = populations)
## 
## $n.pca: 23 first PCs of PCA used
## $n.da: 12 discriminant functions saved
## $var (proportion of conserved variance): 0.701
## 
## $eig (eigenvalues): 45.87 23.45 18.79 13.28 11.4 ...
## 
##   vector    length content                   
## 1 $eig      23     eigenvalues               
## 2 $grp      427    prior group assignment    
## 3 $prior    42     prior group probabilities 
## 4 $assign   427    posterior group assignment
## 5 $pca.cent 159    centring vector of PCA    
## 6 $pca.norm 159    scaling vector of PCA     
## 7 $pca.eig  140    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          427  23   retained PCs of PCA                              
## 2 $means        42   23   group means                                      
## 3 $loadings     23   12   loadings of variables                            
## 4 $ind.coord    427  12   coordinates of individuals (principal components)
## 5 $grp.coord    42   12   coordinates of groups                            
## 6 $posterior    427  42   posterior membership probabilities               
## 7 $pca.loadings 159  23   PCA loadings of original variables               
## 8 $var.contr    159  12   contribution of original variables

only 38% of variance retained with this one

dapc_iberia_3 <- dapc(microsat_pop_iberia, n.pca = 120, n.da = 12, grp = populations)
dapc_iberia_3
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_iberia, n.pca = 120, n.da = 12, 
##     grp = populations)
## 
## $n.pca: 120 first PCs of PCA used
## $n.da: 12 discriminant functions saved
## $var (proportion of conserved variance): 0.998
## 
## $eig (eigenvalues): 3903 122.8 92.83 78.14 65.99 ...
## 
##   vector    length content                   
## 1 $eig      41     eigenvalues               
## 2 $grp      427    prior group assignment    
## 3 $prior    42     prior group probabilities 
## 4 $assign   427    posterior group assignment
## 5 $pca.cent 159    centring vector of PCA    
## 6 $pca.norm 159    scaling vector of PCA     
## 7 $pca.eig  140    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          427  120  retained PCs of PCA                              
## 2 $means        42   120  group means                                      
## 3 $loadings     120  12   loadings of variables                            
## 4 $ind.coord    427  12   coordinates of individuals (principal components)
## 5 $grp.coord    42   12   coordinates of groups                            
## 6 $posterior    427  42   posterior membership probabilities               
## 7 $pca.loadings 159  120  PCA loadings of original variables               
## 8 $var.contr    159  12   contribution of original variables

4.1.9. Plots

scatter(dapc_iberia_1)

scatter(dapc_iberia_2)

scatter(dapc_iberia_3)

All very similar. Use 1st one for plotting.

Check R symbols for plot

#to see all shapes -> plot shapes - para escolher os simbolos
N = 100; M = 1000
good.shapes = c(1:25,35:38,43,60,62:64)
foo = data.frame( x = rnorm(M), y = rnorm(M), s = factor( sample(1:N, M, replace = TRUE) ) )
ggplot(aes(x,y,shape=s ), data=foo ) +
  scale_shape_manual(values=good.shapes[1:N]) +
  geom_point()
## Warning: Removed 660 rows containing missing values or values outside the scale range
## (`geom_point()`).

#1:25,28:31,36,55:57

42 pops now

myCol80 <- read.delim("output/europe/dapc/microsats/colors80.txt")
myCol80
##    X.FB000D
## 1   #0DFF00
## 2   #2A0DFC
## 3   #FFD0D0
## 4   #FE0DDE
## 5   #16D1FE
## 6   #EDE90D
## 7   #FF9300
## 8   #168F51
## 9   #7A3B92
## 10  #AB1C56
## 11  #764200
## 12  #1C515D
## 13  #CC16FD
## 14  #B4EAE6
## 15  #FB90D7
## 16  #859BFE
## 17  #D7E8A3
## 18  #FD2278
## 19  #16FFA5
## 20  #DCC7FC
## 21  #84D026
## 22  #FAC46D
## 23  #FC998C
## 24  #CB3D1C
## 25  #F20DA3
## 26  #454F1C
## 27  #874263
## 28  #00FBDE
## 29  #E682FA
## 30  #165190
## 31  #7C0DC2
## 32  #AC009B
## 33  #92830D
## 34  #968894
## 35  #169FAB
## 36  #9AF5BE
## 37  #8AAA88
## 38  #658B00
## 39  #7FA7DB
## 40  #0042BB
## 41  #AD5100
## 42  #A7886D
## 43  #FE85AD
## 44  #007EFE
## 45  #B67EB2
## 46  #C39CF8
## 47  #66F4FD
## 48  #D03D97
## 49  #564069
## 50  #0DD745
## 51  #FF560D
## 52  #CA8288
## 53  #DB22E2
## 54  #F3667A
## 55  #0D7E6C
## 56  #9822FC
## 57  #E7DFEF
## 58  #D0EB6D
## 59  #F6D4A7
## 60  #0DADFA
## 61  #FE69DD
## 62  #5DCB6C
## 63  #8F72FE
## 64  #FCD100
## 65  #AC7700
## 66  #D9CA5A
## 67  #E0E0C8
## 68  #F7AFFE
## 69  #940D0D
## 70  #51C6AD
## 71  #FFB216
## 72  #8778B3
## 73  #8BFC16
## 74  #8DADC0
## 75  #9600AB
## 76  #FBB4D8
## 77  #FE5198
## 78  #B35156
## 79  #C370FF
myCol42 <- c("#51f310", "#146c45", "#75d5e1", "#FF7F00", "magenta", "red",  "yellow3", "#52ef99", "#2524f9",  "#1E90FF", "purple2", "#fda547", "#cf749D", "#332288", "#a41415",  "yellow", "#C370FF", "#B35156", "#FE5198", "#9600AB", "#8DADE0", "#8778B3", "#FFB216", "#AC7700", "#8F72FE", "#FE69DD", "#FF560D", "#0DC745", "#66F4FD", "#C39CF8", "#0042BB", "#AD5100", "#658B00", "gray", "gray43", "#169FAB", "#92830D", "#AC009B", "purple4", "#CB3D1C", "#FAC46D", "#FC998C")

Plot using different discriminant functions

1 & 2

pdf(file = "output/europe/dapc/microsats/iberia/dapc1_microsat_all_iberia_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_1, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_1, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

Look the same - just plot dapc2

PCs 1 & 3

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

PCs 1 & 4

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_PC1_4",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

PCs 2 & 3

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

PCs 3 & 4

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_PC3_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =3, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCol42, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =3, yax=4)

#### 4.1.9.1. Colored by regions

#10 unique regions: 
#Portugal
#Extremadura
#Andalusia
#Valencia
#Madrid
#North
#Aragon
#Murcia
#Catalonia
#Balearic Islands

myCols_new <- c("#a41415", "yellow3", "#51f310", "yellow3", "#2524f9", "#51f310","#FE69DD","#66F4FD","#a41415", "#a41415", "#2524f9","#C370FF","#51f310",
"#66F4FD","#51f310","#FF560D","#51f310","#a41415", "#2524f9","#C370FF","#2524f9","#a41415", "#a41415", "#a41415", "yellow3","#51f310","#a41415", "#a41415", "#66F4FD","#51f310","#146c45","#a41415", "#a41415", "#a41415", "#FE69DD","#2524f9","#FF7F00", "#FF7F00", "yellow3","#2524f9","#FF560D",
"#a41415")

Plot using different discriminant functions

1 & 2

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_regions_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

1 & 2

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_regions_PC1_3.pdf.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_regions_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_regions_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax=2, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax=2, yax=3)

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_regions_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax=2, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax=2, yax=4)

pdf(file = "output/europe/dapc/microsats/iberia/dapc2_microsat_all_iberia_regions_PC3_4.pdf.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax=3, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_iberia_2, pch = good.shapes, cstar = 0, col=myCols_new, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax=3, yax=4)

4.2. Eastern Europe

4.2.1. Load .gen file with microsat data from all individuals in eastern europe region

eastern <- read.genepop("/gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/dapc/microsats/eastern_europe/for_dapc_albo_microsats_eastern.gen", ncode=3L)
## 
##  Converting data from a Genepop .gen file to a genind object... 
## 
## 
## File description:  ARBOMONITOR_Aedes_albopictus                                           
## 
## ...done.
eastern
## /// GENIND OBJECT /////////
## 
##  // 410 individuals; 11 loci; 147 alleles; size: 296.5 Kb
## 
##  // Basic content
##    @tab:  410 x 147 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 6-19)
##    @loc.fac: locus factor for the 147 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: read.genepop(file = "/gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/dapc/microsats/eastern_europe/for_dapc_albo_microsats_eastern.gen", 
##     ncode = 3L)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 3-30)
pop(eastern)
##   [1] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##   [7] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [13] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [19] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30 
##  [25] SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  SER-SRNO30  ROTI-ROTI30
##  [31] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [37] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [43] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [49] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30
##  [55] ROTI-ROTI30 ROTI-ROTI30 ROTI-ROTI30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [61] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [67] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [73] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [79] RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30 RODE-RODE30
##  [85] RODE-RODE30 RODE-RODE30 RODE-RODE30 ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [91] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
##  [97] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
## [103] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
## [109] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROS-ROSM30 
## [115] ROS-ROSM30  ROS-ROSM30  ROS-ROSM30  ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
## [121] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
## [127] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
## [133] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30
## [139] ROPL-ROPL30 ROPL-ROPL30 ROPL-ROPL30 ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29
## [145] ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29 ROBU-ROBU29 ROCO-ROCO30
## [151] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [157] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [163] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [169] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30
## [175] ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 ROCO-ROCO30 BUL-BULO34  BUL-BULO34 
## [181] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
## [187] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
## [193] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
## [199] BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34  BUL-BULO34 
## [205] BUL-BULO34  BUL-BULO34  BUL-BULO34  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [211] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [217] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [223] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [229] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TUA-TRLG30 
## [235] TUA-TRLG30  TUA-TRLG30  TUA-TRLG30  TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [241] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [247] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [253] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [259] TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28 TRGN-TRGN28
## [265] TRGN-TRGN28 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [271] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [277] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [283] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20
## [289] TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRIS-TRIS20 TRTR-TRTR15 TRTR-TRTR15
## [295] TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15
## [301] TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15 TRTR-TRTR15
## [307] TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10 TRRI-TRRI10
## [313] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [319] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [325] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [331] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29 
## [337] TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TUH-TRHO29  TRAR-TRAR14
## [343] TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14
## [349] TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 TRAR-TRAR14 RUBE-RUBE20
## [355] RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20
## [361] RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20 RUBE-RUBE20
## [367] RUBE-RUBE20 RUBE-RUBE20 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10
## [373] RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RUPL-RUPL10 RURM-RURM07
## [379] RURM-RURM07 RURM-RURM07 SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10 
## [385] SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10  SOC-RUSO10 
## [391] ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04
## [397] ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 ABAL-ABKO04 GES-ABSU05  GES-ABSU05 
## [403] GES-ABSU05  GES-ABSU05  GES-ABSU05  GEPO-GEPO05 GEPO-GEPO05 GEPO-GEPO05
## [409] GEPO-GEPO05 GEPO-GEPO05
## 22 Levels: SER-SRNO30 ROTI-ROTI30 RODE-RODE30 ROS-ROSM30 ... GEPO-GEPO05
nInd(eastern)
## [1] 410
nLoc(eastern)
## [1] 11
nPop(eastern)
## [1] 22
indNames(eastern)
##   [1] "SER-SRNO01"  "SER-SRNO02"  "SER-SRNO03"  "SER-SRNO04"  "SER-SRNO05" 
##   [6] "SER-SRNO06"  "SER-SRNO07"  "SER-SRNO08"  "SER-SRNO09"  "SER-SRNO10" 
##  [11] "SER-SRNO11"  "SER-SRNO12"  "SER-SRNO14"  "SER-SRNO15"  "SER-SRNO16" 
##  [16] "SER-SRNO17"  "SER-SRNO18"  "SER-SRNO19"  "SER-SRNO20"  "SER-SRNO21" 
##  [21] "SER-SRNO22"  "SER-SRNO23"  "SER-SRNO24"  "SER-SRNO25"  "SER-SRNO26" 
##  [26] "SER-SRNO27"  "SER-SRNO28"  "SER-SRNO29"  "SER-SRNO30"  "ROTI-ROTI01"
##  [31] "ROTI-ROTI03" "ROTI-ROTI04" "ROTI-ROTI05" "ROTI-ROTI06" "ROTI-ROTI07"
##  [36] "ROTI-ROTI08" "ROTI-ROTI09" "ROTI-ROTI10" "ROTI-ROTI11" "ROTI-ROTI12"
##  [41] "ROTI-ROTI13" "ROTI-ROTI14" "ROTI-ROTI15" "ROTI-ROTI16" "ROTI-ROTI17"
##  [46] "ROTI-ROTI18" "ROTI-ROTI19" "ROTI-ROTI21" "ROTI-ROTI22" "ROTI-ROTI23"
##  [51] "ROTI-ROTI24" "ROTI-ROTI25" "ROTI-ROTI26" "ROTI-ROTI27" "ROTI-ROTI28"
##  [56] "ROTI-ROTI29" "ROTI-ROTI30" "RODE-RODE01" "RODE-RODE02" "RODE-RODE03"
##  [61] "RODE-RODE04" "RODE-RODE05" "RODE-RODE06" "RODE-RODE07" "RODE-RODE08"
##  [66] "RODE-RODE09" "RODE-RODE10" "RODE-RODE11" "RODE-RODE12" "RODE-RODE13"
##  [71] "RODE-RODE14" "RODE-RODE15" "RODE-RODE16" "RODE-RODE17" "RODE-RODE18"
##  [76] "RODE-RODE19" "RODE-RODE20" "RODE-RODE21" "RODE-RODE22" "RODE-RODE23"
##  [81] "RODE-RODE24" "RODE-RODE25" "RODE-RODE26" "RODE-RODE27" "RODE-RODE28"
##  [86] "RODE-RODE29" "RODE-RODE30" "ROS-ROSM01"  "ROS-ROSM02"  "ROS-ROSM03" 
##  [91] "ROS-ROSM04"  "ROS-ROSM05"  "ROS-ROSM06"  "ROS-ROSM07"  "ROS-ROSM08" 
##  [96] "ROS-ROSM09"  "ROS-ROSM10"  "ROS-ROSM11"  "ROS-ROSM12"  "ROS-ROSM13" 
## [101] "ROS-ROSM14"  "ROS-ROSM15"  "ROS-ROSM16"  "ROS-ROSM17"  "ROS-ROSM18" 
## [106] "ROS-ROSM19"  "ROS-ROSM20"  "ROS-ROSM21"  "ROS-ROSM22"  "ROS-ROSM23" 
## [111] "ROS-ROSM24"  "ROS-ROSM25"  "ROS-ROSM26"  "ROS-ROSM27"  "ROS-ROSM28" 
## [116] "ROS-ROSM29"  "ROS-ROSM30"  "ROPL-ROPL02" "ROPL-ROPL03" "ROPL-ROPL05"
## [121] "ROPL-ROPL07" "ROPL-ROPL08" "ROPL-ROPL11" "ROPL-ROPL12" "ROPL-ROPL13"
## [126] "ROPL-ROPL14" "ROPL-ROPL15" "ROPL-ROPL16" "ROPL-ROPL17" "ROPL-ROPL18"
## [131] "ROPL-ROPL19" "ROPL-ROPL20" "ROPL-ROPL21" "ROPL-ROPL22" "ROPL-ROPL23"
## [136] "ROPL-ROPL25" "ROPL-ROPL26" "ROPL-ROPL27" "ROPL-ROPL28" "ROPL-ROPL29"
## [141] "ROPL-ROPL30" "ROBU-ROBU11" "ROBU-ROBU13" "ROBU-ROBU16" "ROBU-ROBU17"
## [146] "ROBU-ROBU19" "ROBU-ROBU26" "ROBU-ROBU28" "ROBU-ROBU29" "ROCO-ROCO01"
## [151] "ROCO-ROCO02" "ROCO-ROCO03" "ROCO-ROCO04" "ROCO-ROCO05" "ROCO-ROCO06"
## [156] "ROCO-ROCO08" "ROCO-ROCO09" "ROCO-ROCO10" "ROCO-ROCO11" "ROCO-ROCO12"
## [161] "ROCO-ROCO13" "ROCO-ROCO14" "ROCO-ROCO15" "ROCO-ROCO16" "ROCO-ROCO17"
## [166] "ROCO-ROCO18" "ROCO-ROCO19" "ROCO-ROCO20" "ROCO-ROCO21" "ROCO-ROCO22"
## [171] "ROCO-ROCO23" "ROCO-ROCO24" "ROCO-ROCO25" "ROCO-ROCO26" "ROCO-ROCO27"
## [176] "ROCO-ROCO28" "ROCO-ROCO29" "ROCO-ROCO30" "BUL-BULO01"  "BUL-BULO02" 
## [181] "BUL-BULO03"  "BUL-BULO04"  "BUL-BULO05"  "BUL-BULO06"  "BUL-BULO07" 
## [186] "BUL-BULO08"  "BUL-BULO09"  "BUL-BULO10"  "BUL-BULO11"  "BUL-BULO12" 
## [191] "BUL-BULO13"  "BUL-BULO14"  "BUL-BULO15"  "BUL-BULO16"  "BUL-BULO17" 
## [196] "BUL-BULO18"  "BUL-BULO20"  "BUL-BULO25"  "BUL-BULO26"  "BUL-BULO27" 
## [201] "BUL-BULO28"  "BUL-BULO29"  "BUL-BULO30"  "BUL-BULO31"  "BUL-BULO32" 
## [206] "BUL-BULO33"  "BUL-BULO34"  "TUA-TRLG01"  "TUA-TRLG02"  "TUA-TRLG03" 
## [211] "TUA-TRLG04"  "TUA-TRLG05"  "TUA-TRLG06"  "TUA-TRLG07"  "TUA-TRLG08" 
## [216] "TUA-TRLG09"  "TUA-TRLG10"  "TUA-TRLG11"  "TUA-TRLG12"  "TUA-TRLG13" 
## [221] "TUA-TRLG14"  "TUA-TRLG15"  "TUA-TRLG16"  "TUA-TRLG17"  "TUA-TRLG18" 
## [226] "TUA-TRLG19"  "TUA-TRLG20"  "TUA-TRLG21"  "TUA-TRLG22"  "TUA-TRLG23" 
## [231] "TUA-TRLG24"  "TUA-TRLG25"  "TUA-TRLG26"  "TUA-TRLG27"  "TUA-TRLG28" 
## [236] "TUA-TRLG29"  "TUA-TRLG30"  "TRGN-TRGN01" "TRGN-TRGN02" "TRGN-TRGN03"
## [241] "TRGN-TRGN04" "TRGN-TRGN05" "TRGN-TRGN06" "TRGN-TRGN07" "TRGN-TRGN08"
## [246] "TRGN-TRGN09" "TRGN-TRGN10" "TRGN-TRGN11" "TRGN-TRGN12" "TRGN-TRGN13"
## [251] "TRGN-TRGN14" "TRGN-TRGN15" "TRGN-TRGN16" "TRGN-TRGN17" "TRGN-TRGN18"
## [256] "TRGN-TRGN19" "TRGN-TRGN20" "TRGN-TRGN21" "TRGN-TRGN22" "TRGN-TRGN23"
## [261] "TRGN-TRGN24" "TRGN-TRGN25" "TRGN-TRGN26" "TRGN-TRGN27" "TRGN-TRGN28"
## [266] "TRIS-TRIT01" "TRIS-TRIT02" "TRIS-TRIT04" "TRIS-TRIT05" "TRIS-TRIT07"
## [271] "TRIS-TRIT08" "TRIS-TRIT09" "TRIS-TRIS01" "TRIS-TRIS02" "TRIS-TRIS03"
## [276] "TRIS-TRIS04" "TRIS-TRIS05" "TRIS-TRIS06" "TRIS-TRIS07" "TRIS-TRIS08"
## [281] "TRIS-TRIS09" "TRIS-TRIS10" "TRIS-TRIS11" "TRIS-TRIS12" "TRIS-TRIS13"
## [286] "TRIS-TRIS14" "TRIS-TRIS15" "TRIS-TRIS16" "TRIS-TRIS17" "TRIS-TRIS18"
## [291] "TRIS-TRIS19" "TRIS-TRIS20" "TRTR-TRTR01" "TRTR-TRTR02" "TRTR-TRTR03"
## [296] "TRTR-TRTR04" "TRTR-TRTR05" "TRTR-TRTR06" "TRTR-TRTR07" "TRTR-TRTR08"
## [301] "TRTR-TRTR09" "TRTR-TRTR10" "TRTR-TRTR11" "TRTR-TRTR12" "TRTR-TRTR13"
## [306] "TRTR-TRTR15" "TRRI-TRRI02" "TRRI-TRRI03" "TRRI-TRRI04" "TRRI-TRRI05"
## [311] "TRRI-TRRI06" "TRRI-TRRI10" "TUH-TRHO01"  "TUH-TRHO02"  "TUH-TRHO03" 
## [316] "TUH-TRHO04"  "TUH-TRHO05"  "TUH-TRHO06"  "TUH-TRHO07"  "TUH-TRHO08" 
## [321] "TUH-TRHO09"  "TUH-TRHO10"  "TUH-TRHO11"  "TUH-TRHO12"  "TUH-TRHO13" 
## [326] "TUH-TRHO14"  "TUH-TRHO15"  "TUH-TRHO16"  "TUH-TRHO17"  "TUH-TRHO18" 
## [331] "TUH-TRHO19"  "TUH-TRHO20"  "TUH-TRHO21"  "TUH-TRHO22"  "TUH-TRHO23" 
## [336] "TUH-TRHO24"  "TUH-TRHO25"  "TUH-TRHO26"  "TUH-TRHO27"  "TUH-TRHO28" 
## [341] "TUH-TRHO29"  "TRAR-TRAR01" "TRAR-TRAR02" "TRAR-TRAR03" "TRAR-TRAR04"
## [346] "TRAR-TRAR06" "TRAR-TRAR07" "TRAR-TRAR08" "TRAR-TRAR10" "TRAR-TRAR11"
## [351] "TRAR-TRAR12" "TRAR-TRAR13" "TRAR-TRAR14" "RUBE-RUBE06" "RUBE-RUBE07"
## [356] "RUBE-RUBE08" "RUBE-RUBE09" "RUBE-RUBE10" "RUBE-RUBE11" "RUBE-RUBE12"
## [361] "RUBE-RUBE13" "RUBE-RUBE14" "RUBE-RUBE15" "RUBE-RUBE16" "RUBE-RUBE17"
## [366] "RUBE-RUBE18" "RUBE-RUBE19" "RUBE-RUBE20" "RUPL-RUPL01" "RUPL-RUPL02"
## [371] "RUPL-RUPL03" "RUPL-RUPL04" "RUPL-RUPL05" "RUPL-RUPL07" "RUPL-RUPL08"
## [376] "RUPL-RUPL09" "RUPL-RUPL10" "RURM-RURM02" "RURM-RURM06" "RURM-RURM07"
## [381] "SOC-RUSO01"  "SOC-RUSO02"  "SOC-RUSO03"  "SOC-RUSO04"  "SOC-RUSO05" 
## [386] "SOC-RUSO06"  "SOC-RUSO07"  "SOC-RUSO08"  "SOC-RUSO09"  "SOC-RUSO10" 
## [391] "ABAL-ABAL01" "ABAL-ABAL02" "ABAL-ABGL05" "ABAL-ABIN01" "ABAL-ABIN02"
## [396] "ABAL-ABIN06" "ABAL-ABIN07" "ABAL-ABKH01" "ABAL-ABKH02" "ABAL-ABKO04"
## [401] "GES-ABSU01"  "GES-ABSU02"  "GES-ABSU03"  "GES-ABSU04"  "GES-ABSU05" 
## [406] "GEPO-GEPO01" "GEPO-GEPO02" "GEPO-GEPO03" "GEPO-GEPO04" "GEPO-GEPO05"

Save it as rds

saveRDS(
  iberia, here(
    "output/europe/dapc/microsats/eastern_europe/microsats_europe_eastern.rds"
  )
)

To load it

iberia <- readRDS(
  here(
    "output/europe/dapc/microsats/eastern_europe/microsats_europe_eastern.rds"
  )
)

4.2.2. Add countries

strata(eastern) <- data.frame(pop(eastern))

# Currently set on just 
head(pop(eastern)) 
## [1] SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30
## 22 Levels: SER-SRNO30 ROTI-ROTI30 RODE-RODE30 ROS-ROSM30 ... GEPO-GEPO05
#pops_eastern <- as.data.frame(pop(eastern))
#write.csv(pops_eastern, here("DAPC/eastern/pops_eastern.csv"))

4.2.3. Get Sample Locations

Import sample data Load the csv

sampling_loc <- read.csv(here("output/europe/dapc/microsats/sampling_loc_euro_microsats.csv"))
sampling_loc <- as.data.frame(sampling_loc)

head(sampling_loc)
##        Pop_City    Country  Latitude Longitude Continent Abbreviation
## 1      Gravatai     Brazil -29.93760 -50.99070  Americas          GRV
## 2 Puerto Iguazu  Argentina -25.59720 -54.57860  Americas          POR
## 3      Vohimasy Madagascar -22.81591  47.75026    Africa          VOH
## 4 Trois-Bassins    Reunion -21.10901  55.31921    Africa          TRO
## 5     Morondava Madagascar -20.28420  44.27940    Africa          MAD
## 6       Dauguet  Mauritius -20.18530  57.52154    Africa          DAU
##          Year        Region    Subregion order order2 orderold order_microsat
## 1        2018 South America                  8     NA       82             NA
## 2        2018 South America                 NA     NA       NA             NA
## 3 2016 & 2017   East Africa  East Africa    NA     79       NA             NA
## 4        2017  Indian Ocean Indian Ocean    81     81       73             NA
## 5        2016   East Africa  East Africa    80     78       72             NA
## 6        2022  Indian Ocean Indian Ocean    82     80       74             NA
##   microsats microsat_code alt_code  X  Country.1 X.1 X.2 X.3 X.4 X.5 X.6
## 1                                  NA     Brazil  NA  NA  NA  NA  NA  NA
## 2                                  NA  Argentina  NA  NA  NA  NA  NA  NA
## 3                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 4                                  NA    Reunion  NA  NA  NA  NA  NA  NA
## 5                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 6                                  NA  Mauritius  NA  NA  NA  NA  NA  NA

Load the csv

countr <- read.csv(here("output/europe/dapc/microsats/eastern_europe/DAPC_countries_microsats_eastern.csv"
))
df <- as.data.frame(countr)

head(df)
##   pop country
## 1 SER  Serbia
## 2 SER  Serbia
## 3 SER  Serbia
## 4 SER  Serbia
## 5 SER  Serbia
## 6 SER  Serbia
eastern@pop <- as.factor(df$country)
eastern$pop
##   [1] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
##   [9] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
##  [17] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
##  [25] Serbia   Serbia   Serbia   Serbia   Serbia   Romania  Romania  Romania 
##  [33] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [41] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [49] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [57] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [65] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [73] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [81] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [89] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
##  [97] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [105] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [113] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [121] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [129] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [137] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [145] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [153] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [161] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [169] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [177] Romania  Romania  Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [185] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [193] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [201] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Turkey  
## [209] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [217] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [225] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [233] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [241] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [249] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [257] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [265] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [273] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [281] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [289] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [297] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [305] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [313] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [321] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [329] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [337] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [345] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [353] Turkey   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [361] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [369] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [377] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [385] Russia   Russia   Russia   Russia   Russia   Russia   Georgia  Georgia 
## [393] Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia 
## [401] Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia 
## [409] Georgia  Georgia 
## Levels: Bulgaria Georgia Romania Russia Serbia Turkey

Save the genind object

saveRDS(eastern, here("output/europe/dapc/microsats/eastern_europe/microsat_country_eastern.rds"
))
eastern@pop <- as.factor(df$pop)
eastern$pop
##   [1] SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER 
##  [16] SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  SER  ROTI
##  [31] ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI
##  [46] ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI ROTI RODE RODE RODE
##  [61] RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE
##  [76] RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE RODE ROS  ROS  ROS 
##  [91] ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS 
## [106] ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROS  ROPL ROPL ROPL
## [121] ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL ROPL
## [136] ROPL ROPL ROPL ROPL ROPL ROPL ROBU ROBU ROBU ROBU ROBU ROBU ROBU ROBU ROCO
## [151] ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO
## [166] ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO ROCO BUL  BUL 
## [181] BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL 
## [196] BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  BUL  TUA  TUA  TUA 
## [211] TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA 
## [226] TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TUA  TRGN TRGN TRGN
## [241] TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN
## [256] TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRGN TRIS TRIS TRIS TRIS TRIS
## [271] TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRIS
## [286] TRIS TRIS TRIS TRIS TRIS TRIS TRIS TRTR TRTR TRTR TRTR TRTR TRTR TRTR TRTR
## [301] TRTR TRTR TRTR TRTR TRTR TRTR TRRI TRRI TRRI TRRI TRRI TRRI TUH  TUH  TUH 
## [316] TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH 
## [331] TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TUH  TRAR TRAR TRAR TRAR
## [346] TRAR TRAR TRAR TRAR TRAR TRAR TRAR TRAR RUBE RUBE RUBE RUBE RUBE RUBE RUBE
## [361] RUBE RUBE RUBE RUBE RUBE RUBE RUBE RUBE RUPL RUPL RUPL RUPL RUPL RUPL RUPL
## [376] RUPL RUPL RURM RURM RURM SOC  SOC  SOC  SOC  SOC  SOC  SOC  SOC  SOC  SOC 
## [391] ABAL ABAL ABAL ABAL ABAL ABAL ABAL ABAL ABAL ABAL GES  GES  GES  GES  GES 
## [406] GEPO GEPO GEPO GEPO GEPO
## 22 Levels: ABAL BUL GEPO GES ROBU ROCO RODE ROPL ROS ROTI RUBE RUPL ... TUH

Save the genind object

saveRDS(eastern, here("output/europe/dapc/microsats/eastern_europe/microsat_pop_eastern.rds"
))

Load the genind object

microsat_pop_eastern <- readRDS(here("output/europe/dapc/microsats/eastern_europe/microsat_pop_eastern.rds"
))

4.2.4. Scale

microsat_pop_eastern <- scaleGen(eastern, NA.method="mean")
class(microsat_pop_eastern)
dim(microsat_pop_eastern)
## NULL
microsat_pop_eastern[1:5,1:5]
## /// GENIND OBJECT /////////
## 
##  // 5 individuals; 1 locus; 5 alleles; size: 8.7 Kb
## 
##  // Basic content
##    @tab:  5 x 5 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 5-5)
##    @loc.fac: locus factor for the 5 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: .local(x = x, i = i, j = j, drop = drop)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 5-5)
##    @strata: a data frame with 1 columns ( pop.eastern. )
# Get the populations from the genlight object
populations <- eastern$pop

4.2.5. Find clusters

grp <- find.clusters(microsat_pop_eastern, max.n.clust=15)
#retained 150
#Choose the number of clusters (>=2): 6

Save the genind object

saveRDS(grp, here("output/europe/dapc/microsats/eastern_europe/grp_6.rds"
))

Load the genind object

grp <- readRDS(here("output/europe/dapc/microsats/eastern_europe/grp_6.rds"))
names(grp)
## [1] "Kstat" "stat"  "grp"   "size"
grp$size #group sizes for our clusters
## [1] 157  48  14  26 153  12
table(pop(eastern), grp$grp)
##       
##         1  2  3  4  5  6
##   ABAL  0  9  0  0  1  0
##   BUL   0  0  0  0 29  0
##   GEPO  5  0  0  0  0  0
##   GES   0  4  0  0  1  0
##   ROBU  6  0  0  0  2  0
##   ROCO  9  0  0  0 20  0
##   RODE 22  0  0  0  8  0
##   ROPL  9  0  0  1 14  0
##   ROS   5  0  0 25  0  0
##   ROTI 18  0  0  0 10  0
##   RUBE  1 14  0  0  0  0
##   RUPL  0  9  0  0  0  0
##   RURM  0  3  0  0  0  0
##   SER   1  0  0  0 28  0
##   SOC   0  9  0  0  1  0
##   TRAR 10  0  0  0  2  0
##   TRGN 12  0  0  0 16  0
##   TRIS  9  0  0  0 18  0
##   TRRI  6  0  0  0  0  0
##   TRTR 13  0  0  0  1  0
##   TUA  15  0  5  0  1  9
##   TUH  16  0  9  0  1  3

4.2.6. Run dapc

dapc1 <- dapc(microsat_pop_eastern, grp$grp)
#150 PCs retained
#5 discriminant functions retained

Save the genind object

saveRDS(dapc1, here("output/europe/dapc/microsats/eastern_europe/dapc1.rds"
))

Load the genind object

dapc1 <- readRDS(here("output/europe/dapc/microsats/eastern_europe/dapc1.rds"
))
dapc1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1)
## 
## $n.pca: 136 first PCs of PCA used
## $n.da: 5 discriminant functions saved
## $var (proportion of conserved variance): 1
## 
## $eig (eigenvalues): 1469 718.6 571 357.7 299.8  vector    length content                   
## 1 $eig      5      eigenvalues               
## 2 $grp      410    prior group assignment    
## 3 $prior    6      prior group probabilities 
## 4 $assign   410    posterior group assignment
## 5 $pca.cent 147    centring vector of PCA    
## 6 $pca.norm 147    scaling vector of PCA     
## 7 $pca.eig  136    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          410  136  retained PCs of PCA                              
## 2 $means        6    136  group means                                      
## 3 $loadings     136  5    loadings of variables                            
## 4 $ind.coord    410  5    coordinates of individuals (principal components)
## 5 $grp.coord    6    5    coordinates of groups                            
## 6 $posterior    410  6    posterior membership probabilities               
## 7 $pca.loadings 147  136  PCA loadings of original variables               
## 8 $var.contr    147  5    contribution of original variables

4.2.7. Calculating the optimum PC number to rerun DAPC

optim.a.score(dapc1, n.pca=1:ncol(dapc1$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10) #calculating optimal number of PCs
#Optimal number = 13

4.2.8. Now do cross-validation

Cross-validation: The Discriminant Analysis of Principal Components (DAPC) relies on dimension reduction of the data using PCA followed by a linear discriminant analysis. How many PCA axes to retain is often a non-trivial question. Cross validation provides an objective way to decide how many axes to retain: different numbers are tried and the quality of the corresponding DAPC is assessed by cross- validation: DAPC is performed on a training set, typically made of 90% of the observations (comprising 90% of the observations in each subpopulation) , and then used to predict the groups of the 10% of remaining observations. The current method uses the average prediction success per group (result=“groupMean”), or the overall prediction success (result=“overall”). The number of PCs associated with the lowest Mean Squared Error is then retained in the DAPC.

xvalDapc(microsat_pop_eastern, populations, n.pca.max = 200, n.da = NULL,
              training.set = 0.9, result = c("groupMean", "overall"),
              center = TRUE, scale = FALSE,
              n.pca=NULL, n.rep = 30, xval.plot = TRUE) 

40 first PCs of PCA used 21 discriminant functions saved proportion of conserved variance: 0.559

Run DAPC with object using x-val recommendations

dapc_eastern_1 <- dapc(microsat_pop_eastern, n.pca = 40, n.da = 21, grp = populations)
dapc_eastern_1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_eastern, n.pca = 40, n.da = 21, 
##     grp = populations)
## 
## $n.pca: 40 first PCs of PCA used
## $n.da: 21 discriminant functions saved
## $var (proportion of conserved variance): 0.844
## 
## $eig (eigenvalues): 70.44 36.43 29.57 28.57 15.05 ...
## 
##   vector    length content                   
## 1 $eig      21     eigenvalues               
## 2 $grp      410    prior group assignment    
## 3 $prior    22     prior group probabilities 
## 4 $assign   410    posterior group assignment
## 5 $pca.cent 147    centring vector of PCA    
## 6 $pca.norm 147    scaling vector of PCA     
## 7 $pca.eig  136    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          410  40   retained PCs of PCA                              
## 2 $means        22   40   group means                                      
## 3 $loadings     40   21   loadings of variables                            
## 4 $ind.coord    410  21   coordinates of individuals (principal components)
## 5 $grp.coord    22   21   coordinates of groups                            
## 6 $posterior    410  22   posterior membership probabilities               
## 7 $pca.loadings 147  40   PCA loadings of original variables               
## 8 $var.contr    147  21   contribution of original variables

dapc with optimal # of PCs recommended

dapc_eastern_2 <- dapc(microsat_pop_eastern, n.pca = 13, n.da = 5, grp = populations)
dapc_eastern_2
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_eastern, n.pca = 13, n.da = 5, grp = populations)
## 
## $n.pca: 13 first PCs of PCA used
## $n.da: 5 discriminant functions saved
## $var (proportion of conserved variance): 0.494
## 
## $eig (eigenvalues): 36.3 17.62 13.78 10.19 6.149 ...
## 
##   vector    length content                   
## 1 $eig      13     eigenvalues               
## 2 $grp      410    prior group assignment    
## 3 $prior    22     prior group probabilities 
## 4 $assign   410    posterior group assignment
## 5 $pca.cent 147    centring vector of PCA    
## 6 $pca.norm 147    scaling vector of PCA     
## 7 $pca.eig  136    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          410  13   retained PCs of PCA                              
## 2 $means        22   13   group means                                      
## 3 $loadings     13   5    loadings of variables                            
## 4 $ind.coord    410  5    coordinates of individuals (principal components)
## 5 $grp.coord    22   5    coordinates of groups                            
## 6 $posterior    410  22   posterior membership probabilities               
## 7 $pca.loadings 147  13   PCA loadings of original variables               
## 8 $var.contr    147  5    contribution of original variables

4.2.9. Plots

scatter(dapc_eastern_1)

scatter(dapc_eastern_2)

colors for each pop

myCol22 <- c("#51f310", "#146c45", "#75d5e1", "#FF7F00", "magenta", "red",  "yellow3",  "#2524f9", "purple",  "#332288", "#a41415",  "yellow", "#0DC745", "#FE5198", "#169FAB", "gray43",  "#FFB216", "#AC7700", "#C39CF8", "#FC998C", "#FF560D", "purple4") 

Plot using different discriminant functions 1 & 2

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=2)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=2)

1 & 3

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=4)

2 & 3

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =2, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =2, yax=3)

2 & 4

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =2, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =2, yax=4)

3 & 4

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_PC3_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =3, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol22, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =3, yax=4)

Plot by 6 countries now

#myCol11 <- c("#51f310", "#146c45", "#75d5e1", "#FF7F00", "magenta", "red", "yellow3",  "#2524f9", "purple", "#332288", "#a41415")  

#for regions
myCol6 <- c("magenta", 
"yellow3", 
"magenta", 
"magenta", 
"#FF7F00", 
"#FF7F00", 
"#FF7F00", 
"#FF7F00", 
"#FF7F00", 
"#FF7F00", 
"purple", 
"purple", 
"purple", 
"#51f310", 
"purple", 
"#75d5e1", 
"#75d5e1", 
"#75d5e1", 
"#75d5e1", 
"#75d5e1", 
"#75d5e1", 
"#75d5e1")  

Plot using different discriminant functions 1 & 2

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_country_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=2)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=2)

1 & 3

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_country_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_country_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=4)

2 & 3

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_country_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =2, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =2, yax=3)

2 & 4

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_country_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=2, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=2, yax=4)

3 & 4

pdf(file = "output/europe/dapc/microsats/eastern_europe/dapc_eastern_euro_microsats_all_country_PC3_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=3, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_eastern_1, pch = good.shapes, cstar = 0, col=myCol6, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=3, yax=4)

4.3. Southern Europe

4.3.1. Load .gen file with microsat data from all individuals in southern europe region

southern <- read.genepop("output/europe/dapc/microsats/southern/for_dapc_albo_microsats_southern.gen", ncode=3L)
## 
##  Converting data from a Genepop .gen file to a genind object... 
## 
## 
## File description:  ARBOMONITOR_Aedes_albopictus                                           
## 
## ...done.
southern
## /// GENIND OBJECT /////////
## 
##  // 782 individuals; 11 loci; 179 alleles; size: 643.5 Kb
## 
##  // Basic content
##    @tab:  782 x 179 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 6-27)
##    @loc.fac: locus factor for the 179 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: read.genepop(file = "output/europe/dapc/microsats/southern/for_dapc_albo_microsats_southern.gen", 
##     ncode = 3L)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 1-60)
pop(southern)
##   [1] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##   [7] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [13] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [19] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [25] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [31] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [37] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [43] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [49] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [55] POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60  POP-PTPN60 
##  [61] POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15 
##  [67] POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15  POL-PTQT15 
##  [73] POL-PTQT15  POL-PTQT15  POL-PTQT15  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11 
##  [79] SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11  SPB-ESBD11 
##  [85] SPB-ESBD11  SPB-ESBD11  ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07
##  [91] ESAC-ESAC07 ESAC-ESAC07 ESAC-ESAC07 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
##  [97] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
## [103] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18
## [109] ESMO-ESMO18 ESMO-ESMO18 ESMO-ESMO18 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15
## [115] ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15
## [121] ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESSV-ESSV15 ESAL-ESAL06 ESAL-ESAL06
## [127] ESAL-ESAL06 ESAL-ESAL06 ESAL-ESAL06 ESAL-ESAL06 SPS-ESUP10  SPS-ESUP10 
## [133] SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10  SPS-ESUP10 
## [139] SPS-ESUP10  SPS-ESUP10  ESMN-ESMN04 ESMN-ESMN04 ESMN-ESMN04 ESLS-ESLS03
## [145] ESLS-ESLS03 ESLS-ESLS03 ESMV-ESMV03 ESMV-ESMV03 ESMV-ESMV03 ESFU-ESFU03
## [151] ESFU-ESFU03 ESFU-ESFU03 ESBM-ESBT03 ESBM-ESBT03 ESBM-ESBT03 ESBM-ESBT03
## [157] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10
## [163] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10
## [169] ESTM-ESTY10 ESTM-ESTY10 ESTM-ESTY10 ESGD-ESGD02 ESGD-ESGD02 ESBN-ESBN06
## [175] ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESBN-ESBN06 ESSL-ESSL03
## [181] ESSL-ESSL03 ESSL-ESSL03 ESMC-ESMT03 ESMC-ESMT03 ESMC-ESMT03 ESMC-ESMT03
## [187] ESVN-ESVN04 ESPT-ESPT03 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15
## [193] ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15
## [199] ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESAB-ESAB15 ESBY-ESBY06 ESBY-ESBY06
## [205] ESBY-ESBY06 ESBY-ESBY06 ESBY-ESBY06 ESBY-ESBY06 ESNI-ESNI10 ESNI-ESNI10
## [211] ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10 ESNI-ESNI10
## [217] ESNI-ESNI10 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06 ESNU-ESNU06
## [223] ESNU-ESNU06 ESIR-ESIR03 ESIR-ESIR03 ESIR-ESIR03 ESAG-ESAG10 ESAG-ESAG10
## [229] ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10 ESAG-ESAG10
## [235] ESAG-ESAG10 ESAG-ESAG10 ESAZ-ESAZ04 ESAZ-ESAZ04 ESAZ-ESAZ04 ESAZ-ESAZ04
## [241] ESCN-ESCN04 ESCN-ESCN04 ESCN-ESCN04 ESCN-ESCN04 ESCT-ESTT01 ESCT-ESTT01
## [247] ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01
## [253] ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01 ESCT-ESTT01
## [259] ESCT-ESTT01 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
## [265] ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
## [271] ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10 ESMU-ESRM10
## [277] ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06 ESPP-ESPP06
## [283] ESCH-ESCH02 ESCH-ESCH02 ESLM-ESLM04 ESLM-ESLM04 ESLM-ESLM04 ESLM-ESLM04
## [289] ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESCA-ESCA05 ESAY-ESAY10
## [295] ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10 ESAY-ESAY10
## [301] ESAY-ESAY10 ESAY-ESAY10 SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
## [307] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
## [313] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20 
## [319] SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  SPC-ESVL20  ESBS-ESBC07 ESBS-ESBC07
## [325] ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07
## [331] ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07 ESBS-ESBC07
## [337] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15
## [343] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15
## [349] ESBE-ESBE15 ESBE-ESBE15 ESBE-ESBE15 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10
## [355] ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10 ESTS-ESTS10
## [361] ESTS-ESTS10 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [367] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [373] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [379] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28
## [385] ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESBA-ESBA28 ESCP-ESCP19
## [391] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
## [397] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
## [403] ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19 ESCP-ESCP19
## [409] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
## [415] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
## [421] SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19  SPM-ESMG19 
## [427] SPM-ESMG19  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
## [433] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
## [439] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
## [445] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
## [451] ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15  ITB-ITBO15 
## [457] ITB-ITBO15  ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
## [463] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
## [469] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
## [475] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
## [481] ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17 ITRO-ITRO17
## [487] ITRO-ITRO17 ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
## [493] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
## [499] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
## [505] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
## [511] ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09  ITP-ITVL09 
## [517] ITP-ITVL09  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
## [523] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
## [529] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
## [535] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
## [541] MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39  MAL-MTLU39 
## [547] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
## [553] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
## [559] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
## [565] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
## [571] SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39  SLO-SLGO39 
## [577] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
## [583] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
## [589] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
## [595] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
## [601] CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30  CRO-CRPL30 
## [607] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
## [613] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
## [619] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
## [625] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30 
## [631] ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  ALD-ALDU30  GRC-GRCC25 
## [637] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
## [643] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
## [649] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
## [655] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25 
## [661] GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRC-GRCC25  GRPA-GRPU04 GRPA-GRPU04
## [667] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
## [673] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
## [679] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
## [685] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04
## [691] GRPA-GRPU04 GRPA-GRPU04 GRPA-GRPU04 GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
## [697] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
## [703] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
## [709] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
## [715] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRA-GRAN08 
## [721] GRA-GRAN08  GRA-GRAN08  GRA-GRAN08  GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
## [727] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
## [733] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
## [739] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
## [745] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05
## [751] GRTA-GRTT05 GRTA-GRTT05 GRTA-GRTT05 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [757] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [763] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [769] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [775] GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15 GRKV-GRKV15
## [781] GRKV-GRKV15 GRKV-GRKV15
## 54 Levels: POP-PTPN60 POL-PTQT15 SPB-ESBD11 ESAC-ESAC07 ... GRKV-GRKV15
nInd(southern)
## [1] 782
nLoc(southern)
## [1] 11
nPop(southern)
## [1] 54
indNames(southern)
##   [1] "POP-PTPN01"  "POP-PTPN02"  "POP-PTPN03"  "POP-PTPN04"  "POP-PTPN05" 
##   [6] "POP-PTPN06"  "POP-PTPN07"  "POP-PTPN08"  "POP-PTPN09"  "POP-PTPN10" 
##  [11] "POP-PTPN11"  "POP-PTPN12"  "POP-PTPN13"  "POP-PTPN14"  "POP-PTPN15" 
##  [16] "POP-PTPN16"  "POP-PTPN17"  "POP-PTPN18"  "POP-PTPN19"  "POP-PTPN20" 
##  [21] "POP-PTPN21"  "POP-PTPN22"  "POP-PTPN23"  "POP-PTPN24"  "POP-PTPN25" 
##  [26] "POP-PTPN26"  "POP-PTPN27"  "POP-PTPN28"  "POP-PTPN29"  "POP-PTPN30" 
##  [31] "POP-PTPN31"  "POP-PTPN32"  "POP-PTPN33"  "POP-PTPN34"  "POP-PTPN35" 
##  [36] "POP-PTPN36"  "POP-PTPN37"  "POP-PTPN38"  "POP-PTPN39"  "POP-PTPN40" 
##  [41] "POP-PTPN41"  "POP-PTPN42"  "POP-PTPN43"  "POP-PTPN44"  "POP-PTPN45" 
##  [46] "POP-PTPN46"  "POP-PTPN47"  "POP-PTPN48"  "POP-PTPN49"  "POP-PTPN50" 
##  [51] "POP-PTPN51"  "POP-PTPN52"  "POP-PTPN53"  "POP-PTPN54"  "POP-PTPN55" 
##  [56] "POP-PTPN56"  "POP-PTPN57"  "POP-PTPN58"  "POP-PTPN59"  "POP-PTPN60" 
##  [61] "POL-PTQT01"  "POL-PTQT02"  "POL-PTQT03"  "POL-PTQT04"  "POL-PTQT05" 
##  [66] "POL-PTQT06"  "POL-PTQT07"  "POL-PTQT08"  "POL-PTQT09"  "POL-PTQT10" 
##  [71] "POL-PTQT11"  "POL-PTQT12"  "POL-PTQT13"  "POL-PTQT14"  "POL-PTQT15" 
##  [76] "SPB-ESBD01"  "SPB-ESBD02"  "SPB-ESBD03"  "SPB-ESBD04"  "SPB-ESBD05" 
##  [81] "SPB-ESBD06"  "SPB-ESBD07"  "SPB-ESBD08"  "SPB-ESBD09"  "SPB-ESBD10" 
##  [86] "SPB-ESBD11"  "ESAC-ESAC01" "ESAC-ESAC02" "ESAC-ESAC03" "ESAC-ESAC04"
##  [91] "ESAC-ESAC05" "ESAC-ESAC06" "ESAC-ESAC07" "ESMO-ESMO01" "ESMO-ESMO02"
##  [96] "ESMO-ESMO03" "ESMO-ESMO04" "ESMO-ESMO05" "ESMO-ESMO06" "ESMO-ESMO07"
## [101] "ESMO-ESMO08" "ESMO-ESMO09" "ESMO-ESMO10" "ESMO-ESMO11" "ESMO-ESMO12"
## [106] "ESMO-ESMO13" "ESMO-ESMO14" "ESMO-ESMO15" "ESMO-ESMO16" "ESMO-ESMO17"
## [111] "ESMO-ESMO18" "ESSV-ESSV01" "ESSV-ESSV02" "ESSV-ESSV03" "ESSV-ESSV05"
## [116] "ESSV-ESSV06" "ESSV-ESSV07" "ESSV-ESSV08" "ESSV-ESSV09" "ESSV-ESSV10"
## [121] "ESSV-ESSV11" "ESSV-ESSV12" "ESSV-ESSV13" "ESSV-ESSV15" "ESAL-ESAL01"
## [126] "ESAL-ESAL02" "ESAL-ESAL03" "ESAL-ESAL04" "ESAL-ESAL05" "ESAL-ESAL06"
## [131] "SPS-ESUP01"  "SPS-ESUP02"  "SPS-ESUP03"  "SPS-ESUP04"  "SPS-ESUP05" 
## [136] "SPS-ESUP06"  "SPS-ESUP07"  "SPS-ESUP08"  "SPS-ESUP09"  "SPS-ESUP10" 
## [141] "ESMN-ESMN01" "ESMN-ESMN03" "ESMN-ESMN04" "ESLS-ESLS01" "ESLS-ESLS02"
## [146] "ESLS-ESLS03" "ESMV-ESMV01" "ESMV-ESMV02" "ESMV-ESMV03" "ESFU-ESFU01"
## [151] "ESFU-ESFU02" "ESFU-ESFU03" "ESBM-ESBM01" "ESBM-ESBT01" "ESBM-ESBT02"
## [156] "ESBM-ESBT03" "ESTM-ESTM01" "ESTM-ESTM02" "ESTM-ESTO01" "ESTM-ESTO02"
## [161] "ESTM-ESTO03" "ESTM-ESTY01" "ESTM-ESTY02" "ESTM-ESTY03" "ESTM-ESTY04"
## [166] "ESTM-ESTY05" "ESTM-ESTY06" "ESTM-ESTY07" "ESTM-ESTY08" "ESTM-ESTY09"
## [171] "ESTM-ESTY10" "ESGD-ESGD01" "ESGD-ESGD02" "ESBN-ESBN01" "ESBN-ESBN02"
## [176] "ESBN-ESBN03" "ESBN-ESBN04" "ESBN-ESBN05" "ESBN-ESBN06" "ESSL-ESSL01"
## [181] "ESSL-ESSL02" "ESSL-ESSL03" "ESMC-ESMC03" "ESMC-ESMT01" "ESMC-ESMT02"
## [186] "ESMC-ESMT03" "ESVN-ESVN04" "ESPT-ESPT03" "ESAB-ESAB01" "ESAB-ESAB02"
## [191] "ESAB-ESAB03" "ESAB-ESAB04" "ESAB-ESAB05" "ESAB-ESAB06" "ESAB-ESAB07"
## [196] "ESAB-ESAB09" "ESAB-ESAB10" "ESAB-ESAB11" "ESAB-ESAB12" "ESAB-ESAB13"
## [201] "ESAB-ESAB14" "ESAB-ESAB15" "ESBY-ESBY01" "ESBY-ESBY02" "ESBY-ESBY03"
## [206] "ESBY-ESBY04" "ESBY-ESBY05" "ESBY-ESBY06" "ESNI-ESNI01" "ESNI-ESNI02"
## [211] "ESNI-ESNI04" "ESNI-ESNI05" "ESNI-ESNI06" "ESNI-ESNI07" "ESNI-ESNI08"
## [216] "ESNI-ESNI09" "ESNI-ESNI10" "ESNU-ESNU01" "ESNU-ESNU02" "ESNU-ESNU03"
## [221] "ESNU-ESNU04" "ESNU-ESNU05" "ESNU-ESNU06" "ESIR-ESIR01" "ESIR-ESIR02"
## [226] "ESIR-ESIR03" "ESAG-ESAG01" "ESAG-ESAG02" "ESAG-ESAG03" "ESAG-ESAG04"
## [231] "ESAG-ESAG05" "ESAG-ESAG06" "ESAG-ESAG07" "ESAG-ESAG08" "ESAG-ESAG09"
## [236] "ESAG-ESAG10" "ESAZ-ESAZ01" "ESAZ-ESAZ02" "ESAZ-ESAZ03" "ESAZ-ESAZ04"
## [241] "ESCN-ESCN01" "ESCN-ESCN02" "ESCN-ESCN03" "ESCN-ESCN04" "ESCT-ESCT01"
## [246] "ESCT-ESCT02" "ESCT-ESLA01" "ESCT-ESLA02" "ESCT-ESLU01" "ESCT-ESLU02"
## [251] "ESCT-ESLU03" "ESCT-ESLU04" "ESCT-ESLU05" "ESCT-ESLU06" "ESCT-ESLU07"
## [256] "ESCT-ESLU08" "ESCT-ESLU09" "ESCT-ESLU10" "ESCT-ESTT01" "ESMU-ESCV01"
## [261] "ESMU-ESCV02" "ESMU-ESCV03" "ESMU-ESCV04" "ESMU-ESMU01" "ESMU-ESMU02"
## [266] "ESMU-ESMU03" "ESMU-ESRM01" "ESMU-ESRM02" "ESMU-ESRM03" "ESMU-ESRM04"
## [271] "ESMU-ESRM05" "ESMU-ESRM06" "ESMU-ESRM07" "ESMU-ESRM08" "ESMU-ESRM09"
## [276] "ESMU-ESRM10" "ESPP-ESPP01" "ESPP-ESPP02" "ESPP-ESPP03" "ESPP-ESPP04"
## [281] "ESPP-ESPP05" "ESPP-ESPP06" "ESCH-ESCH01" "ESCH-ESCH02" "ESLM-ESLM01"
## [286] "ESLM-ESLM02" "ESLM-ESLM03" "ESLM-ESLM04" "ESCA-ESCA01" "ESCA-ESCA02"
## [291] "ESCA-ESCA03" "ESCA-ESCA04" "ESCA-ESCA05" "ESAY-ESAY01" "ESAY-ESAY02"
## [296] "ESAY-ESAY03" "ESAY-ESAY04" "ESAY-ESAY05" "ESAY-ESAY06" "ESAY-ESAY07"
## [301] "ESAY-ESAY09" "ESAY-ESAY10" "SPC-ESVL01"  "SPC-ESVL02"  "SPC-ESVL03" 
## [306] "SPC-ESVL04"  "SPC-ESVL05"  "SPC-ESVL06"  "SPC-ESVL07"  "SPC-ESVL08" 
## [311] "SPC-ESVL09"  "SPC-ESVL10"  "SPC-ESVL11"  "SPC-ESVL12"  "SPC-ESVL13" 
## [316] "SPC-ESVL14"  "SPC-ESVL15"  "SPC-ESVL16"  "SPC-ESVL17"  "SPC-ESVL18" 
## [321] "SPC-ESVL19"  "SPC-ESVL20"  "ESBS-ESBS01" "ESBS-ESBS02" "ESBS-ESBS03"
## [326] "ESBS-ESBS04" "ESBS-ESBS05" "ESBS-ESBS06" "ESBS-ESBS07" "ESBS-ESBC01"
## [331] "ESBS-ESBC02" "ESBS-ESBC03" "ESBS-ESBC04" "ESBS-ESBC05" "ESBS-ESBC06"
## [336] "ESBS-ESBC07" "ESBE-ESBE01" "ESBE-ESBE02" "ESBE-ESBE03" "ESBE-ESBE04"
## [341] "ESBE-ESBE05" "ESBE-ESBE06" "ESBE-ESBE07" "ESBE-ESBE08" "ESBE-ESBE09"
## [346] "ESBE-ESBE10" "ESBE-ESBE11" "ESBE-ESBE12" "ESBE-ESBE13" "ESBE-ESBE14"
## [351] "ESBE-ESBE15" "ESTS-ESTS01" "ESTS-ESTS02" "ESTS-ESTS03" "ESTS-ESTS04"
## [356] "ESTS-ESTS05" "ESTS-ESTS06" "ESTS-ESTS07" "ESTS-ESTS08" "ESTS-ESTS09"
## [361] "ESTS-ESTS10" "ESBA-ESBA01" "ESBA-ESBA02" "ESBA-ESBA03" "ESBA-ESBA04"
## [366] "ESBA-ESBA05" "ESBA-ESBA06" "ESBA-ESBA07" "ESBA-ESBA08" "ESBA-ESBA09"
## [371] "ESBA-ESBA10" "ESBA-ESBA11" "ESBA-ESBA12" "ESBA-ESBA13" "ESBA-ESBA14"
## [376] "ESBA-ESBA15" "ESBA-ESBA16" "ESBA-ESBA17" "ESBA-ESBA18" "ESBA-ESBA19"
## [381] "ESBA-ESBA20" "ESBA-ESBA21" "ESBA-ESBA22" "ESBA-ESBA23" "ESBA-ESBA24"
## [386] "ESBA-ESBA25" "ESBA-ESBA26" "ESBA-ESBA27" "ESBA-ESBA28" "ESCP-ESCP01"
## [391] "ESCP-ESCP02" "ESCP-ESCP03" "ESCP-ESCP04" "ESCP-ESCP05" "ESCP-ESCP06"
## [396] "ESCP-ESCP07" "ESCP-ESCP08" "ESCP-ESCP09" "ESCP-ESCP10" "ESCP-ESCP11"
## [401] "ESCP-ESCP12" "ESCP-ESCP13" "ESCP-ESCP14" "ESCP-ESCP15" "ESCP-ESCP16"
## [406] "ESCP-ESCP17" "ESCP-ESCP18" "ESCP-ESCP19" "SPM-ESMG01"  "SPM-ESMG02" 
## [411] "SPM-ESMG03"  "SPM-ESMG04"  "SPM-ESMG05"  "SPM-ESMG06"  "SPM-ESMG07" 
## [416] "SPM-ESMG08"  "SPM-ESMG09"  "SPM-ESMG10"  "SPM-ESMG11"  "SPM-ESMG12" 
## [421] "SPM-ESMG13"  "SPM-ESMG14"  "SPM-ESMG15"  "SPM-ESMG16"  "SPM-ESMG17" 
## [426] "SPM-ESMG18"  "SPM-ESMG19"  "ITB-ITBL01"  "ITB-ITBL02"  "ITB-ITBL03" 
## [431] "ITB-ITBL04"  "ITB-ITBL05"  "ITB-ITBL06"  "ITB-ITBL07"  "ITB-ITBL08" 
## [436] "ITB-ITBL09"  "ITB-ITBL10"  "ITB-ITBL11"  "ITB-ITBL12"  "ITB-ITBL13" 
## [441] "ITB-ITBL14"  "ITB-ITBL15"  "ITB-ITBO01"  "ITB-ITBO02"  "ITB-ITBO03" 
## [446] "ITB-ITBO04"  "ITB-ITBO05"  "ITB-ITBO06"  "ITB-ITBO07"  "ITB-ITBO08" 
## [451] "ITB-ITBO09"  "ITB-ITBO10"  "ITB-ITBO11"  "ITB-ITBO12"  "ITB-ITBO13" 
## [456] "ITB-ITBO14"  "ITB-ITBO15"  "ITRO-ITRM01" "ITRO-ITRM02" "ITRO-ITRM03"
## [461] "ITRO-ITRM04" "ITRO-ITRM05" "ITRO-ITRM06" "ITRO-ITRM07" "ITRO-ITRM08"
## [466] "ITRO-ITRM09" "ITRO-ITRM10" "ITRO-ITRM11" "ITRO-ITRM12" "ITRO-ITRM13"
## [471] "ITRO-ITRO01" "ITRO-ITRO02" "ITRO-ITRO03" "ITRO-ITRO04" "ITRO-ITRO05"
## [476] "ITRO-ITRO06" "ITRO-ITRO07" "ITRO-ITRO08" "ITRO-ITRO09" "ITRO-ITRO10"
## [481] "ITRO-ITRO11" "ITRO-ITRO12" "ITRO-ITRO13" "ITRO-ITRO14" "ITRO-ITRO15"
## [486] "ITRO-ITRO16" "ITRO-ITRO17" "ITP-ITBR01"  "ITP-ITBR02"  "ITP-ITBR03" 
## [491] "ITP-ITBR04"  "ITP-ITBR05"  "ITP-ITBR06"  "ITP-ITBR07"  "ITP-ITBR08" 
## [496] "ITP-ITBR09"  "ITP-ITBR10"  "ITP-ITBR11"  "ITP-ITBR12"  "ITP-ITBR13" 
## [501] "ITP-ITBR14"  "ITP-ITBR15"  "ITP-ITBR16"  "ITP-ITBR17"  "ITP-ITBR18" 
## [506] "ITP-ITBR19"  "ITP-ITBR20"  "ITP-ITBR21"  "ITP-ITVL01"  "ITP-ITVL02" 
## [511] "ITP-ITVL03"  "ITP-ITVL04"  "ITP-ITVL05"  "ITP-ITVL06"  "ITP-ITVL07" 
## [516] "ITP-ITVL08"  "ITP-ITVL09"  "MAL-MTLU01"  "MAL-MTLU02"  "MAL-MTLU03" 
## [521] "MAL-MTLU04"  "MAL-MTLU05"  "MAL-MTLU06"  "MAL-MTLU07"  "MAL-MTLU08" 
## [526] "MAL-MTLU09"  "MAL-MTLU10"  "MAL-MTLU11"  "MAL-MTLU12"  "MAL-MTLU13" 
## [531] "MAL-MTLU14"  "MAL-MTLU15"  "MAL-MTLU16"  "MAL-MTLU17"  "MAL-MTLU18" 
## [536] "MAL-MTLU19"  "MAL-MTLU20"  "MAL-MTLU31"  "MAL-MTLU32"  "MAL-MTLU33" 
## [541] "MAL-MTLU34"  "MAL-MTLU35"  "MAL-MTLU36"  "MAL-MTLU37"  "MAL-MTLU38" 
## [546] "MAL-MTLU39"  "SLO-SLGO01"  "SLO-SLGO02"  "SLO-SLGO03"  "SLO-SLGO04" 
## [551] "SLO-SLGO05"  "SLO-SLGO06"  "SLO-SLGO07"  "SLO-SLGO08"  "SLO-SLGO09" 
## [556] "SLO-SLGO10"  "SLO-SLGO11"  "SLO-SLGO12"  "SLO-SLGO13"  "SLO-SLGO14" 
## [561] "SLO-SLGO15"  "SLO-SLGO25"  "SLO-SLGO26"  "SLO-SLGO27"  "SLO-SLGO28" 
## [566] "SLO-SLGO29"  "SLO-SLGO30"  "SLO-SLGO31"  "SLO-SLGO32"  "SLO-SLGO33" 
## [571] "SLO-SLGO34"  "SLO-SLGO35"  "SLO-SLGO36"  "SLO-SLGO37"  "SLO-SLGO38" 
## [576] "SLO-SLGO39"  "CRO-CRPL01"  "CRO-CRPL02"  "CRO-CRPL03"  "CRO-CRPL04" 
## [581] "CRO-CRPL05"  "CRO-CRPL06"  "CRO-CRPL07"  "CRO-CRPL08"  "CRO-CRPL09" 
## [586] "CRO-CRPL10"  "CRO-CRPL11"  "CRO-CRPL12"  "CRO-CRPL13"  "CRO-CRPL14" 
## [591] "CRO-CRPL15"  "CRO-CRPL16"  "CRO-CRPL17"  "CRO-CRPL18"  "CRO-CRPL19" 
## [596] "CRO-CRPL20"  "CRO-CRPL21"  "CRO-CRPL22"  "CRO-CRPL23"  "CRO-CRPL24" 
## [601] "CRO-CRPL25"  "CRO-CRPL26"  "CRO-CRPL27"  "CRO-CRPL28"  "CRO-CRPL29" 
## [606] "CRO-CRPL30"  "ALD-ALDU01"  "ALD-ALDU02"  "ALD-ALDU03"  "ALD-ALDU04" 
## [611] "ALD-ALDU05"  "ALD-ALDU06"  "ALD-ALDU07"  "ALD-ALDU08"  "ALD-ALDU09" 
## [616] "ALD-ALDU10"  "ALD-ALDU11"  "ALD-ALDU12"  "ALD-ALDU13"  "ALD-ALDU14" 
## [621] "ALD-ALDU15"  "ALD-ALDU16"  "ALD-ALDU17"  "ALD-ALDU18"  "ALD-ALDU19" 
## [626] "ALD-ALDU20"  "ALD-ALDU21"  "ALD-ALDU22"  "ALD-ALDU23"  "ALD-ALDU25" 
## [631] "ALD-ALDU26"  "ALD-ALDU27"  "ALD-ALDU28"  "ALD-ALDU29"  "ALD-ALDU30" 
## [636] "GRC-GRCA01"  "GRC-GRCA02"  "GRC-GRCA03"  "GRC-GRCA04"  "GRC-GRCA05" 
## [641] "GRC-GRCC01"  "GRC-GRCC02"  "GRC-GRCC03"  "GRC-GRCC04"  "GRC-GRCC05" 
## [646] "GRC-GRCC06"  "GRC-GRCC08"  "GRC-GRCC09"  "GRC-GRCC10"  "GRC-GRCC11" 
## [651] "GRC-GRCC12"  "GRC-GRCC13"  "GRC-GRCC14"  "GRC-GRCC15"  "GRC-GRCC16" 
## [656] "GRC-GRCC17"  "GRC-GRCC18"  "GRC-GRCC19"  "GRC-GRCC20"  "GRC-GRCC21" 
## [661] "GRC-GRCC22"  "GRC-GRCC23"  "GRC-GRCC24"  "GRC-GRCC25"  "GRPA-GRPA01"
## [666] "GRPA-GRPA02" "GRPA-GRPA03" "GRPA-GRPA04" "GRPA-GRPA05" "GRPA-GRPI01"
## [671] "GRPA-GRPI02" "GRPA-GRPI03" "GRPA-GRPI04" "GRPA-GRPI06" "GRPA-GRPP01"
## [676] "GRPA-GRPP02" "GRPA-GRPP03" "GRPA-GRPP04" "GRPA-GRPP05" "GRPA-GRPR01"
## [681] "GRPA-GRPR02" "GRPA-GRPR03" "GRPA-GRPR04" "GRPA-GRPR05" "GRPA-GRPR06"
## [686] "GRPA-GRPR07" "GRPA-GRPR08" "GRPA-GRPR09" "GRPA-GRPR10" "GRPA-GRPU01"
## [691] "GRPA-GRPU02" "GRPA-GRPU03" "GRPA-GRPU04" "GRA-GRAA01"  "GRA-GRAA02" 
## [696] "GRA-GRAA03"  "GRA-GRAA04"  "GRA-GRAA05"  "GRA-GRAA06"  "GRA-GRAA07" 
## [701] "GRA-GRAA08"  "GRA-GRAE01"  "GRA-GRAE02"  "GRA-GRAE03"  "GRA-GRAE04" 
## [706] "GRA-GRAE05"  "GRA-GRAE06"  "GRA-GRAE07"  "GRA-GRAE08"  "GRA-GRAH01" 
## [711] "GRA-GRAH02"  "GRA-GRAH05"  "GRA-GRAH06"  "GRA-GRAH07"  "GRA-GRAI01" 
## [716] "GRA-GRAN01"  "GRA-GRAN02"  "GRA-GRAN03"  "GRA-GRAN04"  "GRA-GRAN05" 
## [721] "GRA-GRAN06"  "GRA-GRAN07"  "GRA-GRAN08"  "GRTA-GRTA01" "GRTA-GRTA02"
## [726] "GRTA-GRTA03" "GRTA-GRTA04" "GRTA-GRTA05" "GRTA-GRTA06" "GRTA-GRTA07"
## [731] "GRTA-GRTA08" "GRTA-GRTA09" "GRTA-GRTA10" "GRTA-GRTA11" "GRTA-GRTA12"
## [736] "GRTA-GRTA13" "GRTA-GRTA14" "GRTA-GRTA15" "GRTA-GRTA23" "GRTA-GRTA24"
## [741] "GRTA-GRTA25" "GRTA-GRTA26" "GRTA-GRTA27" "GRTA-GRTI01" "GRTA-GRTI02"
## [746] "GRTA-GRTI03" "GRTA-GRTI04" "GRTA-GRTI05" "GRTA-GRTT01" "GRTA-GRTT02"
## [751] "GRTA-GRTT03" "GRTA-GRTT04" "GRTA-GRTT05" "GRKV-GRKA01" "GRKV-GRKA02"
## [756] "GRKV-GRKA03" "GRKV-GRKA04" "GRKV-GRKA05" "GRKV-GRKB01" "GRKV-GRKB02"
## [761] "GRKV-GRKB03" "GRKV-GRKB04" "GRKV-GRKL01" "GRKV-GRKL02" "GRKV-GRKL03"
## [766] "GRKV-GRKL04" "GRKV-GRKL05" "GRKV-GRKV01" "GRKV-GRKV02" "GRKV-GRKV03"
## [771] "GRKV-GRKV04" "GRKV-GRKV05" "GRKV-GRKV06" "GRKV-GRKV07" "GRKV-GRKV08"
## [776] "GRKV-GRKV09" "GRKV-GRKV10" "GRKV-GRKV11" "GRKV-GRKV12" "GRKV-GRKV13"
## [781] "GRKV-GRKV14" "GRKV-GRKV15"

Save it as rds

saveRDS(
  southern, here(
    "output/europe/dapc/microsats/southern/microsats_europe_southern.rds"
  )
)

To load it

southern <- readRDS(
  here(
    "output/europe/dapc/microsats/southern/microsats_europe_southern.rds"
  )
)

4.3.2. Add countries

strata(southern) <- data.frame(pop(southern))

# Currently set on just 
head(pop(southern)) 
## [1] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
## 54 Levels: POP-PTPN60 POL-PTQT15 SPB-ESBD11 ESAC-ESAC07 ... GRKV-GRKV15
#pops_southern <- as.data.frame(pop(southern))
#write.csv(pops_southern, here("DAPC/southern/pops_southern.csv"))

4.3.3. Get Sample Locations

Import sample data Load the csv

sampling_loc <- read.csv(here("output/europe/dapc/microsats/sampling_loc_euro_microsats.csv"))
sampling_loc <- as.data.frame(sampling_loc)

head(sampling_loc)
##        Pop_City    Country  Latitude Longitude Continent Abbreviation
## 1      Gravatai     Brazil -29.93760 -50.99070  Americas          GRV
## 2 Puerto Iguazu  Argentina -25.59720 -54.57860  Americas          POR
## 3      Vohimasy Madagascar -22.81591  47.75026    Africa          VOH
## 4 Trois-Bassins    Reunion -21.10901  55.31921    Africa          TRO
## 5     Morondava Madagascar -20.28420  44.27940    Africa          MAD
## 6       Dauguet  Mauritius -20.18530  57.52154    Africa          DAU
##          Year        Region    Subregion order order2 orderold order_microsat
## 1        2018 South America                  8     NA       82             NA
## 2        2018 South America                 NA     NA       NA             NA
## 3 2016 & 2017   East Africa  East Africa    NA     79       NA             NA
## 4        2017  Indian Ocean Indian Ocean    81     81       73             NA
## 5        2016   East Africa  East Africa    80     78       72             NA
## 6        2022  Indian Ocean Indian Ocean    82     80       74             NA
##   microsats microsat_code alt_code  X  Country.1 X.1 X.2 X.3 X.4 X.5 X.6
## 1                                  NA     Brazil  NA  NA  NA  NA  NA  NA
## 2                                  NA  Argentina  NA  NA  NA  NA  NA  NA
## 3                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 4                                  NA    Reunion  NA  NA  NA  NA  NA  NA
## 5                                  NA Madagascar  NA  NA  NA  NA  NA  NA
## 6                                  NA  Mauritius  NA  NA  NA  NA  NA  NA

Load the csv

countr <- read.csv(here("output/europe/dapc/microsats/southern/DAPC_countries_microsats_southern.csv"
))
df <- as.data.frame(countr)

head(df)
##   pops  country
## 1  POP Portugal
## 2  POP Portugal
## 3  POP Portugal
## 4  POP Portugal
## 5  POP Portugal
## 6  POP Portugal
southern@pop <- as.factor(df$country)
southern$pop
##   [1] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [9] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [17] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [25] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [33] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [41] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [49] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [57] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [65] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [73] Portugal Portugal Portugal Spain    Spain    Spain    Spain    Spain   
##  [81] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [89] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [97] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [105] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [113] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [121] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [129] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [137] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [145] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [153] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [161] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [169] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [177] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [185] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [193] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [201] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [209] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [217] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [225] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [233] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [241] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [249] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [257] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [265] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [273] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [281] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [289] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [297] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [305] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [313] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [321] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [329] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [337] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [345] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [353] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [361] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [369] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [377] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [385] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [393] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [401] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [409] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [417] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [425] Spain    Spain    Spain    Italy    Italy    Italy    Italy    Italy   
## [433] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [441] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [449] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [457] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [465] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [473] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [481] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [489] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [497] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [505] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [513] Italy    Italy    Italy    Italy    Italy    Malta    Malta    Malta   
## [521] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
## [529] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
## [537] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
## [545] Malta    Malta    Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [553] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [561] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [569] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [577] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
## [585] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
## [593] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
## [601] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Albania  Albania 
## [609] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
## [617] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
## [625] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
## [633] Albania  Albania  Albania  Greece   Greece   Greece   Greece   Greece  
## [641] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [649] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [657] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [665] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [673] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [681] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [689] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [697] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [705] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [713] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [721] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [729] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [737] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [745] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [753] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [761] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [769] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [777] Greece   Greece   Greece   Greece   Greece   Greece  
## Levels: Albania Croatia Greece Italy Malta Portugal Slovenia Spain

Save the genind object

saveRDS(southern, here("output/europe/dapc/microsats/southern/microsat_country_southern.rds"
))
southern@pop <- as.factor(df$pop)
southern$pop
##   [1] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [16] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [31] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [46] POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP  POP 
##  [61] POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL  POL 
##  [76] SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  SPB  ESAC ESAC ESAC ESAC
##  [91] ESAC ESAC ESAC ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO ESMO
## [106] ESMO ESMO ESMO ESMO ESMO ESMO ESSV ESSV ESSV ESSV ESSV ESSV ESSV ESSV ESSV
## [121] ESSV ESSV ESSV ESSV ESAL ESAL ESAL ESAL ESAL ESAL SPS  SPS  SPS  SPS  SPS 
## [136] SPS  SPS  SPS  SPS  SPS  ESMN ESMN ESMN ESLS ESLS ESLS ESMV ESMV ESMV ESFU
## [151] ESFU ESFU ESBM ESBM ESBM ESBM ESTM ESTM ESTM ESTM ESTM ESTM ESTM ESTM ESTM
## [166] ESTM ESTM ESTM ESTM ESTM ESTM ESGD ESGD ESBN ESBN ESBN ESBN ESBN ESBN ESSL
## [181] ESSL ESSL ESMC ESMC ESMC ESMC ESVN ESPT ESAB ESAB ESAB ESAB ESAB ESAB ESAB
## [196] ESAB ESAB ESAB ESAB ESAB ESAB ESAB ESBY ESBY ESBY ESBY ESBY ESBY ESNI ESNI
## [211] ESNI ESNI ESNI ESNI ESNI ESNI ESNI ESNU ESNU ESNU ESNU ESNU ESNU ESIR ESIR
## [226] ESIR ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAG ESAZ ESAZ ESAZ ESAZ
## [241] ESCN ESCN ESCN ESCN ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT ESCT
## [256] ESCT ESCT ESCT ESCT ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU ESMU
## [271] ESMU ESMU ESMU ESMU ESMU ESMU ESPP ESPP ESPP ESPP ESPP ESPP ESCH ESCH ESLM
## [286] ESLM ESLM ESLM ESCA ESCA ESCA ESCA ESCA ESAY ESAY ESAY ESAY ESAY ESAY ESAY
## [301] ESAY ESAY SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC  SPC 
## [316] SPC  SPC  SPC  SPC  SPC  SPC  SPC  ESBS ESBS ESBS ESBS ESBS ESBS ESBS ESBS
## [331] ESBS ESBS ESBS ESBS ESBS ESBS ESBE ESBE ESBE ESBE ESBE ESBE ESBE ESBE ESBE
## [346] ESBE ESBE ESBE ESBE ESBE ESBE ESTS ESTS ESTS ESTS ESTS ESTS ESTS ESTS ESTS
## [361] ESTS ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA
## [376] ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESBA ESCP
## [391] ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP ESCP
## [406] ESCP ESCP ESCP SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM  SPM 
## [421] SPM  SPM  SPM  SPM  SPM  SPM  SPM  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB 
## [436] ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITB 
## [451] ITB  ITB  ITB  ITB  ITB  ITB  ITB  ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO
## [466] ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITRO
## [481] ITRO ITRO ITRO ITRO ITRO ITRO ITRO ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP 
## [496] ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP  ITP 
## [511] ITP  ITP  ITP  ITP  ITP  ITP  ITP  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL 
## [526] MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL  MAL 
## [541] MAL  MAL  MAL  MAL  MAL  MAL  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO 
## [556] SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO  SLO 
## [571] SLO  SLO  SLO  SLO  SLO  SLO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO 
## [586] CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO  CRO 
## [601] CRO  CRO  CRO  CRO  CRO  CRO  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD 
## [616] ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD  ALD 
## [631] ALD  ALD  ALD  ALD  ALD  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC 
## [646] GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC  GRC 
## [661] GRC  GRC  GRC  GRC  GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA
## [676] GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA GRPA
## [691] GRPA GRPA GRPA GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA 
## [706] GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA  GRA 
## [721] GRA  GRA  GRA  GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA
## [736] GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA GRTA
## [751] GRTA GRTA GRTA GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV
## [766] GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV GRKV
## [781] GRKV GRKV
## 54 Levels: ALD CRO ESAB ESAC ESAG ESAL ESAY ESAZ ESBA ESBE ESBM ESBN ... SPS

Save the genind object

saveRDS(southern, here("output/europe/dapc/microsats/southern/microsat_pop_southern.rds"
))

Load the genind object

microsat_pop_southern <- readRDS(here("output/europe/dapc/microsats/southern/microsat_pop_southern.rds"
))

4.3.4. Scale

microsat_pop_southern <- scaleGen(southern, NA.method="mean")
class(microsat_pop_southern)
dim(microsat_pop_southern)
## NULL
microsat_pop_southern[1:5,1:5]
## /// GENIND OBJECT /////////
## 
##  // 5 individuals; 1 locus; 5 alleles; size: 10.9 Kb
## 
##  // Basic content
##    @tab:  5 x 5 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 5-5)
##    @loc.fac: locus factor for the 5 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: .local(x = x, i = i, j = j, drop = drop)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 5-5)
##    @strata: a data frame with 1 columns ( pop.southern. )
# Get the populations from the genlight object
populations <- southern$pop

4.3.5. Find clusters

grp <- find.clusters(microsat_pop_southern, max.n.clust=22)
#retained 150
#Choose the number of clusters (>=2): 20

Save the genind object

saveRDS(grp, here("output/europe/dapc/microsats/southern/grp_20.rds"
))

Load the genind object

grp <- readRDS(here("output/europe/dapc/microsats/southern/grp_20.rds"))
names(grp)
## [1] "Kstat" "stat"  "grp"   "size"
grp$size #group sizes for our clusters
##  [1]  30   6   1   7   1   1 177   3   5   3  14  14  71  27 276   6  21  15 102
## [20]   2
table(pop(southern), grp$grp)
##       
##         1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   ALD   0  0  0  0  0  0 11  0  0  0  0  0  0  0 17  1  0  0  0  0
##   CRO   0  0  0  0  0  0  4  0  0  0  0  0  2  0 24  0  0  0  0  0
##   ESAB  0  0  0  0  0  0  5  0  0  0  0  0  0  0  9  0  0  0  0  0
##   ESAC  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  7  0
##   ESAG  0  0  0  0  0  0  0  0  0  0  0  0  0  0  4  0  0  0  6  0
##   ESAL  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  5  0
##   ESAY  0  0  0  0  0  0  4  0  0  0  0  0  0  0  5  0  0  0  0  0
##   ESAZ  0  0  0  0  0  0  0  0  0  0  0  0  0  0  4  0  0  0  0  0
##   ESBA  0  0  1  0  0  1  4  0  0  2  0  0  3  0  2  0  0  1 14  0
##   ESBE  0  0  0  0  0  0  1  0  0  0  0  0  9  0  5  0  0  0  0  0
##   ESBM  0  0  0  0  0  0  0  0  0  0  0  0  1  0  3  0  0  0  0  0
##   ESBN  0  0  0  0  0  0  1  0  0  0  0  0  0  0  5  0  0  0  0  0
##   ESBS  0  0  0  0  0  0  3  0  0  0  0  0  1  0  7  0  0  0  3  0
##   ESBY  0  0  0  0  0  0  0  0  0  0  0  0  0  0  6  0  0  0  0  0
##   ESCA  3  0  0  0  0  0  1  0  0  0  0  0  1  0  0  0  0  0  0  0
##   ESCH  0  0  0  0  0  0  0  0  0  0  0  0  0  0  2  0  0  0  0  0
##   ESCN  4  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##   ESCP  0  0  0  0  0  0  0  0  0  0  0 14  1  0  0  0  0  0  4  0
##   ESCT  0  0  0  0  1  0  6  0  0  0  0  0  0  0  7  0  0  0  1  0
##   ESFU  0  0  0  0  0  0  1  0  0  0  0  0  0  0  2  0  0  0  0  0
##   ESGD  0  0  0  0  0  0  0  0  0  0  0  0  0  0  2  0  0  0  0  0
##   ESIR  0  0  0  0  0  0  0  0  0  0  0  0  0  0  3  0  0  0  0  0
##   ESLM  2  0  0  0  0  0  0  0  0  0  0  0  0  0  2  0  0  0  0  0
##   ESLS  0  0  0  0  0  0  0  0  0  0  0  0  0  0  3  0  0  0  0  0
##   ESMC  1  0  0  0  0  0  0  0  0  0  0  0  0  0  3  0  0  0  0  0
##   ESMN  0  0  0  0  0  0  2  0  0  0  0  0  0  0  1  0  0  0  0  0
##   ESMO  0  0  0  0  0  0  0  0  0  0  0  0  0 18  0  0  0  0  0  0
##   ESMU  8  0  0  0  0  0  1  0  0  0  0  0  0  0  8  0  0  0  0  0
##   ESMV  1  0  0  0  0  0  1  0  0  0  0  0  1  0  0  0  0  0  0  0
##   ESNI  4  0  0  0  0  0  1  0  0  0  0  0  0  0  4  0  0  0  0  0
##   ESNU  0  0  0  0  0  0  1  0  0  0  0  0  0  0  5  0  0  0  0  0
##   ESPP  0  0  0  0  0  0  0  1  0  0  0  0  0  0  4  1  0  0  0  0
##   ESPT  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0
##   ESSL  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  2
##   ESSV  1  0  0  0  0  0  6  1  0  0  0  0  2  0  2  0  0  0  1  0
##   ESTM  0  0  0  0  0  0  1  0  0  0  0  0  1  0 12  0  1  0  0  0
##   ESTS  0  0  0  0  0  0 10  0  0  0  0  0  0  0  0  0  0  0  0  0
##   ESVN  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##   GRA   0  0  0  0  0  0 22  0  0  0  0  0  0  0  8  0  0  0  0  0
##   GRC   0  0  0  0  0  0 21  0  0  0  0  0  0  0  8  0  0  0  0  0
##   GRKV  0  0  0  0  0  0  4  0  0  0  0  0  0  0 25  0  0  0  0  0
##   GRPA  0  5  0  0  0  0  9  0  5  0  0  0  0  0  9  0  0  0  1  0
##   GRTA  0  0  0  0  0  0  4  0  0  0  0  0  0  0 26  0  0  0  0  0
##   ITB   1  0  0  0  0  0 16  0  0  0  0  0  1  0  9  0  0  0  3  0
##   ITP   0  0  0  6  0  0  1  0  0  0  0  0  0  0  1  2 20  0  0  0
##   ITRO  1  0  0  0  0  0  6  0  0  0  0  0  7  0 16  0  0  0  0  0
##   MAL   3  0  0  0  0  0 11  0  0  0  0  0 12  0  2  1  0  0  0  0
##   POL   0  0  0  0  0  0  0  0  0  0  0  0  0  3  2  0  0 10  0  0
##   POP   0  0  0  0  0  0  2  0  0  1 14  0  0  3  0  0  0  4 36  0
##   SLO   1  0  0  0  0  0 10  0  0  0  0  0  1  0 15  1  0  0  2  0
##   SPB   0  0  0  0  0  0  2  0  0  0  0  0  6  0  0  0  0  0  3  0
##   SPC   0  0  0  0  0  0  2  0  0  0  0  0 11  1  0  0  0  0  6  0
##   SPM   0  1  0  0  0  0  0  0  0  0  0  0  6  1  1  0  0  0 10  0
##   SPS   0  0  0  0  0  0  3  0  0  0  0  0  5  0  2  0  0  0  0  0

4.3.6. Run dapc

dapc1 <- dapc(microsat_pop_southern, grp$grp)
#150 PCs retained
#19 discriminant functions retained

Save the genind object

saveRDS(dapc1, here("output/europe/dapc/microsats/southern/dapc1.rds"
))

Load the genind object

dapc1 <- readRDS(here("output/europe/dapc/microsats/southern/dapc1.rds"
))
dapc1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1)
## 
## $n.pca: 150 first PCs of PCA used
## $n.da: 19 discriminant functions saved
## $var (proportion of conserved variance): 0.984
## 
## $eig (eigenvalues): 296200 92430 15200 5787 2530 ...
## 
##   vector    length content                   
## 1 $eig      19     eigenvalues               
## 2 $grp      782    prior group assignment    
## 3 $prior    20     prior group probabilities 
## 4 $assign   782    posterior group assignment
## 5 $pca.cent 179    centring vector of PCA    
## 6 $pca.norm 179    scaling vector of PCA     
## 7 $pca.eig  163    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          782  150  retained PCs of PCA                              
## 2 $means        20   150  group means                                      
## 3 $loadings     150  19   loadings of variables                            
## 4 $ind.coord    782  19   coordinates of individuals (principal components)
## 5 $grp.coord    20   19   coordinates of groups                            
## 6 $posterior    782  20   posterior membership probabilities               
## 7 $pca.loadings 179  150  PCA loadings of original variables               
## 8 $var.contr    179  19   contribution of original variables

4.3.7. Calculating the optimum PC number to rerun DAPC

optim.a.score(dapc1, n.pca=1:ncol(dapc1$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10) #calculating optimal number of PCs
#Optimal number = 25

4.3.8. Now do cross-validation

Cross-validation: The Discriminant Analysis of Principal Components (DAPC) relies on dimension reduction of the data using PCA followed by a linear discriminant analysis. How many PCA axes to retain is often a non-trivial question. Cross validation provides an objective way to decide how many axes to retain: different numbers are tried and the quality of the corresponding DAPC is assessed by cross- validation: DAPC is performed on a training set, typically made of 90% of the observations (comprising 90% of the observations in each subpopulation) , and then used to predict the groups of the 10% of remaining observations. The current method uses the average prediction success per group (result=“groupMean”), or the overall prediction success (result=“overall”). The number of PCs associated with the lowest Mean Squared Error is then retained in the DAPC.

xvalDapc(microsat_pop_southern, populations, n.pca.max = 200, n.da = NULL,
              training.set = 0.9, result = c("groupMean", "overall"),
              center = TRUE, scale = FALSE,
              n.pca=NULL, n.rep = 30, xval.plot = TRUE) 

60 first PCs of PCA used 53 discriminant functions saved proportion of conserved variance: 0.617

Run DAPC with object using x-val recommendations

dapc_southern_1 <- dapc(microsat_pop_southern, n.pca = 60, n.da = 53, grp = populations)
dapc_southern_1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_southern, n.pca = 60, n.da = 53, 
##     grp = populations)
## 
## $n.pca: 60 first PCs of PCA used
## $n.da: 53 discriminant functions saved
## $var (proportion of conserved variance): 0.919
## 
## $eig (eigenvalues): 67.04 54.64 32.48 24.74 20.46 ...
## 
##   vector    length content                   
## 1 $eig      53     eigenvalues               
## 2 $grp      782    prior group assignment    
## 3 $prior    54     prior group probabilities 
## 4 $assign   782    posterior group assignment
## 5 $pca.cent 179    centring vector of PCA    
## 6 $pca.norm 179    scaling vector of PCA     
## 7 $pca.eig  161    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          782  60   retained PCs of PCA                              
## 2 $means        54   60   group means                                      
## 3 $loadings     60   53   loadings of variables                            
## 4 $ind.coord    782  53   coordinates of individuals (principal components)
## 5 $grp.coord    54   53   coordinates of groups                            
## 6 $posterior    782  54   posterior membership probabilities               
## 7 $pca.loadings 179  60   PCA loadings of original variables               
## 8 $var.contr    179  53   contribution of original variables

dapc with optimal # of PCs recommended

dapc_southern_2 <- dapc(microsat_pop_southern, n.pca = 25, n.da = 19, grp = populations)
dapc_southern_2
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.genind(x = microsat_pop_southern, n.pca = 25, n.da = 19, 
##     grp = populations)
## 
## $n.pca: 25 first PCs of PCA used
## $n.da: 19 discriminant functions saved
## $var (proportion of conserved variance): 0.684
## 
## $eig (eigenvalues): 39.76 17.26 14.35 13.66 9.425 ...
## 
##   vector    length content                   
## 1 $eig      25     eigenvalues               
## 2 $grp      782    prior group assignment    
## 3 $prior    54     prior group probabilities 
## 4 $assign   782    posterior group assignment
## 5 $pca.cent 179    centring vector of PCA    
## 6 $pca.norm 179    scaling vector of PCA     
## 7 $pca.eig  161    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          782  25   retained PCs of PCA                              
## 2 $means        54   25   group means                                      
## 3 $loadings     25   19   loadings of variables                            
## 4 $ind.coord    782  19   coordinates of individuals (principal components)
## 5 $grp.coord    54   19   coordinates of groups                            
## 6 $posterior    782  54   posterior membership probabilities               
## 7 $pca.loadings 179  25   PCA loadings of original variables               
## 8 $var.contr    179  19   contribution of original variables

4.3.9. Plots

scatter(dapc_southern_1)

scatter(dapc_southern_2)

colors for each pop

myCol8 <- c("#51f310", "#146c45","yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "yellow3", "#a41415", "#a41415", "#a41415", "#a41415", "#a41415", "#2524f9", "#2524f9", "#2524f9", "purple", "#FF7F00", "#FF7F00", "#75d5e1", "yellow3", "yellow3", "yellow3", "yellow3"
)

Plot using different discriminant functions 1 & 2

pdf(file = "output/europe/dapc/microsats/southern/dapc1_microsats_all_southern_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=2)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=2)

1 & 3

pdf(file = "output/europe/dapc/microsats/southern/dapc1_microsats_all_southern_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/microsats/southern/dapc1_microsats_all_southern_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax =1, yax=4)

2 & 4

pdf(file = "output/europe/dapc/microsats/southern/dapc1_microsats_all_southern_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=2, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=2, yax=4)

2 & 3

pdf(file = "output/europe/dapc/microsats/southern/dapc1_microsats_all_southern_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=2, yax=3)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=2, yax=3)

3 & 4

pdf(file = "output/europe/dapc/microsats/southern/dapc1_microsats_all_southern_PC3_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=3, yax=4)

dev.off()
op <- par(cex = 0.5)
scatter(dapc_southern_1, pch = good.shapes, cstar = 0, col=myCol8, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft", xax=3, yax=4)

5. DAPC for 24 pops in the micosats dataset that overlap with SNP dataset

Load .gen file with microsat data from all individuals

europe_over <- read.genepop("output/europe/dapc/microsats/overlap/for_fst_albo_microsat_overlap.gen", ncode=3L)
## 
##  Converting data from a Genepop .gen file to a genind object... 
## 
## 
## File description:  ARBOMONITOR_Aedes_albopictus                                           
## 
## ...done.
europe_over
## /// GENIND OBJECT /////////
## 
##  // 637 individuals; 11 loci; 163 alleles; size: 486.7 Kb
## 
##  // Basic content
##    @tab:  637 x 163 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 6-22)
##    @loc.fac: locus factor for the 163 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: read.genepop(file = "output/europe/dapc/microsats/overlap/for_fst_albo_microsat_overlap.gen", 
##     ncode = 3L)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 5-60)
pop(europe_over)
##   [1] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##   [7] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [13] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [19] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [25] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [31] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [37] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [43] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [49] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [55] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
##  [61] SPB-ESBD11 SPB-ESBD11 SPB-ESBD11 SPB-ESBD11 SPB-ESBD11 SPB-ESBD11
##  [67] SPB-ESBD11 SPB-ESBD11 SPB-ESBD11 SPB-ESBD11 SPB-ESBD11 BUL-BULO34
##  [73] BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34
##  [79] BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34
##  [85] BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34
##  [91] BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34
##  [97] BUL-BULO34 BUL-BULO34 BUL-BULO34 BUL-BULO34 ROS-ROSM30 ROS-ROSM30
## [103] ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30
## [109] ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30
## [115] ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30
## [121] ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30
## [127] ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 ROS-ROSM30 SOC-RUSO10 SOC-RUSO10
## [133] SOC-RUSO10 SOC-RUSO10 SOC-RUSO10 SOC-RUSO10 SOC-RUSO10 SOC-RUSO10
## [139] SOC-RUSO10 SOC-RUSO10 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30
## [145] SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30
## [151] SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30
## [157] SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30
## [163] SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30 SER-SRNO30
## [169] SER-SRNO30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30
## [175] TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30
## [181] TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30
## [187] TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30
## [193] TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30 TUA-TRLG30
## [199] TUA-TRLG30 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29
## [205] TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29
## [211] TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29
## [217] TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29
## [223] TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29 TUH-TRHO29
## [229] ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30
## [235] ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30
## [241] ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30
## [247] ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30
## [253] ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 ALD-ALDU30 CRO-CRPL30
## [259] CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30
## [265] CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30
## [271] CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30
## [277] CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30
## [283] CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 CRO-CRPL30 GRC-GRCC25
## [289] GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25
## [295] GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25
## [301] GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25
## [307] GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25
## [313] GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRC-GRCC25 GRA-GRAN08 GRA-GRAN08
## [319] GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08
## [325] GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08
## [331] GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08
## [337] GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08
## [343] GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 GRA-GRAN08 ITP-ITVL09 ITP-ITVL09
## [349] ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09
## [355] ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09
## [361] ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09
## [367] ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09
## [373] ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITP-ITVL09 ITR-ITRO17 ITR-ITRO17
## [379] ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17
## [385] ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17
## [391] ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17
## [397] ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17
## [403] ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITR-ITRO17 ITB-ITBO15 ITB-ITBO15
## [409] ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15
## [415] ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15
## [421] ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15
## [427] ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15
## [433] ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 ITB-ITBO15 MAL-MTLU39 MAL-MTLU39
## [439] MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39
## [445] MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39
## [451] MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39
## [457] MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 MAL-MTLU39
## [463] MAL-MTLU39 MAL-MTLU39 MAL-MTLU39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39
## [469] SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39
## [475] SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39
## [481] SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39
## [487] SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SLO-SLGO39
## [493] SLO-SLGO39 SLO-SLGO39 SLO-SLGO39 SPS-ESUP10 SPS-ESUP10 SPS-ESUP10
## [499] SPS-ESUP10 SPS-ESUP10 SPS-ESUP10 SPS-ESUP10 SPS-ESUP10 SPS-ESUP10
## [505] SPS-ESUP10 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20
## [511] SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20
## [517] SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPC-ESVL20
## [523] SPC-ESVL20 SPC-ESVL20 SPC-ESVL20 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19
## [529] SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19
## [535] SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19
## [541] SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 SPM-ESMG19 FRS-FRMH45 FRS-FRMH45
## [547] FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45
## [553] FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45
## [559] FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45
## [565] FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45
## [571] FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 FRS-FRMH45 STS-FRST30 STS-FRST30
## [577] STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30
## [583] STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30
## [589] STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30
## [595] STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30
## [601] STS-FRST30 STS-FRST30 STS-FRST30 STS-FRST30 GES-ABSU05 GES-ABSU05
## [607] GES-ABSU05 GES-ABSU05 GES-ABSU05 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28
## [613] BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28
## [619] BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28
## [625] BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28
## [631] BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28 BAR-ESBA28
## [637] BAR-ESBA28
## 24 Levels: POP-PTPN60 SPB-ESBD11 BUL-BULO34 ROS-ROSM30 ... BAR-ESBA28

covert it to genind format

# import the data
nInd(europe_over)
## [1] 637
nLoc(europe_over)
## [1] 11
nPop(europe_over)
## [1] 24
indNames(europe_over)
##   [1] "POP-PTPN01" "POP-PTPN02" "POP-PTPN03" "POP-PTPN04" "POP-PTPN05"
##   [6] "POP-PTPN06" "POP-PTPN07" "POP-PTPN08" "POP-PTPN09" "POP-PTPN10"
##  [11] "POP-PTPN11" "POP-PTPN12" "POP-PTPN13" "POP-PTPN14" "POP-PTPN15"
##  [16] "POP-PTPN16" "POP-PTPN17" "POP-PTPN18" "POP-PTPN19" "POP-PTPN20"
##  [21] "POP-PTPN21" "POP-PTPN22" "POP-PTPN23" "POP-PTPN24" "POP-PTPN25"
##  [26] "POP-PTPN26" "POP-PTPN27" "POP-PTPN28" "POP-PTPN29" "POP-PTPN30"
##  [31] "POP-PTPN31" "POP-PTPN32" "POP-PTPN33" "POP-PTPN34" "POP-PTPN35"
##  [36] "POP-PTPN36" "POP-PTPN37" "POP-PTPN38" "POP-PTPN39" "POP-PTPN40"
##  [41] "POP-PTPN41" "POP-PTPN42" "POP-PTPN43" "POP-PTPN44" "POP-PTPN45"
##  [46] "POP-PTPN46" "POP-PTPN47" "POP-PTPN48" "POP-PTPN49" "POP-PTPN50"
##  [51] "POP-PTPN51" "POP-PTPN52" "POP-PTPN53" "POP-PTPN54" "POP-PTPN55"
##  [56] "POP-PTPN56" "POP-PTPN57" "POP-PTPN58" "POP-PTPN59" "POP-PTPN60"
##  [61] "SPB-ESBD01" "SPB-ESBD02" "SPB-ESBD03" "SPB-ESBD04" "SPB-ESBD05"
##  [66] "SPB-ESBD06" "SPB-ESBD07" "SPB-ESBD08" "SPB-ESBD09" "SPB-ESBD10"
##  [71] "SPB-ESBD11" "BUL-BULO01" "BUL-BULO02" "BUL-BULO03" "BUL-BULO04"
##  [76] "BUL-BULO05" "BUL-BULO06" "BUL-BULO07" "BUL-BULO08" "BUL-BULO09"
##  [81] "BUL-BULO10" "BUL-BULO11" "BUL-BULO12" "BUL-BULO13" "BUL-BULO14"
##  [86] "BUL-BULO15" "BUL-BULO16" "BUL-BULO17" "BUL-BULO18" "BUL-BULO20"
##  [91] "BUL-BULO25" "BUL-BULO26" "BUL-BULO27" "BUL-BULO28" "BUL-BULO29"
##  [96] "BUL-BULO30" "BUL-BULO31" "BUL-BULO32" "BUL-BULO33" "BUL-BULO34"
## [101] "ROS-ROSM01" "ROS-ROSM02" "ROS-ROSM03" "ROS-ROSM04" "ROS-ROSM05"
## [106] "ROS-ROSM06" "ROS-ROSM07" "ROS-ROSM08" "ROS-ROSM09" "ROS-ROSM10"
## [111] "ROS-ROSM11" "ROS-ROSM12" "ROS-ROSM13" "ROS-ROSM14" "ROS-ROSM15"
## [116] "ROS-ROSM16" "ROS-ROSM17" "ROS-ROSM18" "ROS-ROSM19" "ROS-ROSM20"
## [121] "ROS-ROSM21" "ROS-ROSM22" "ROS-ROSM23" "ROS-ROSM24" "ROS-ROSM25"
## [126] "ROS-ROSM26" "ROS-ROSM27" "ROS-ROSM28" "ROS-ROSM29" "ROS-ROSM30"
## [131] "SOC-RUSO01" "SOC-RUSO02" "SOC-RUSO03" "SOC-RUSO04" "SOC-RUSO05"
## [136] "SOC-RUSO06" "SOC-RUSO07" "SOC-RUSO08" "SOC-RUSO09" "SOC-RUSO10"
## [141] "SER-SRNO01" "SER-SRNO02" "SER-SRNO03" "SER-SRNO04" "SER-SRNO05"
## [146] "SER-SRNO06" "SER-SRNO07" "SER-SRNO08" "SER-SRNO09" "SER-SRNO10"
## [151] "SER-SRNO11" "SER-SRNO12" "SER-SRNO14" "SER-SRNO15" "SER-SRNO16"
## [156] "SER-SRNO17" "SER-SRNO18" "SER-SRNO19" "SER-SRNO20" "SER-SRNO21"
## [161] "SER-SRNO22" "SER-SRNO23" "SER-SRNO24" "SER-SRNO25" "SER-SRNO26"
## [166] "SER-SRNO27" "SER-SRNO28" "SER-SRNO29" "SER-SRNO30" "TUA-TRLG01"
## [171] "TUA-TRLG02" "TUA-TRLG03" "TUA-TRLG04" "TUA-TRLG05" "TUA-TRLG06"
## [176] "TUA-TRLG07" "TUA-TRLG08" "TUA-TRLG09" "TUA-TRLG10" "TUA-TRLG11"
## [181] "TUA-TRLG12" "TUA-TRLG13" "TUA-TRLG14" "TUA-TRLG15" "TUA-TRLG16"
## [186] "TUA-TRLG17" "TUA-TRLG18" "TUA-TRLG19" "TUA-TRLG20" "TUA-TRLG21"
## [191] "TUA-TRLG22" "TUA-TRLG23" "TUA-TRLG24" "TUA-TRLG25" "TUA-TRLG26"
## [196] "TUA-TRLG27" "TUA-TRLG28" "TUA-TRLG29" "TUA-TRLG30" "TUH-TRHO01"
## [201] "TUH-TRHO02" "TUH-TRHO03" "TUH-TRHO04" "TUH-TRHO05" "TUH-TRHO06"
## [206] "TUH-TRHO07" "TUH-TRHO08" "TUH-TRHO09" "TUH-TRHO10" "TUH-TRHO11"
## [211] "TUH-TRHO12" "TUH-TRHO13" "TUH-TRHO14" "TUH-TRHO15" "TUH-TRHO16"
## [216] "TUH-TRHO17" "TUH-TRHO18" "TUH-TRHO19" "TUH-TRHO20" "TUH-TRHO21"
## [221] "TUH-TRHO22" "TUH-TRHO23" "TUH-TRHO24" "TUH-TRHO25" "TUH-TRHO26"
## [226] "TUH-TRHO27" "TUH-TRHO28" "TUH-TRHO29" "ALD-ALDU01" "ALD-ALDU02"
## [231] "ALD-ALDU03" "ALD-ALDU04" "ALD-ALDU05" "ALD-ALDU06" "ALD-ALDU07"
## [236] "ALD-ALDU08" "ALD-ALDU09" "ALD-ALDU10" "ALD-ALDU11" "ALD-ALDU12"
## [241] "ALD-ALDU13" "ALD-ALDU14" "ALD-ALDU15" "ALD-ALDU16" "ALD-ALDU17"
## [246] "ALD-ALDU18" "ALD-ALDU19" "ALD-ALDU20" "ALD-ALDU21" "ALD-ALDU22"
## [251] "ALD-ALDU23" "ALD-ALDU25" "ALD-ALDU26" "ALD-ALDU27" "ALD-ALDU28"
## [256] "ALD-ALDU29" "ALD-ALDU30" "CRO-CRPL01" "CRO-CRPL02" "CRO-CRPL03"
## [261] "CRO-CRPL04" "CRO-CRPL05" "CRO-CRPL06" "CRO-CRPL07" "CRO-CRPL08"
## [266] "CRO-CRPL09" "CRO-CRPL10" "CRO-CRPL11" "CRO-CRPL12" "CRO-CRPL13"
## [271] "CRO-CRPL14" "CRO-CRPL15" "CRO-CRPL16" "CRO-CRPL17" "CRO-CRPL18"
## [276] "CRO-CRPL19" "CRO-CRPL20" "CRO-CRPL21" "CRO-CRPL22" "CRO-CRPL23"
## [281] "CRO-CRPL24" "CRO-CRPL25" "CRO-CRPL26" "CRO-CRPL27" "CRO-CRPL28"
## [286] "CRO-CRPL29" "CRO-CRPL30" "GRC-GRCA01" "GRC-GRCA02" "GRC-GRCA03"
## [291] "GRC-GRCA04" "GRC-GRCA05" "GRC-GRCC01" "GRC-GRCC02" "GRC-GRCC03"
## [296] "GRC-GRCC04" "GRC-GRCC05" "GRC-GRCC06" "GRC-GRCC08" "GRC-GRCC09"
## [301] "GRC-GRCC10" "GRC-GRCC11" "GRC-GRCC12" "GRC-GRCC13" "GRC-GRCC14"
## [306] "GRC-GRCC15" "GRC-GRCC16" "GRC-GRCC17" "GRC-GRCC18" "GRC-GRCC19"
## [311] "GRC-GRCC20" "GRC-GRCC21" "GRC-GRCC22" "GRC-GRCC23" "GRC-GRCC24"
## [316] "GRC-GRCC25" "GRA-GRAA01" "GRA-GRAA02" "GRA-GRAA03" "GRA-GRAA04"
## [321] "GRA-GRAA05" "GRA-GRAA06" "GRA-GRAA07" "GRA-GRAA08" "GRA-GRAE01"
## [326] "GRA-GRAE02" "GRA-GRAE03" "GRA-GRAE04" "GRA-GRAE05" "GRA-GRAE06"
## [331] "GRA-GRAE07" "GRA-GRAE08" "GRA-GRAH01" "GRA-GRAH02" "GRA-GRAH05"
## [336] "GRA-GRAH06" "GRA-GRAH07" "GRA-GRAI01" "GRA-GRAN01" "GRA-GRAN02"
## [341] "GRA-GRAN03" "GRA-GRAN04" "GRA-GRAN05" "GRA-GRAN06" "GRA-GRAN07"
## [346] "GRA-GRAN08" "ITP-ITBR01" "ITP-ITBR02" "ITP-ITBR03" "ITP-ITBR04"
## [351] "ITP-ITBR05" "ITP-ITBR06" "ITP-ITBR07" "ITP-ITBR08" "ITP-ITBR09"
## [356] "ITP-ITBR10" "ITP-ITBR11" "ITP-ITBR12" "ITP-ITBR13" "ITP-ITBR14"
## [361] "ITP-ITBR15" "ITP-ITBR16" "ITP-ITBR17" "ITP-ITBR18" "ITP-ITBR19"
## [366] "ITP-ITBR20" "ITP-ITBR21" "ITP-ITVL01" "ITP-ITVL02" "ITP-ITVL03"
## [371] "ITP-ITVL04" "ITP-ITVL05" "ITP-ITVL06" "ITP-ITVL07" "ITP-ITVL08"
## [376] "ITP-ITVL09" "ITR-ITRM01" "ITR-ITRM02" "ITR-ITRM03" "ITR-ITRM04"
## [381] "ITR-ITRM05" "ITR-ITRM06" "ITR-ITRM07" "ITR-ITRM08" "ITR-ITRM09"
## [386] "ITR-ITRM10" "ITR-ITRM11" "ITR-ITRM12" "ITR-ITRM13" "ITR-ITRO01"
## [391] "ITR-ITRO02" "ITR-ITRO03" "ITR-ITRO04" "ITR-ITRO05" "ITR-ITRO06"
## [396] "ITR-ITRO07" "ITR-ITRO08" "ITR-ITRO09" "ITR-ITRO10" "ITR-ITRO11"
## [401] "ITR-ITRO12" "ITR-ITRO13" "ITR-ITRO14" "ITR-ITRO15" "ITR-ITRO16"
## [406] "ITR-ITRO17" "ITB-ITBL01" "ITB-ITBL02" "ITB-ITBL03" "ITB-ITBL04"
## [411] "ITB-ITBL05" "ITB-ITBL06" "ITB-ITBL07" "ITB-ITBL08" "ITB-ITBL09"
## [416] "ITB-ITBL10" "ITB-ITBL11" "ITB-ITBL12" "ITB-ITBL13" "ITB-ITBL14"
## [421] "ITB-ITBL15" "ITB-ITBO01" "ITB-ITBO02" "ITB-ITBO03" "ITB-ITBO04"
## [426] "ITB-ITBO05" "ITB-ITBO06" "ITB-ITBO07" "ITB-ITBO08" "ITB-ITBO09"
## [431] "ITB-ITBO10" "ITB-ITBO11" "ITB-ITBO12" "ITB-ITBO13" "ITB-ITBO14"
## [436] "ITB-ITBO15" "MAL-MTLU01" "MAL-MTLU02" "MAL-MTLU03" "MAL-MTLU04"
## [441] "MAL-MTLU05" "MAL-MTLU06" "MAL-MTLU07" "MAL-MTLU08" "MAL-MTLU09"
## [446] "MAL-MTLU10" "MAL-MTLU11" "MAL-MTLU12" "MAL-MTLU13" "MAL-MTLU14"
## [451] "MAL-MTLU15" "MAL-MTLU16" "MAL-MTLU17" "MAL-MTLU18" "MAL-MTLU19"
## [456] "MAL-MTLU20" "MAL-MTLU31" "MAL-MTLU32" "MAL-MTLU33" "MAL-MTLU34"
## [461] "MAL-MTLU35" "MAL-MTLU36" "MAL-MTLU37" "MAL-MTLU38" "MAL-MTLU39"
## [466] "SLO-SLGO01" "SLO-SLGO02" "SLO-SLGO03" "SLO-SLGO04" "SLO-SLGO05"
## [471] "SLO-SLGO06" "SLO-SLGO07" "SLO-SLGO08" "SLO-SLGO09" "SLO-SLGO10"
## [476] "SLO-SLGO11" "SLO-SLGO12" "SLO-SLGO13" "SLO-SLGO14" "SLO-SLGO15"
## [481] "SLO-SLGO25" "SLO-SLGO26" "SLO-SLGO27" "SLO-SLGO28" "SLO-SLGO29"
## [486] "SLO-SLGO30" "SLO-SLGO31" "SLO-SLGO32" "SLO-SLGO33" "SLO-SLGO34"
## [491] "SLO-SLGO35" "SLO-SLGO36" "SLO-SLGO37" "SLO-SLGO38" "SLO-SLGO39"
## [496] "SPS-ESUP01" "SPS-ESUP02" "SPS-ESUP03" "SPS-ESUP04" "SPS-ESUP05"
## [501] "SPS-ESUP06" "SPS-ESUP07" "SPS-ESUP08" "SPS-ESUP09" "SPS-ESUP10"
## [506] "SPC-ESVL01" "SPC-ESVL02" "SPC-ESVL03" "SPC-ESVL04" "SPC-ESVL05"
## [511] "SPC-ESVL06" "SPC-ESVL07" "SPC-ESVL08" "SPC-ESVL09" "SPC-ESVL10"
## [516] "SPC-ESVL11" "SPC-ESVL12" "SPC-ESVL13" "SPC-ESVL14" "SPC-ESVL15"
## [521] "SPC-ESVL16" "SPC-ESVL17" "SPC-ESVL18" "SPC-ESVL19" "SPC-ESVL20"
## [526] "SPM-ESMG01" "SPM-ESMG02" "SPM-ESMG03" "SPM-ESMG04" "SPM-ESMG05"
## [531] "SPM-ESMG06" "SPM-ESMG07" "SPM-ESMG08" "SPM-ESMG09" "SPM-ESMG10"
## [536] "SPM-ESMG11" "SPM-ESMG12" "SPM-ESMG13" "SPM-ESMG14" "SPM-ESMG15"
## [541] "SPM-ESMG16" "SPM-ESMG17" "SPM-ESMG18" "SPM-ESMG19" "FRS-FRMH01"
## [546] "FRS-FRMH02" "FRS-FRMH03" "FRS-FRMH04" "FRS-FRMH05" "FRS-FRMH06"
## [551] "FRS-FRMH07" "FRS-FRMH08" "FRS-FRMH09" "FRS-FRMH10" "FRS-FRMH11"
## [556] "FRS-FRMH12" "FRS-FRMH13" "FRS-FRMH14" "FRS-FRMH15" "FRS-FRMH16"
## [561] "FRS-FRMH17" "FRS-FRMH18" "FRS-FRMH19" "FRS-FRMH20" "FRS-FRMH36"
## [566] "FRS-FRMH37" "FRS-FRMH38" "FRS-FRMH39" "FRS-FRMH40" "FRS-FRMH41"
## [571] "FRS-FRMH42" "FRS-FRMH43" "FRS-FRMH44" "FRS-FRMH45" "STS-FRST01"
## [576] "STS-FRST02" "STS-FRST03" "STS-FRST04" "STS-FRST05" "STS-FRST06"
## [581] "STS-FRST07" "STS-FRST08" "STS-FRST09" "STS-FRST10" "STS-FRST11"
## [586] "STS-FRST12" "STS-FRST13" "STS-FRST14" "STS-FRST15" "STS-FRST16"
## [591] "STS-FRST17" "STS-FRST18" "STS-FRST19" "STS-FRST20" "STS-FRST21"
## [596] "STS-FRST22" "STS-FRST23" "STS-FRST24" "STS-FRST25" "STS-FRST26"
## [601] "STS-FRST27" "STS-FRST28" "STS-FRST29" "STS-FRST30" "GES-ABSU01"
## [606] "GES-ABSU02" "GES-ABSU03" "GES-ABSU04" "GES-ABSU05" "BAR-ESBA01"
## [611] "BAR-ESBA02" "BAR-ESBA03" "BAR-ESBA04" "BAR-ESBA05" "BAR-ESBA06"
## [616] "BAR-ESBA07" "BAR-ESBA08" "BAR-ESBA09" "BAR-ESBA10" "BAR-ESBA11"
## [621] "BAR-ESBA12" "BAR-ESBA13" "BAR-ESBA14" "BAR-ESBA15" "BAR-ESBA16"
## [626] "BAR-ESBA17" "BAR-ESBA18" "BAR-ESBA19" "BAR-ESBA20" "BAR-ESBA21"
## [631] "BAR-ESBA22" "BAR-ESBA23" "BAR-ESBA24" "BAR-ESBA25" "BAR-ESBA26"
## [636] "BAR-ESBA27" "BAR-ESBA28"

Save it as rds

saveRDS(
  europe_over, here(
    "output/europe/dapc/microsats/overlap/microsats_europe_overlap.rds"
  )
)

To load it

europe_over <- readRDS(
  here(
    "output/europe/dapc/microsats/overlap/microsats_europe_overlap.rds"
  )
)

5.1. Add countries

strata(europe_over) <- data.frame(pop(europe_over))

# Currently set on just 
head(pop(europe_over)) 
## [1] POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60 POP-PTPN60
## 24 Levels: POP-PTPN60 SPB-ESBD11 BUL-BULO34 ROS-ROSM30 ... BAR-ESBA28
#pops <- as.data.frame(pop(europe_all))
#write.csv(pops, here("DAPC/pops.csv"))

5.2. Get Sample Locations

Import sample data Load the csv

sampling_loc <- read.csv(here("output/europe/dapc/microsats/overlap/sampling_loc_euro_microsats_overlap.csv"))
sampling_loc <- as.data.frame(sampling_loc)

head(sampling_loc)
##               Pop_City  Country Latitude Longitude Continent Abbreviation Year
## 1 Saint-Martin-d'Heres   France 45.18230  5.774900    Europe          FRS 2019
## 2           Strasbourg   France 48.59772  7.749702    Europe          STS 2019
## 3             Penafiel Portugal 41.18555 -8.329371    Europe          POP 2017
## 4                Loule Portugal 37.09084 -8.092465    Europe          POL 2017
## 5              Badajoz    Spain 38.86622 -6.974194    Europe          SPB 2018
## 6            San Roque    Spain 36.30058 -5.269380    Europe          SPS 2017
##        Region_old   Subregion order order2 orderold order_microsat microsats
## 1  Western Europe West Europe     9      1        1              1       yes
## 2  Western Europe West Europe    10      2        2              2       yes
## 3 Southern Europe West Europe    11      3        3              3       yes
## 4 Southern Europe West Europe    12      4        4              4       yes
## 5 Southern Europe West Europe    13      5        5              6       yes
## 6 Southern Europe West Europe    14      6        6             10       yes
##   microsat_code alt_code  X Country.1          Region   mean_fst SNP_data
## 1           FRS     FRMH NA    France  Western Europe 0.13952119      Yes
## 2           STS     FRST NA    France  Western Europe 0.09768391      Yes
## 3           POP     PTPN NA  Portugal Southern Europe 0.13113621      Yes
## 4           POL     PTQT NA  Portugal Southern Europe 0.30865389      Yes
## 5           SPB     ESBD NA     Spain Southern Europe 0.14455414      Yes
## 6           SPS     ESUP NA     Spain Southern Europe 0.16472052      Yes

Save it as rds

saveRDS(
  sampling_loc, here(
    "output/europe/dapc/microsats/overlap/sampling_loc_euro_microsats_overlap.rds"
  )
)

To load it

sampling_loc <- readRDS(here("output/europe/dapc/microsats/overlap/sampling_loc_euro_microsats_overlap.rds"))
head(sampling_loc)
##               Pop_City  Country Latitude Longitude Continent Abbreviation Year
## 1 Saint-Martin-d'Heres   France 45.18230  5.774900    Europe          FRS 2019
## 2           Strasbourg   France 48.59772  7.749702    Europe          STS 2019
## 3             Penafiel Portugal 41.18555 -8.329371    Europe          POP 2017
## 4                Loule Portugal 37.09084 -8.092465    Europe          POL 2017
## 5              Badajoz    Spain 38.86622 -6.974194    Europe          SPB 2018
## 6            San Roque    Spain 36.30058 -5.269380    Europe          SPS 2017
##        Region_old   Subregion order order2 orderold order_microsat microsats
## 1  Western Europe West Europe     9      1        1              1       yes
## 2  Western Europe West Europe    10      2        2              2       yes
## 3 Southern Europe West Europe    11      3        3              3       yes
## 4 Southern Europe West Europe    12      4        4              4       yes
## 5 Southern Europe West Europe    13      5        5              6       yes
## 6 Southern Europe West Europe    14      6        6             10       yes
##   microsat_code alt_code  X Country.1          Region   mean_fst SNP_data
## 1           FRS     FRMH NA    France  Western Europe 0.13952119      Yes
## 2           STS     FRST NA    France  Western Europe 0.09768391      Yes
## 3           POP     PTPN NA  Portugal Southern Europe 0.13113621      Yes
## 4           POL     PTQT NA  Portugal Southern Europe 0.30865389      Yes
## 5           SPB     ESBD NA     Spain Southern Europe 0.14455414      Yes
## 6           SPS     ESUP NA     Spain Southern Europe 0.16472052      Yes

Load the csv

countr <- read.csv(here("output/europe/dapc/microsats/overlap/DAPC_countries_microsats_overlap.csv"
))
df <- as.data.frame(countr)

head(df)
##   pop  country
## 1 POP Portugal
## 2 POP Portugal
## 3 POP Portugal
## 4 POP Portugal
## 5 POP Portugal
## 6 POP Portugal
europe_over@pop <- as.factor(df$country)
europe_over$pop
##   [1] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##   [9] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [17] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [25] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [33] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [41] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [49] Portugal Portugal Portugal Portugal Portugal Portugal Portugal Portugal
##  [57] Portugal Portugal Portugal Portugal Spain    Spain    Spain    Spain   
##  [65] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [73] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [81] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [89] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [97] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [105] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [113] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [121] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [129] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [137] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [145] Spain    Spain    Spain    Spain    France   France   France   France  
## [153] France   France   France   France   France   France   France   France  
## [161] France   France   France   France   France   France   France   France  
## [169] France   France   France   France   France   France   France   France  
## [177] France   France   France   France   France   France   France   France  
## [185] France   France   France   France   France   France   France   France  
## [193] France   France   France   France   France   France   France   France  
## [201] France   France   France   France   France   France   France   France  
## [209] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [217] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [225] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [233] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [241] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [249] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [257] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [265] Italy    Italy    Italy    Italy    Slovenia Slovenia Slovenia Slovenia
## [273] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [281] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [289] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [297] Slovenia Slovenia Malta    Malta    Malta    Malta    Malta    Malta   
## [305] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
## [313] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
## [321] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Italy   
## [329] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [337] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [345] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [353] Italy    Italy    Italy    Italy    Italy    Croatia  Croatia  Croatia 
## [361] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
## [369] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
## [377] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
## [385] Croatia  Croatia  Croatia  Albania  Albania  Albania  Albania  Albania 
## [393] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
## [401] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
## [409] Albania  Albania  Albania  Albania  Albania  Albania  Albania  Albania 
## [417] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
## [425] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
## [433] Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia   Serbia  
## [441] Serbia   Serbia   Serbia   Serbia   Serbia   Romania  Romania  Romania 
## [449] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [457] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [465] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [473] Romania  Romania  Romania  Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [481] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [489] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [497] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria
## [505] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [513] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [521] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [529] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [537] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [545] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [553] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
## [561] Greece   Greece   Greece   Turkey   Turkey   Turkey   Turkey   Turkey  
## [569] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [577] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [585] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [593] Turkey   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
## [601] Russia   Russia   Russia   Georgia  Georgia  Georgia  Georgia  Georgia 
## [609] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [617] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [625] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [633] Turkey   Turkey   Turkey   Turkey   Turkey  
## 15 Levels: Albania Bulgaria Croatia France Georgia Greece Italy ... Turkey

Save the genind object

saveRDS(europe_over, here("output/europe/dapc/microsats/overlap/microsat_country.rds"
))

Load the genind object

microsat_country <- readRDS(here("output/europe/dapc/microsats/overlap/microsat_country.rds"
))

5.3. Scale

microsat_country <- scaleGen(europe_over, NA.method="mean")
class(microsat_country)
## [1] "matrix" "array"
dim(microsat_country)
## [1] 637 163
microsat_country[1:5,1:5]
##              MIC2.180   MIC2.183    MIC2.186  MIC2.181  MIC2.184
## POP-PTPN01  5.4187592  6.2295646 -0.06927959 -1.057301 -1.475692
## POP-PTPN02  5.4187592  6.2295646 -0.06927959 -1.057301 -1.475692
## POP-PTPN03  5.4187592  6.2295646 -0.06927959 -1.057301 -1.475692
## POP-PTPN04 -0.1317364 12.5797014 -0.06927959 -1.057301 -1.475692
## POP-PTPN05 10.9692548 -0.1205722 -0.06927959 -1.057301 -1.475692
# Get the populations from the genlight object
populations <- europe_over$pop

5.4. Find clusters

grp <- find.clusters(microsat_country, max.n.clust=20)
#retained 150
#Choose the number of clusters (>=2): 7

Save the genind object

saveRDS(grp, here("output/europe/dapc/microsats/overlap/grp_7.rds"
))

Load the genind object

grp <- readRDS(here("output/europe/dapc/microsats/overlap/grp_7.rds"))
names(grp)
## [1] "Kstat" "stat"  "grp"   "size"
grp$size #group sizes for our clusters
## [1]   1 257  34  80 178   7  80
table(pop(europe_over), grp$grp)
##           
##             1  2  3  4  5  6  7
##   Albania   0 20  0  0  4  0  5
##   Bulgaria  0 18  0  0  4  0  7
##   Croatia   0 13  0 17  0  0  0
##   France    0  3  0 14 24  0 19
##   Georgia   0  5  0  0  0  0  0
##   Greece    0  8 16 14 20  0  1
##   Italy     0 47  0 24 11  0  8
##   Malta     0 28  0  0  0  0  1
##   Portugal  0  1  2  0 54  3  0
##   Romania   0 17  0  0  5  0  8
##   Russia    0  5  0  0  3  0  2
##   Serbia    0 18  0  0  3  0  8
##   Slovenia  0 28  0  0  1  0  1
##   Spain     0 32  6  0 34  0 16
##   Turkey    1 14 10 11 15  4  4

5.5. Run dapc

dapc1 <- dapc(microsat_country, grp$grp)
#150 PCs retained
#8 discriminant functions retained

Save the genind object

saveRDS(dapc1, here("output/europe/dapc/microsats/overlap/dapc1.rds"
))

Load the genind object

dapc1 <- readRDS(here("output/europe/dapc/microsats/overlap/dapc1.rds"
))
dapc1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1)
## 
## $n.pca: 150 first PCs of PCA used
## $n.da: 6 discriminant functions saved
## $var (proportion of conserved variance): 1
## 
## $eig (eigenvalues): 11240000 2627 1750 510.6 318.2 ...
## 
##   vector    length content                   
## 1 $eig      6      eigenvalues               
## 2 $grp      637    prior group assignment    
## 3 $prior    7      prior group probabilities 
## 4 $assign   637    posterior group assignment
## 5 $pca.cent 163    centring vector of PCA    
## 6 $pca.norm 163    scaling vector of PCA     
## 7 $pca.eig  150    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          637  150  retained PCs of PCA                              
## 2 $means        7    150  group means                                      
## 3 $loadings     150  6    loadings of variables                            
## 4 $ind.coord    637  6    coordinates of individuals (principal components)
## 5 $grp.coord    7    6    coordinates of groups                            
## 6 $posterior    637  7    posterior membership probabilities               
## 7 $pca.loadings 163  150  PCA loadings of original variables               
## 8 $var.contr    163  6    contribution of original variables

5.6. Calculating the optimum PC number to rerun DAPC

optim.a.score(dapc1, n.pca=1:ncol(dapc1$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10) #calculating optimal number of PCs
#Optimal number = 24

5.7. Now do cross-validation

Cross-validation: The Discriminant Analysis of Principal Components (DAPC) relies on dimension reduction of the data using PCA followed by a linear discriminant analysis. How many PCA axes to retain is often a non-trivial question. Cross validation provides an objective way to decide how many axes to retain: different numbers are tried and the quality of the corresponding DAPC is assessed by cross- validation: DAPC is performed on a training set, typically made of 90% of the observations (comprising 90% of the observations in each subpopulation) , and then used to predict the groups of the 10% of remaining observations. The current method uses the average prediction success per group (result=“groupMean”), or the overall prediction success (result=“overall”). The number of PCs associated with the lowest Mean Squared Error is then retained in the DAPC.

xvalDapc(microsat_country, populations, n.pca.max = 200, n.da = NULL,
              training.set = 0.9, result = c("groupMean", "overall"),
              center = TRUE, scale = FALSE,
              n.pca=NULL, n.rep = 30, xval.plot = TRUE) 

## $`Cross-Validation Results`
##     n.pca   success
## 1      20 0.3703704
## 2      20 0.2537037
## 3      20 0.3277778
## 4      20 0.3574074
## 5      20 0.3592593
## 6      20 0.3888889
## 7      20 0.3351852
## 8      20 0.4222222
## 9      20 0.2981481
## 10     20 0.3240741
## 11     20 0.2666667
## 12     20 0.3018519
## 13     20 0.3351852
## 14     20 0.2888889
## 15     20 0.4111111
## 16     20 0.3648148
## 17     20 0.3814815
## 18     20 0.3481481
## 19     20 0.3962963
## 20     20 0.3777778
## 21     20 0.3185185
## 22     20 0.3407407
## 23     20 0.3685185
## 24     20 0.4666667
## 25     20 0.3185185
## 26     20 0.3111111
## 27     20 0.4018519
## 28     20 0.3240741
## 29     20 0.3740741
## 30     20 0.3703704
## 31     40 0.4388889
## 32     40 0.4888889
## 33     40 0.3944444
## 34     40 0.3722222
## 35     40 0.5092593
## 36     40 0.4000000
## 37     40 0.3851852
## 38     40 0.4222222
## 39     40 0.4018519
## 40     40 0.4129630
## 41     40 0.4444444
## 42     40 0.4592593
## 43     40 0.3870370
## 44     40 0.3388889
## 45     40 0.4388889
## 46     40 0.2925926
## 47     40 0.3888889
## 48     40 0.3537037
## 49     40 0.3907407
## 50     40 0.4314815
## 51     40 0.3296296
## 52     40 0.4648148
## 53     40 0.3833333
## 54     40 0.4481481
## 55     40 0.4055556
## 56     40 0.3574074
## 57     40 0.4129630
## 58     40 0.3962963
## 59     40 0.4370370
## 60     40 0.3759259
## 61     60 0.4055556
## 62     60 0.4129630
## 63     60 0.5037037
## 64     60 0.3851852
## 65     60 0.4759259
## 66     60 0.5185185
## 67     60 0.4314815
## 68     60 0.4166667
## 69     60 0.4203704
## 70     60 0.3962963
## 71     60 0.4314815
## 72     60 0.4370370
## 73     60 0.4962963
## 74     60 0.4185185
## 75     60 0.4870370
## 76     60 0.4574074
## 77     60 0.4703704
## 78     60 0.4203704
## 79     60 0.4388889
## 80     60 0.4333333
## 81     60 0.3981481
## 82     60 0.3981481
## 83     60 0.5666667
## 84     60 0.4666667
## 85     60 0.4518519
## 86     60 0.4314815
## 87     60 0.3703704
## 88     60 0.4129630
## 89     60 0.4129630
## 90     60 0.4833333
## 91     80 0.3851852
## 92     80 0.5592593
## 93     80 0.5018519
## 94     80 0.4648148
## 95     80 0.4981481
## 96     80 0.3944444
## 97     80 0.4981481
## 98     80 0.3629630
## 99     80 0.3962963
## 100    80 0.4240741
## 101    80 0.4296296
## 102    80 0.4148148
## 103    80 0.3611111
## 104    80 0.3370370
## 105    80 0.4240741
## 106    80 0.3462963
## 107    80 0.3777778
## 108    80 0.4592593
## 109    80 0.4185185
## 110    80 0.3648148
## 111    80 0.3611111
## 112    80 0.3851852
## 113    80 0.3648148
## 114    80 0.4148148
## 115    80 0.4370370
## 116    80 0.3500000
## 117    80 0.4851852
## 118    80 0.4055556
## 119    80 0.5296296
## 120    80 0.3962963
## 121   100 0.5092593
## 122   100 0.5129630
## 123   100 0.4796296
## 124   100 0.4407407
## 125   100 0.3462963
## 126   100 0.4592593
## 127   100 0.5314815
## 128   100 0.4222222
## 129   100 0.4462963
## 130   100 0.4074074
## 131   100 0.3611111
## 132   100 0.4759259
## 133   100 0.4129630
## 134   100 0.3648148
## 135   100 0.4481481
## 136   100 0.3574074
## 137   100 0.5111111
## 138   100 0.5518519
## 139   100 0.5166667
## 140   100 0.4296296
## 141   100 0.4425926
## 142   100 0.3425926
## 143   100 0.4481481
## 144   100 0.3666667
## 145   100 0.4037037
## 146   100 0.3555556
## 147   100 0.5222222
## 148   100 0.3981481
## 149   100 0.4203704
## 150   100 0.4444444
## 151   120 0.4240741
## 152   120 0.4185185
## 153   120 0.4777778
## 154   120 0.5296296
## 155   120 0.4518519
## 156   120 0.4870370
## 157   120 0.3962963
## 158   120 0.3888889
## 159   120 0.3796296
## 160   120 0.3925926
## 161   120 0.5037037
## 162   120 0.4462963
## 163   120 0.4537037
## 164   120 0.4370370
## 165   120 0.3518519
## 166   120 0.3796296
## 167   120 0.4851852
## 168   120 0.4277778
## 169   120 0.4166667
## 170   120 0.5222222
## 171   120 0.4222222
## 172   120 0.4592593
## 173   120 0.3833333
## 174   120 0.4074074
## 175   120 0.4777778
## 176   120 0.4259259
## 177   120 0.4277778
## 178   120 0.4018519
## 179   120 0.3148148
## 180   120 0.5703704
## 181   140 0.3648148
## 182   140 0.4944444
## 183   140 0.4814815
## 184   140 0.4740741
## 185   140 0.4518519
## 186   140 0.3555556
## 187   140 0.4166667
## 188   140 0.4240741
## 189   140 0.4222222
## 190   140 0.4462963
## 191   140 0.4074074
## 192   140 0.4259259
## 193   140 0.4222222
## 194   140 0.4722222
## 195   140 0.4314815
## 196   140 0.3888889
## 197   140 0.4240741
## 198   140 0.4333333
## 199   140 0.4444444
## 200   140 0.4537037
## 201   140 0.3537037
## 202   140 0.3203704
## 203   140 0.4000000
## 204   140 0.4055556
## 205   140 0.4296296
## 206   140 0.3722222
## 207   140 0.4611111
## 208   140 0.3574074
## 209   140 0.3777778
## 210   140 0.4407407
## 
## $`Median and Confidence Interval for Random Chance`
##       2.5%        50%      97.5% 
## 0.05133884 0.06798331 0.08551598 
## 
## $`Mean Successful Assignment by Number of PCs of PCA`
##        20        40        60        80       100       120       140 
## 0.3501235 0.4054321 0.4416667 0.4182716 0.4376543 0.4353704 0.4184568 
## 
## $`Number of PCs Achieving Highest Mean Success`
## [1] "60"
## 
## $`Root Mean Squared Error by Number of PCs of PCA`
##        20        40        60        80       100       120       140 
## 0.6515056 0.5963498 0.5599878 0.5845349 0.5655112 0.5672319 0.5830371 
## 
## $`Number of PCs Achieving Lowest MSE`
## [1] "60"
## 
## $DAPC
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1, n.pca = ..2, 
##     n.da = ..3)
## 
## $n.pca: 60 first PCs of PCA used
## $n.da: 14 discriminant functions saved
## $var (proportion of conserved variance): 0.644
## 
## $eig (eigenvalues): 106.8 46.37 37.9 29.47 25.46 ...
## 
##   vector    length content                   
## 1 $eig      14     eigenvalues               
## 2 $grp      637    prior group assignment    
## 3 $prior    15     prior group probabilities 
## 4 $assign   637    posterior group assignment
## 5 $pca.cent 163    centring vector of PCA    
## 6 $pca.norm 163    scaling vector of PCA     
## 7 $pca.eig  150    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          637  60   retained PCs of PCA                              
## 2 $means        15   60   group means                                      
## 3 $loadings     60   14   loadings of variables                            
## 4 $ind.coord    637  14   coordinates of individuals (principal components)
## 5 $grp.coord    15   14   coordinates of groups                            
## 6 $posterior    637  15   posterior membership probabilities               
## 7 $pca.loadings 163  60   PCA loadings of original variables               
## 8 $var.contr    163  14   contribution of original variables

$n.pca: 100 first PCs of PCA used $n.da: 14 discriminant functions saved $var (proportion of conserved variance): 0.863

Run DAPC with object using x-val recommendations

dapc_micro_1 <- dapc(microsat_country, n.pca = 100, n.da = 14, grp = populations)
dapc_micro_1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..3, n.pca = 100, 
##     n.da = 14)
## 
## $n.pca: 100 first PCs of PCA used
## $n.da: 14 discriminant functions saved
## $var (proportion of conserved variance): 0.863
## 
## $eig (eigenvalues): 129 63.98 48.15 41.99 36.22 ...
## 
##   vector    length content                   
## 1 $eig      14     eigenvalues               
## 2 $grp      637    prior group assignment    
## 3 $prior    15     prior group probabilities 
## 4 $assign   637    posterior group assignment
## 5 $pca.cent 163    centring vector of PCA    
## 6 $pca.norm 163    scaling vector of PCA     
## 7 $pca.eig  150    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          637  100  retained PCs of PCA                              
## 2 $means        15   100  group means                                      
## 3 $loadings     100  14   loadings of variables                            
## 4 $ind.coord    637  14   coordinates of individuals (principal components)
## 5 $grp.coord    15   14   coordinates of groups                            
## 6 $posterior    637  15   posterior membership probabilities               
## 7 $pca.loadings 163  100  PCA loadings of original variables               
## 8 $var.contr    163  14   contribution of original variables

dapc with optimal # of PCs recommended

dapc_micro_2 <- dapc(microsat_country, n.pca = 24, n.da = 8, grp = populations)
dapc_micro_2
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..3, n.pca = 24, 
##     n.da = 8)
## 
## $n.pca: 24 first PCs of PCA used
## $n.da: 8 discriminant functions saved
## $var (proportion of conserved variance): 0.336
## 
## $eig (eigenvalues): 81.32 32.56 19.86 17.27 16.26 ...
## 
##   vector    length content                   
## 1 $eig      14     eigenvalues               
## 2 $grp      637    prior group assignment    
## 3 $prior    15     prior group probabilities 
## 4 $assign   637    posterior group assignment
## 5 $pca.cent 163    centring vector of PCA    
## 6 $pca.norm 163    scaling vector of PCA     
## 7 $pca.eig  150    eigenvalues of PCA        
## 
##   data.frame    nrow ncol content                                          
## 1 $tab          637  24   retained PCs of PCA                              
## 2 $means        15   24   group means                                      
## 3 $loadings     24   8    loadings of variables                            
## 4 $ind.coord    637  8    coordinates of individuals (principal components)
## 5 $grp.coord    15   8    coordinates of groups                            
## 6 $posterior    637  15   posterior membership probabilities               
## 7 $pca.loadings 163  24   PCA loadings of original variables               
## 8 $var.contr    163  8    contribution of original variables

only 34% of variance retained with this one

Most contributing alleles

set.seed(4) 
contrib<-loadingplot(dapc_micro_1$var.contr,axis=2, thres=.0002,lab.jitter=3)

set.seed(4) 
contrib<-loadingplot(dapc_micro_2$var.contr,axis=2, thres=.0002,lab.jitter=3)

5.8. Plots

scatter(dapc_micro_1)

scatter(dapc_micro_2)

Check R symbols for plot

#to see all shapes -> plot shapes - para escolher os simbolos
N = 100; M = 1000
good.shapes = c(1:25,35:38,43,60,62:64)
foo = data.frame( x = rnorm(M), y = rnorm(M), s = factor( sample(1:N, M, replace = TRUE) ) )
ggplot(aes(x,y,shape=s ), data=foo ) +
  scale_shape_manual(values=good.shapes[1:N]) +
  geom_point()
## Warning: Removed 690 rows containing missing values or values outside the scale range
## (`geom_point()`).

#1:25,28:31,36,55:57
myCol2 <- c("#51f310", "#146c45", "#75d5e1", "#FF7F00", "magenta", "red",  "yellow3", "#52ef99", "#2524f9",  "#1E90FF", "purple", "#fda547", "#cf749b", "#332288", "#a41415")  

Plot using different discriminant functions

1 & 2

pdf(file = "output/europe/dapc/microsats/overlap/dapc_micro_overlap_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

1 & 3

pdf(file = "output/europe/dapc/microsats/overlap/dapc_micro_overlap_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/microsats/overlap/dapc_micro_overlap_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

2 & 3

pdf(file = "output/europe/dapc/microsats/overlap/dapc_micro_overlap_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

2 & 4

pdf(file = "output/europe/dapc/microsats/overlap/dapc_micro_overlap_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=4)

3 & 4

pdf(file = "output/europe/dapc/microsats/overlap/dapc_micro_overlap_PC3_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =3, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_micro_1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomleft", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =3, yax=4)

6. DAPC for SNP Set 3 with the 24 populations overlapping with the microsatelli

6.1. Import the data and covert it to genind format

# import the data
albo <-
  read.PLINK(
    here("/gpfs/gibbs/pi/caccone/mkc54/albo/europe/output/fst/overlap/overlap.raw"),
    quiet = FALSE,
    chunkSize = 1000,
    parallel = require("parallel"),
    n.cores = 4
  )
## 
##  Reading PLINK raw format into a genlight object...
## Loading required package: parallel
## 
##  Reading loci information... 
## 
##  Reading and converting genotypes... 
## .
##  Building final object... 
## 
## ...done.
# convert to genind
albo1 <- gl2gi(albo, probar = TRUE, verbose = NULL)
## Starting gl2gi 
##   Processing genlight object with SNP data
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================| 100%
## Matrix converted.. Prepare genind object...
## Completed: gl2gi

Import the data and covert it to genind format

# import the data
snp <-
  read.PLINK(
    here("/gpfs/gibbs/pi/caccone/mkc54/albo/europe/output/fst/overlap/overlap.raw"),
    quiet = FALSE,
    chunkSize = 1000,
    parallel = require("parallel"),
    n.cores = 4
  )
## 
##  Reading PLINK raw format into a genlight object... 
## 
## 
##  Reading loci information... 
## 
##  Reading and converting genotypes... 
## .
##  Building final object... 
## 
## ...done.
nInd(snp)
## [1] 242
nLoc(snp)
## [1] 20968
nPop(snp)
## [1] 24
indNames(snp)
##   [1] "1065" "1066" "1067" "1068" "1069" "1070" "1071" "1072" "1073" "1074"
##  [11] "1075" "1076" "1109" "1110" "1111" "1112" "1113" "1114" "1115" "1116"
##  [21] "1117" "1118" "1119" "1120" "1218" "1219" "1220" "1221" "1222" "1223"
##  [31] "1224" "1225" "1426" "1427" "1428" "1429" "201"  "202"  "203"  "204" 
##  [41] "2202" "279"  "280"  "281"  "282"  "283"  "284"  "285"  "286"  "287" 
##  [51] "289"  "290"  "291"  "701"  "702"  "703"  "704"  "705"  "706"  "707" 
##  [61] "708"  "709"  "710"  "711"  "712"  "713"  "714"  "715"  "716"  "717" 
##  [71] "718"  "719"  "720"  "721"  "722"  "723"  "724"  "725"  "726"  "727" 
##  [81] "728"  "729"  "730"  "731"  "732"  "733"  "735"  "736"  "737"  "741" 
##  [91] "742"  "743"  "744"  "745"  "746"  "747"  "749"  "750"  "751"  "752" 
## [101] "753"  "754"  "755"  "756"  "757"  "758"  "759"  "760"  "761"  "762" 
## [111] "763"  "764"  "765"  "766"  "767"  "769"  "770"  "771"  "772"  "773" 
## [121] "774"  "775"  "776"  "777"  "778"  "781"  "782"  "784"  "785"  "786" 
## [131] "787"  "788"  "789"  "790"  "791"  "792"  "793"  "794"  "795"  "801" 
## [141] "802"  "803"  "804"  "805"  "806"  "807"  "808"  "809"  "810"  "811" 
## [151] "812"  "813"  "814"  "815"  "816"  "817"  "818"  "819"  "820"  "821" 
## [161] "822"  "824"  "825"  "826"  "827"  "830"  "831"  "833"  "834"  "835" 
## [171] "836"  "837"  "838"  "839"  "840"  "841"  "842"  "843"  "844"  "845" 
## [181] "846"  "849"  "850"  "851"  "852"  "853"  "854"  "855"  "856"  "857" 
## [191] "859"  "860"  "861"  "862"  "863"  "864"  "865"  "866"  "867"  "868" 
## [201] "869"  "870"  "871"  "872"  "873"  "874"  "875"  "876"  "877"  "878" 
## [211] "879"  "880"  "881"  "882"  "883"  "884"  "885"  "886"  "887"  "888" 
## [221] "889"  "890"  "891"  "892"  "893"  "894"  "911"  "912"  "913"  "915" 
## [231] "928"  "929"  "930"  "931"  "932"  "933"  "934"  "935"  "936"  "937" 
## [241] "938"  "939"
# convert to genind
snp2 <- gl2gi(snp, probar = TRUE, verbose = NULL)
## Starting gl2gi 
##   Processing genlight object with SNP data
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================| 100%
## Matrix converted.. Prepare genind object...
## Completed: gl2gi

Save it

saveRDS(
  snp2, here(
    "output/europe/dapc/overlap/snp2.rds"
  )
)

To load it

snp2 <- readRDS(
  here(
    "output/europe/dapc/overlap/snp2.rds"
  )
)

6.2. Get Sample Locations

Import sample data

sampling_loc <- readRDS(here("output/europe/dapc/overlap/sampling_loc_overlap.rds"))
head(sampling_loc)
## # A tibble: 6 × 10
##   Pop_City Country Latitude Longitude Continent Abbreviation  Year Region Marker
##   <chr>    <chr>      <dbl>     <dbl> <chr>     <chr>        <dbl> <chr>  <chr> 
## 1 Saint-M… France      45.2     5.77  Europe    FRS           2019 Weste… SNPs  
## 2 Strasbo… France      48.6     7.75  Europe    STS           2019 Weste… SNPs  
## 3 Penafiel Portug…     41.2    -8.33  Europe    POP           2017 South… SNPs  
## 4 Badajoz  Spain       38.9    -6.97  Europe    SPB           2018 South… SNPs  
## 5 San Roq… Spain       36.2    -5.37  Europe    SPS           2017 South… SNPs  
## 6 Catarro… Spain       39.4    -0.396 Europe    SPC           2017 South… SNPs  
## # ℹ 1 more variable: order <dbl>
strata(snp2) <- data.frame(other(snp2))

# Currently set on just 
head(pop(snp2)) 
## [1] SOC SOC SOC SOC SOC SOC
## 24 Levels: ALD BAR BUL CRO FRS GES GRA GRC ITB ITP ITR MAL POP ROS SER ... TUH

Load the csv

countr <- read.csv(here("/gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/dapc/overlap/DAPC_countries_SNP_overlap.csv"
))
countr$country[countr$country == 'country'] <- 'Portugal'

df <- as.data.frame(countr)

head(df)
##   pop country
## 1 SOC  Russia
## 2 SOC  Russia
## 3 SOC  Russia
## 4 SOC  Russia
## 5 SOC  Russia
## 6 SOC  Russia
countr$country[countr$country == 'country'] <- 'Portugal'
snp2@pop <- as.factor(df$country)
snp2$pop
##   [1] Russia   Russia   Russia   Russia   Russia   Russia   Russia   Russia  
##   [9] Russia   Russia   Russia   Russia   Georgia  Georgia  Georgia  Georgia 
##  [17] Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia  Georgia 
##  [25] France   France   France   France   France   France   France   France  
##  [33] France   France   France   France   Italy    Italy    Italy    Italy   
##  [41] Greece   Spain    Spain    Spain    Spain    Spain    Spain    Spain   
##  [49] Spain    Spain    Spain    Spain    Spain    Bulgaria Bulgaria Bulgaria
##  [57] Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Bulgaria Croatia 
##  [65] Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia  Croatia 
##  [73] Croatia  Croatia  Croatia  Greece   Greece   Greece   Greece   Greece  
##  [81] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Greece  
##  [89] Greece   Greece   Greece   Greece   Greece   Greece   Greece   Italy   
##  [97] Italy    Italy    Italy    Italy    Malta    Malta    Malta    Malta   
## [105] Malta    Malta    Malta    Malta    Malta    Malta    Malta    Malta   
## [113] Spain    Spain    Spain    Spain    Spain    Spain    Turkey   Turkey  
## [121] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [129] Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey   Turkey  
## [137] Turkey   Turkey   Turkey   Albania  Albania  Albania  Albania  Albania 
## [145] Albania  Albania  Albania  Albania  Albania  France   France   France  
## [153] France   France   France   France   France   France   France   France  
## [161] France   Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [169] Italy    Portugal Portugal Portugal Portugal Portugal Portugal Portugal
## [177] Portugal Portugal Portugal Portugal Portugal Romania  Romania  Romania 
## [185] Romania  Romania  Romania  Romania  Romania  Romania  Romania  Romania 
## [193] Serbia   Serbia   Serbia   Serbia   Slovenia Slovenia Slovenia Slovenia
## [201] Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia Slovenia
## [209] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [217] Spain    Spain    Spain    Spain    Spain    Spain    Spain    Spain   
## [225] Spain    Spain    Spain    Spain    Spain    Spain    Italy    Italy   
## [233] Italy    Italy    Italy    Italy    Italy    Italy    Italy    Italy   
## [241] Italy    Italy   
## 15 Levels: Albania Bulgaria Croatia France Georgia Greece Italy ... Turkey

Save the genind object

saveRDS(snp2, here("output/europe/dapc/overlap/snp_country_overlap.rds"
))

Load the genind object

snp_country <- readRDS(here("output/europe/dapc/overlap/snp_country_overlap.rds"
))

6.3. Scale and find clusters

Scale

snp_country <- scaleGen(snp2, NA.method="mean")
class(snp_country)
dim(snp_country)
## NULL
snp_country[1:5,1:5]
## /// GENIND OBJECT /////////
## 
##  // 5 individuals; 3 loci; 5 alleles; size: 11.5 Kb
## 
##  // Basic content
##    @tab:  5 x 5 matrix of allele counts
##    @loc.n.all: number of alleles per locus (range: 1-2)
##    @loc.fac: locus factor for the 5 columns of @tab
##    @all.names: list of allele names for each locus
##    @ploidy: ploidy of each individual  (range: 2-2)
##    @type:  codom
##    @call: .local(x = x, i = i, j = j, drop = drop)
## 
##  // Optional content
##    @pop: population of each individual (group size range: 5-5)
##    @strata: a data frame with 4 columns ( sex, phenotype, pat, mat )
##    @other: a list containing: sex  phenotype  pat  mat
# Get the populations from the genlight object
populations <- snp2$pop

6.3.1. Find clusters

grp <- find.clusters(snp_country, max.n.clust=20)
#retained 250
#Choose the number of clusters (>=2): 7

Save the genind object

saveRDS(grp, here("output/europe/dapc/overlap/grp7.rds"
))

Load the genind object

grp <- readRDS(here("output/europe/dapc/overlap/grp7.rds"
))
names(grp)
## [1] "Kstat" "stat"  "grp"   "size"
grp$size #group sizes for our clusters
## [1]   1 257  34  80 178   7  80
table(pop(snp2), grp$grp)
dapc1 <- dapc(snp_country, grp$grp)
#250 PCs retained
#8 discriminant functions retained

Load the genind object

dapc1 <- readRDS(here("output/europe/dapc/overlap/dapc1_b.rds"
))
dapc1
##  #################################################
##  # Discriminant Analysis of Principal Components #
##  #################################################
## class: dapc
## $call: dapc.data.frame(x = as.data.frame(x), grp = ..1)
## 
## $n.pca: 241 first PCs of PCA used
## $n.da: 7 discriminant functions saved
## $var (proportion of conserved variance): 1
## 
## $eig (eigenvalues): 1.9e+35 8.576e+33 3.181e+33 2.564e+33 8.317e+32 ...
## 
##   vector    length content                   
## 1 $eig      7      eigenvalues               
## 2 $grp      242    prior group assignment    
## 3 $prior    7      prior group probabilities 
## 4 $assign   242    posterior group assignment
## 5 $pca.cent 41926  centring vector of PCA    
## 6 $pca.norm 41926  scaling vector of PCA     
## 7 $pca.eig  241    eigenvalues of PCA        
## 
##   data.frame    nrow  ncol content                                          
## 1 $tab          242   241  retained PCs of PCA                              
## 2 $means        7     241  group means                                      
## 3 $loadings     241   7    loadings of variables                            
## 4 $ind.coord    242   7    coordinates of individuals (principal components)
## 5 $grp.coord    7     7    coordinates of groups                            
## 6 $posterior    242   7    posterior membership probabilities               
## 7 $pca.loadings 41926 241  PCA loadings of original variables               
## 8 $var.contr    41926 7    contribution of original variables

Save the genind object

saveRDS(dapc1, here("output/europe/dapc/overlap/dapc1_b.rds"
))

6.3.2. Calculating the optimum PC number to rerun DAPC

optim.a.score(dapc1, n.pca=1:ncol(dapc1$tab), smart=TRUE, n=10, plot=TRUE, n.sim=10) #calculating optimal number of PCs 13

## $pop.score
## $pop.score$`241`
## 1 2 3 4 5 6 7 
## 0 0 0 0 0 0 0 
## 
## $pop.score$`1`
##           1           2           3           4           5           6 
##  0.53846154 -0.01860465  0.00000000  1.00000000  0.94444444  1.00000000 
##           7 
## -0.06396396 
## 
## $pop.score$`20`
##         1         2         3         4         5         6         7 
## 0.8000000 0.7976744 0.8333333 0.7750000 0.8555556 0.8875000 0.1540541 
## 
## $pop.score$`40`
##         1         2         3         4         5         6         7 
## 0.7884615 0.6837209 0.6500000 0.5625000 0.6888889 0.6375000 0.2234234 
## 
## $pop.score$`60`
##         1         2         3         4         5         6         7 
## 0.5230769 0.5441860 0.3916667 0.2500000 0.4722222 0.5291667 0.2261261 
## 
## $pop.score$`80`
##         1         2         3         4         5         6         7 
## 0.4115385 0.4325581 0.3250000 0.0875000 0.3444444 0.3625000 0.2063063 
## 
## $pop.score$`100`
##         1         2         3         4         5         6         7 
## 0.3115385 0.3418605 0.1583333 0.1250000 0.2111111 0.2875000 0.1747748 
## 
## $pop.score$`120`
##         1         2         3         4         5         6         7 
## 0.1961538 0.2604651 0.1166667 0.0875000 0.1388889 0.2041667 0.1261261 
## 
## $pop.score$`140`
##          1          2          3          4          5          6          7 
## 0.16538462 0.18837209 0.08333333 0.02500000 0.15000000 0.12500000 0.08738739 
## 
## $pop.score$`160`
##          1          2          3          4          5          6          7 
## 0.12307692 0.10697674 0.08333333 0.05000000 0.12222222 0.10000000 0.05225225 
## 
## $pop.score$`180`
##          1          2          3          4          5          6          7 
## 0.10384615 0.09069767 0.05833333 0.05000000 0.10000000 0.07500000 0.03603604 
## 
## $pop.score$`200`
##          1          2          3          4          5          6          7 
## 0.06923077 0.06279070 0.09166667 0.02500000 0.07777778 0.06666667 0.02342342 
## 
## $pop.score$`220`
##           1           2           3           4           5           6 
## 0.034615385 0.037209302 0.008333333 0.050000000 0.050000000 0.033333333 
##           7 
## 0.020720721 
## 
## $pop.score$`240`
## 1 2 3 4 5 6 7 
## 0 0 0 0 0 0 0 
## 
## 
## $mean
##        241          1         20         40         60         80        100 
## 0.00000000 0.48576248 0.72901677 0.60492783 0.41949209 0.30997819 0.23001688 
##        120        140        160        180        200        220        240 
## 0.16142390 0.11778249 0.09112307 0.07341617 0.05950800 0.03345887 0.00000000 
## 
## $pred
## $pred$x
##   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
##  [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
##  [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
##  [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
##  [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
##  [91]  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108
## [109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
## [127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
## [145] 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
## [163] 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
## [181] 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
## [199] 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
## [217] 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
## [235] 235 236 237 238 239 240 241
## 
## $pred$y
##   [1]  4.857625e-01  5.032312e-01  5.206244e-01  5.378640e-01  5.548718e-01
##   [6]  5.715696e-01  5.878792e-01  6.037225e-01  6.190214e-01  6.336976e-01
##  [11]  6.476729e-01  6.608693e-01  6.732086e-01  6.846125e-01  6.950029e-01
##  [16]  7.043016e-01  7.124306e-01  7.193115e-01  7.248663e-01  7.290168e-01
##  [21]  7.317108e-01  7.330002e-01  7.329631e-01  7.316775e-01  7.292212e-01
##  [26]  7.256723e-01  7.211088e-01  7.156086e-01  7.092497e-01  7.021101e-01
##  [31]  6.942677e-01  6.858005e-01  6.767865e-01  6.673037e-01  6.574300e-01
##  [36]  6.472434e-01  6.368220e-01  6.262436e-01  6.155862e-01  6.049278e-01
##  [41]  5.943349e-01  5.838279e-01  5.734156e-01  5.631068e-01  5.529106e-01
##  [46]  5.428356e-01  5.328909e-01  5.230852e-01  5.134274e-01  5.039265e-01
##  [51]  4.945912e-01  4.854305e-01  4.764531e-01  4.676681e-01  4.590841e-01
##  [56]  4.507102e-01  4.425552e-01  4.346279e-01  4.269373e-01  4.194921e-01
##  [61]  4.122980e-01  4.053479e-01  3.986310e-01  3.921371e-01  3.858555e-01
##  [66]  3.797758e-01  3.738874e-01  3.681799e-01  3.626429e-01  3.572657e-01
##  [71]  3.520378e-01  3.469489e-01  3.419884e-01  3.371458e-01  3.324106e-01
##  [76]  3.277723e-01  3.232204e-01  3.187444e-01  3.143338e-01  3.099782e-01
##  [81]  3.056684e-01  3.014015e-01  2.971756e-01  2.929892e-01  2.888405e-01
##  [86]  2.847280e-01  2.806500e-01  2.766047e-01  2.725906e-01  2.686060e-01
##  [91]  2.646493e-01  2.607187e-01  2.568126e-01  2.529294e-01  2.490673e-01
##  [96]  2.452248e-01  2.414002e-01  2.375917e-01  2.337979e-01  2.300169e-01
## [101]  2.262480e-01  2.224938e-01  2.187579e-01  2.150437e-01  2.113547e-01
## [106]  2.076945e-01  2.040664e-01  2.004741e-01  1.969209e-01  1.934105e-01
## [111]  1.899462e-01  1.865317e-01  1.831703e-01  1.798657e-01  1.766212e-01
## [116]  1.734404e-01  1.703268e-01  1.672838e-01  1.643150e-01  1.614239e-01
## [121]  1.586130e-01  1.558811e-01  1.532261e-01  1.506459e-01  1.481383e-01
## [126]  1.457011e-01  1.433323e-01  1.410296e-01  1.387910e-01  1.366144e-01
## [131]  1.344975e-01  1.324382e-01  1.304345e-01  1.284841e-01  1.265849e-01
## [136]  1.247348e-01  1.229316e-01  1.211733e-01  1.194576e-01  1.177825e-01
## [141]  1.161459e-01  1.145469e-01  1.129843e-01  1.114574e-01  1.099653e-01
## [146]  1.085069e-01  1.070814e-01  1.056878e-01  1.043253e-01  1.029929e-01
## [151]  1.016897e-01  1.004148e-01  9.916720e-02  9.794607e-02  9.675047e-02
## [156]  9.557946e-02  9.443214e-02  9.330758e-02  9.220486e-02  9.112307e-02
## [161]  9.006140e-02  8.901953e-02  8.799725e-02  8.699435e-02  8.601064e-02
## [166]  8.504589e-02  8.409992e-02  8.317250e-02  8.226344e-02  8.137253e-02
## [171]  8.049956e-02  7.964433e-02  7.880662e-02  7.798624e-02  7.718297e-02
## [176]  7.639662e-02  7.562697e-02  7.487381e-02  7.413695e-02  7.341617e-02
## [181]  7.271095e-02  7.201949e-02  7.133967e-02  7.066937e-02  7.000645e-02
## [186]  6.934882e-02  6.869433e-02  6.804088e-02  6.738635e-02  6.672860e-02
## [191]  6.606552e-02  6.539499e-02  6.471489e-02  6.402309e-02  6.331748e-02
## [196]  6.259594e-02  6.185634e-02  6.109657e-02  6.031449e-02  5.950800e-02
## [201]  5.867478e-02  5.781175e-02  5.691566e-02  5.598323e-02  5.501120e-02
## [206]  5.399631e-02  5.293529e-02  5.182488e-02  5.066181e-02  4.944281e-02
## [211]  4.816463e-02  4.682400e-02  4.541765e-02  4.394232e-02  4.239474e-02
## [216]  4.077165e-02  3.906978e-02  3.728587e-02  3.541665e-02  3.345887e-02
## [221]  3.141291e-02  2.929385e-02  2.712041e-02  2.491131e-02  2.268530e-02
## [226]  2.046109e-02  1.825742e-02  1.609302e-02  1.398661e-02  1.195692e-02
## [231]  1.002267e-02  8.202614e-03  6.515460e-03  4.979942e-03  3.614790e-03
## [236]  2.438730e-03  1.470493e-03  7.288065e-04  2.323993e-04  3.186139e-13
## [241] -2.988284e-13
## 
## 
## $best
## [1] 22
#Optimal number = 22

6.3.3. Now do cross-validation

Cross-validation: The Discriminant Analysis of Principal Components (DAPC) relies on dimension reduction of the data using PCA followed by a linear discriminant analysis. How many PCA axes to retain is often a non-trivial question. Cross validation provides an objective way to decide how many axes to retain: different numbers are tried and the quality of the corresponding DAPC is assessed by cross- validation: DAPC is performed on a training set, typically made of 90% of the observations (comprising 90% of the observations in each subpopulation) , and then used to predict the groups of the 10% of remaining observations. The current method uses the average prediction success per group (result=“groupMean”), or the overall prediction success (result=“overall”). The number of PCs associated with the lowest Mean Squared Error is then retained in the DAPC.

xvalDapc(snp_country, populations, n.pca.max = 200, n.da = NULL,
              training.set = 0.9, result = c("groupMean", "overall"),
              center = TRUE, scale = FALSE,
              n.pca=NULL, n.rep = 20, xval.plot = TRUE) 

$n.pca: 80 first PCs of PCA used $n.da: 14 discriminant functions saved $var (proportion of conserved variance): 0.561

Run DAPC with object

dapc_snp1 <- dapc(snp_country, n.pca = 80, n.da = 14, grp = populations) 

Save it

saveRDS(
  dapc_snp1, here("/gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/dapc/overlap/dapc_snp1_b.rds"
  )
)

To load it

dapc_snp1 <- readRDS(
  here("/gpfs/gibbs/pi/caccone/mkc54/albo/scripts/RMarkdowns/output/europe/dapc/overlap/dapc_snp1_b.rds"
  )
)

Most contributing alleles

set.seed(4) 
contrib<-loadingplot(dapc_snp1$var.contr,axis=2, thres=.0002,lab.jitter=3)

6.4. Plots

scatter(dapc_snp1)

myCol2 <- c("#52ef99", "#146c45", "#75d5e1", "#FB8072", "#2c4a5e", "#6a8fe0", "#8c61cd", "#f365e7", "#871550", "#a113b2", "#BF5B17", "#1F78B4", "#cf749b",  "#FF7F00","#2524f9", "#799d10", "#a7e831", "#984EA3", "#754819", "#fda547", "#a41415", "#fd5917", "#fd4e8b", "#ead624", "#6A3D9A", "#21a708", "#332288", "#51f310", "#9d8d88", "#66C2A5", "#E41A1C", "#BC80BD", "#E7297A", "darkgray", "orange", "aquamarine3", "magenta", "gold4", "purple")

Check R symbols for plot

#to see all shapes -> plot shapes - para escolher os simbolos
N = 100; M = 1000
good.shapes = c(1:25,35:38,43,60,62:64)
foo = data.frame( x = rnorm(M), y = rnorm(M), s = factor( sample(1:N, M, replace = TRUE) ) )
ggplot(aes(x,y,shape=s ), data=foo ) +
  scale_shape_manual(values=good.shapes[1:N]) +
  geom_point()
## Warning: Removed 692 rows containing missing values or values outside the scale range
## (`geom_point()`).

#1:25,28:31,36,55:57
myCol2 <- c("#51f310", "#146c45", "#75d5e1", "#FF7F00", "magenta", "red",  "yellow3", "#52ef99", "#2524f9",  "#1E90FF", "purple", "#fda547", "#cf749b", "#332288", "#a41415")  

Plot using different discriminant functions

1 & 2

pdf(file = "output/europe/dapc/overlap/dapc_SNP3_overlap_PC1_2.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=2)

1 & 3

pdf(file = "output/europe/dapc/overlap/dapc_SNP3_overlap_PC1_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="topright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="topright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=3)

1 & 4

pdf(file = "output/europe/dapc/overlap/dapc_SNP3_overlap_PC1_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =1, yax=4)

2 & 3

pdf(file = "output/europe/dapc/overlap/dapc_SNP3_overlap_PC2_3.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=3 )

2 & 4

pdf(file = "output/europe/dapc/overlap/dapc_SNP3_overlap_PC2_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =2, yax=4 )

3 & 4

pdf(file = "output/europe/dapc/overlap/dapc_SNP3_overlap_PC3_4.pdf",   # The directory you want to save the file in
    width = 7, # The width of the plot in inches
    height = 7) # The height of the plot in inches

good.shapes = c(1:25,35:38,43,60,62:64)

op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =3, yax=4)

dev.off()
op <- par(cex = 0.39)
scatter(dapc_snp1, pch = good.shapes, cstar = 0, col=myCol2, label=NULL, mstree = FALSE, legend=TRUE, posi.da="bottomright", cex=1.0,  cex.lab=0.5, cex.main=0.5, cellipse=TRUE, posi.leg="topleft",  xax =3, yax=4 )