Tests of population structure

Eric Archer

2020-02-23

Given some sample microsatellite data:

data(msats.g)
msats <- stratify(msats.g, "fine")
msats <- msats[, getLociNames(msats)[1:4], ]

There are several ways that population structure analyses can be conducted. For each population structure metric, there is a function starting with “stat” (e.g., statFst, statChi2, statGst). A full list can be found in ?popStructStat.

Each of these functions takes a gtypes object and produces a list which contains the name of the statistic, the value of the estimate, the permutation p-value (based on 1000 replicates by default), and if keep.null = TRUE, the permutation null distribution:

statFst(msats)
## $stat.name
## [1] "Fst"
## 
## $result
## estimate    p.val 
##     0.11       NA 
## 
## $null.dist
## NULL
statGst(msats, nrep = 10, keep.null = TRUE)
## $stat.name
## [1] "Gst"
## 
## $result
## estimate    p.val 
##    0.061    0.091 
## 
## $null.dist
##  [1] -0.00541 -0.00163 -0.00101 -0.00194 -0.00209 -0.00525 -0.00239 -0.00161
##  [9]  0.00056 -0.00084

Population structure tests can be conducted in an “overall” manner which estimates the degree of differentiation due to the specified stratification scheme, or in a “pairwise” manner, which tests differentiation between all pairs of strata. The overall test is run via overallTest(). By default, all statistics are run and NAs are returned if they are not appropriate to the type of data (e.g., PHIst for diploid data). Tests for specified statistics can be conducted by listing them in the stats argument:

ovl <- overallTest(msats, stats = c("fst", "chi2"), nrep = 1000)
## 
## <<< dolphin msats >>>
##  2020-02-23 16:30:27 : Overall test : 1000 permutations
## 
##                 N
## Coastal        68
## Offshore.North 40
## Offshore.South 18
## 
## Population structure results:
##      estimate p.val
## Fst      0.11 0.001
## Chi2   568.71 0.001

Pairwise tests are conducted with pairwiseTest() in a similar fashion.

pws <- pairwiseTest(msats, stats = c("fst.prime", "gst"), nrep = 1000)
## 
## <<< dolphin msats >>>
##  2020-02-23 16:30:27 : Pairwise tests : 1000 permutations
##    2020-02-23 16:30:27 : Coastal v. Offshore.North 
##    2020-02-23 16:30:27 : Coastal v. Offshore.South 
##    2020-02-23 16:30:28 : Offshore.North v. Offshore.South 
## 
## Population structure results:
##                                               F'st F'st.p.val      Gst
## Coastal (68) v. Offshore.North (40)         0.5117      0.001  0.06713
## Coastal (68) v. Offshore.South (18)         0.5902      0.001  0.07613
## Offshore.North (40) v. Offshore.South (18) -0.0099      0.558 -0.00054
##                                            Gst.p.val
## Coastal (68) v. Offshore.North (40)            0.001
## Coastal (68) v. Offshore.South (18)            0.001
## Offshore.North (40) v. Offshore.South (18)     0.539

The result of a pairwise test contains both a data.frame formatted for each pairwise comparison and pairwise matrices for each statistic with statistic estimates in the lower left, and p-values in the upper right.

pws
## $result
##                                                  strata.1       strata.2 n.1
## Coastal (68) v. Offshore.North (40)               Coastal Offshore.North  68
## Coastal (68) v. Offshore.South (18)               Coastal Offshore.South  68
## Offshore.North (40) v. Offshore.South (18) Offshore.North Offshore.South  40
##                                            n.2    F'st F'st.p.val      Gst
## Coastal (68) v. Offshore.North (40)         40  0.5117      0.001  0.06713
## Coastal (68) v. Offshore.South (18)         18  0.5902      0.001  0.07613
## Offshore.North (40) v. Offshore.South (18)  18 -0.0099      0.558 -0.00054
##                                            Gst.p.val
## Coastal (68) v. Offshore.North (40)            0.001
## Coastal (68) v. Offshore.South (18)            0.001
## Offshore.North (40) v. Offshore.South (18)     0.539
## 
## $pair.mat
## $pair.mat$`F'st`
##                Coastal Offshore.North Offshore.South
## Coastal             NA         0.0010          0.001
## Offshore.North    0.51             NA          0.558
## Offshore.South    0.59        -0.0099             NA
## 
## $pair.mat$Gst
##                Coastal Offshore.North Offshore.South
## Coastal             NA        0.00100          0.001
## Offshore.North   0.067             NA          0.539
## Offshore.South   0.076       -0.00054             NA
## 
## 
## $null.dist
## NULL

Both overall and pairwise tests can be conducted at once with popStructTest():

popStruct <- popStructTest(msats, stats = c("fst", "fst.prime"), nrep = 1000, quietly = TRUE)
popStruct
## $overall
## $overall$strata.freq
## 
##        Coastal Offshore.North Offshore.South 
##             68             40             18 
## 
## $overall$result
##      estimate p.val
## Fst      0.11 0.001
## F'st     0.49 0.001
## 
## $overall$null.dist
## NULL
## 
## 
## $pairwise
## $pairwise$result
##                                                  strata.1       strata.2 n.1
## Coastal (68) v. Offshore.North (40)               Coastal Offshore.North  68
## Coastal (68) v. Offshore.South (18)               Coastal Offshore.South  68
## Offshore.North (40) v. Offshore.South (18) Offshore.North Offshore.South  40
##                                            n.2     Fst Fst.p.val    F'st
## Coastal (68) v. Offshore.North (40)         40  0.1308     0.001  0.5117
## Coastal (68) v. Offshore.South (18)         18  0.1552     0.001  0.5902
## Offshore.North (40) v. Offshore.South (18)  18 -0.0012     0.534 -0.0099
##                                            F'st.p.val
## Coastal (68) v. Offshore.North (40)             0.001
## Coastal (68) v. Offshore.South (18)             0.001
## Offshore.North (40) v. Offshore.South (18)      0.535
## 
## $pairwise$pair.mat
## $pairwise$pair.mat$Fst
##                Coastal Offshore.North Offshore.South
## Coastal             NA         0.0010          0.001
## Offshore.North    0.13             NA          0.534
## Offshore.South    0.16        -0.0012             NA
## 
## $pairwise$pair.mat$`F'st`
##                Coastal Offshore.North Offshore.South
## Coastal             NA         0.0010          0.001
## Offshore.North    0.51             NA          0.535
## Offshore.South    0.59        -0.0099             NA
## 
## 
## $pairwise$null.dist
## NULL