Tests of Population Structure

Eric Archer

2017-04-10

Given some sample microsatellite data:

data(msats.g)
msats <- stratify(msats.g, "fine")
msats <- msats[, locNames(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.056    0.091 
## 
## $null.dist
##  [1] -0.0090 -0.0077 -0.0026 -0.0010 -0.0020 -0.0032 -0.0045  0.0020
##  [9] -0.0087 -0.0107

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 >>>
##  2017-04-10 20:52:10 : 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. You can provide either the statistic names or the names of the functions.

pws <- pairwiseTest(msats, stats = c(statFstPrime, statGst), nrep = 1000)
## 
## <<< dolphin msats >>>
##  2017-04-10 20:52:10 : Pairwise tests : 1000 permutations
##    2017-04-10 20:52:10 : Coastal v. Offshore.North 
##    2017-04-10 20:52:10 : Coastal v. Offshore.South 
##    2017-04-10 20:52:11 : Offshore.North v. Offshore.South 
## 
## Population structure results:
##                                   pair.label    F'st F'st.p.val    Gst
## 1        Coastal (68) v. Offshore.North (40)  0.5117      0.001  0.063
## 2        Coastal (68) v. Offshore.South (18)  0.5902      0.001  0.069
## 3 Offshore.North (40) v. Offshore.South (18) -0.0099      0.544 -0.011
##   Gst.p.val
## 1     0.001
## 2     0.001
## 3     0.486

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
##                                   pair.label       strata.1       strata.2
## 1        Coastal (68) v. Offshore.North (40)        Coastal Offshore.North
## 2        Coastal (68) v. Offshore.South (18)        Coastal Offshore.South
## 3 Offshore.North (40) v. Offshore.South (18) Offshore.North Offshore.South
##   n.1 n.2    F'st F'st.p.val    Gst Gst.p.val
## 1  68  40  0.5117      0.001  0.063     0.001
## 2  68  18  0.5902      0.001  0.069     0.001
## 3  40  18 -0.0099      0.544 -0.011     0.486
## 
## $pair.mat
## $pair.mat$`F'st`
##                Coastal Offshore.North Offshore.South
## Coastal             NA         0.0010          0.001
## Offshore.North    0.51             NA          0.544
## Offshore.South    0.59        -0.0099             NA
## 
## $pair.mat$Gst
##                Coastal Offshore.North Offshore.South
## Coastal             NA          0.001          0.001
## Offshore.North   0.063             NA          0.486
## Offshore.South   0.069         -0.011             NA
## 
## 
## $null.dist
## NULL

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

popStruct <- popStructTest(msats, stats = c(statFst, statFstPrime), 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
##                                   pair.label       strata.1       strata.2
## 1        Coastal (68) v. Offshore.North (40)        Coastal Offshore.North
## 2        Coastal (68) v. Offshore.South (18)        Coastal Offshore.South
## 3 Offshore.North (40) v. Offshore.South (18) Offshore.North Offshore.South
##   n.1 n.2     Fst Fst.p.val    F'st F'st.p.val
## 1  68  40  0.1308     0.001  0.5117      0.001
## 2  68  18  0.1552     0.001  0.5902      0.001
## 3  40  18 -0.0012     0.560 -0.0099      0.560
## 
## $pairwise$pair.mat
## $pairwise$pair.mat$Fst
##                Coastal Offshore.North Offshore.South
## Coastal             NA         0.0010          0.001
## Offshore.North    0.13             NA          0.560
## 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.560
## Offshore.South    0.59        -0.0099             NA
## 
## 
## $pairwise$null.dist
## NULL