2) Genotype and sequence summaries

Individual summaries

summarizeInds(): This function will produce a summary of genotyping across individuals, including the number of loci genotyped for each, the number and percent of loci missing genotypes, and the percent of loci homozygous.

ind.smry <- summarizeInds(msats.g)

head(ind.smry)
     id        stratum num.loci.genotyped num.loci.missing.genotypes
1 18650 Offshore.South                  5                          0
2 18651 Offshore.South                  5                          0
3 18652 Offshore.South                  5                          0
4 18653 Offshore.South                  5                          0
5 18654 Offshore.South                  5                          0
6 18655 Offshore.South                  5                          0
  pct.loci.missing.genotypes pct.loci.homozygous
1                          0                 0.0
2                          0                 0.2
3                          0                 0.0
4                          0                 0.0
5                          0                 0.2
6                          0                 0.0
tail(ind.smry)
       id        stratum num.loci.genotyped num.loci.missing.genotypes
121 78067        Coastal                  5                          0
122 78068        Coastal                  5                          0
123 78069        Coastal                  5                          0
124 78530 Offshore.North                  5                          0
125 78531 Offshore.North                  5                          0
126 78532 Offshore.North                  5                          0
    pct.loci.missing.genotypes pct.loci.homozygous
121                          0                 0.6
122                          0                 0.4
123                          0                 0.4
124                          0                 0.2
125                          0                 0.4
126                          0                 0.0

Allelic diversity

There are several by-locus summary functions available for gtypes objects. Given some sample microsatellite data:

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

One can compute the following summaries:

numAlleles(): The number of alleles at each locus with:

numAlleles(msats)
  locus num.alleles
1  D11t          12
2  EV37          22
3  EV94          15
4 Ttr11           9

numMissing(): The number of samples with missing data at each locus:

numMissing(msats)
  locus num.missing
1  D11t           1
2  EV37           7
3  EV94           1
4 Ttr11           1

which can also be expressed as a proportion of samples with missing data:

numMissing(msats, prop = TRUE)
  locus num.missing
1  D11t       0.004
2  EV37       0.028
3  EV94       0.004
4 Ttr11       0.004

allelicRichness(): The allelic richness, or the average number of alleles per sample:

allelicRichness(msats)
  locus allelic.richness
1  D11t            0.096
2  EV37            0.185
3  EV94            0.120
4 Ttr11            0.072

heterozygosity(): Both observed and expected heterozygosity:

# observed
heterozygosity(msats, type = "observed")
  locus obsvd.het
1  D11t      0.70
2  EV37      0.70
3  EV94      0.78
4 Ttr11      0.70
# expected
heterozygosity(msats, type = "expected")
  locus exptd.het
1  D11t      0.75
2  EV37      0.83
3  EV94      0.83
4 Ttr11      0.80

propUniqueAlleles(): The proportion of alleles that are unique (present in only one sample):

propUniqueAlleles(msats)
  locus prop.unique.alleles
1  D11t               0.032
2  EV37               0.025
3  EV94               0.016
4 Ttr11               0.024

These measures are all calculated in the summarizeLoci() function and returned as a matrix. This function also allows you to calculate the measures for each stratum separately, which returns a list for each stratum. Many of these functions have a by.strata argument. See the help file of each for details.

summarizeLoci(msats)
  locus num.genotyped num.missing prop.genotyped num.alleles allelic.richness
1  D11t           125           1           0.99          12            0.096
2  EV37           119           7           0.94          22            0.185
3  EV94           125           1           0.99          15            0.120
4 Ttr11           125           1           0.99           9            0.072
  prop.unique.alleles exptd.het obsvd.het
1               0.032      0.75      0.70
2               0.025      0.83      0.70
3               0.016      0.83      0.78
4               0.024      0.80      0.70
summarizeLoci(msats, by.strata = TRUE)
  locus  stratum num.genotyped num.missing prop.genotyped num.alleles
1  D11t Offshore            58           0           1.00          12
2  EV37 Offshore            56           2           0.97          22
3  EV94 Offshore            57           1           0.98          15
4 Ttr11 Offshore            57           1           0.98           9
5  D11t  Coastal            67           1           0.99           3
6  EV37  Coastal            63           5           0.93           7
7  EV94  Coastal            68           0           1.00           5
8 Ttr11  Coastal            68           0           1.00           4
  allelic.richness prop.unique.alleles exptd.het obsvd.het
1            0.207               0.052      0.86      0.91
2            0.393               0.054      0.94      0.79
3            0.263               0.035      0.86      0.82
4            0.158               0.053      0.82      0.79
5            0.045               0.015      0.49      0.52
6            0.111               0.048      0.61      0.62
7            0.074               0.000      0.77      0.74
8            0.059               0.000      0.66      0.63

thetaH: The package also calculates thetaH, the population scaled mutation rate based on heterozygosity using several models:

thetaH(msats, model = 'IAM')
  locus   n    H theta.IAM Ne.mu.IAM
1  D11t 250 0.75       2.9      0.74
2  EV37 238 0.83       4.8      1.20
3  EV94 250 0.83       4.9      1.22
4 Ttr11 250 0.80       3.9      0.97
thetaH(msats, model = 'SMM')
  locus   n    H theta.SMM Ne.mu.SMM
1  D11t 250 0.75       7.3       1.8
2  EV37 238 0.83      16.2       4.1
3  EV94 250 0.83      16.9       4.2
4 Ttr11 250 0.80      11.4       2.9
thetaH(msats, model = 'ZourosSMM')
  locus   n    H theta.ZourosSMM Ne.mu.ZourosSMM
1  D11t 250 0.75             5.7             1.4
2  EV37 238 0.83            13.8             3.5
3  EV94 250 0.83            14.5             3.6
4 Ttr11 250 0.80             9.4             2.3

alleleFreqs(): One can also obtain the allelic frequencies for each locus overall and by-strata by:

alleleFreqs(msats)
$D11t

117 119 121 127 129 131 133 135 137 139 141 143 
  1   1   4   1   3  16  75  96  20  20   7   6 

$EV37

190 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 
  3   4   5   2   7   8   3  13  86  39   8   6  20  11   3   8   5   2   1   2 
240 254 
  1   1 

$EV94

229 239 243 245 247 249 251 253 255 259 261 263 265 269 271 
  1   2  15  18   3  83  41   7   6  27  27   7   8   3   2 

$Ttr11

193 197 207 209 211 213 215 217 219 
  1  10  53  17  35  80  46   7   1 
af <- alleleFreqs(msats, by.strata = TRUE)
str(af)
List of 4
 $ D11t : 'table' int [1:12, 1:2] 0 0 0 0 0 0 48 83 3 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:12] "117" "119" "121" "127" ...
  .. ..$ : chr [1:2] "Coastal" "Offshore"
 $ EV37 : 'table' int [1:22, 1:2] 0 0 0 0 0 0 0 1 71 33 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:22] "190" "200" "202" "204" ...
  .. ..$ : chr [1:2] "Coastal" "Offshore"
 $ EV94 : 'table' int [1:15, 1:2] 0 0 0 12 0 47 30 0 0 25 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:15] "229" "239" "243" "245" ...
  .. ..$ : chr [1:2] "Coastal" "Offshore"
 $ Ttr11: 'table' int [1:9, 1:2] 0 0 42 0 0 59 33 2 0 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:9] "193" "197" "207" "209" ...
  .. ..$ : chr [1:2] "Coastal" "Offshore"

The dupGenotypes() function identifies samples that have the same or nearly the same genotypes. The number (or percent) of loci that must be shared in order for it to be considered a duplicate can be set by the num.shared argument. The return data.frame provides which loci the two samples show mismatches at so they can be reviewed.

# Find samples that share alleles at 2/3rds of the loci
dupes <- dupGenotypes(msats, num.shared = 0.66)
head(dupes)
  ids.1 ids.2 strata.1 strata.2 mismatch.loci num.loci.genotyped
1 78045 78058  Coastal  Coastal          <NA>                  4
2 25509 41822  Coastal  Coastal          <NA>                  4
3 42193 78035  Coastal  Coastal          <NA>                  3
4 41579 45237  Coastal  Coastal          <NA>                  3
5 40916 78038  Coastal  Coastal          <NA>                  3
6 78063 78069  Coastal  Coastal          EV94                  4
  num.loci.shared prop.loci.shared
1               4             1.00
2               4             1.00
3               3             1.00
4               3             1.00
5               3             1.00
6               3             0.75

Back to contents