recode_polyploids | R Documentation |
As the genind object requires ploidy to be consistent across loci, a
workaround to importing polyploid data was to code missing alleles as "0"
(for microsatellite data sets). The advantage of this is that users would be
able to calculate Bruvo's distance, the index of association, and genotypic
diversity statistics. The tradeoff was the fact that this broke all other
analyses as they relied on allele frequencies and the missing alleles are
treated as extra alleles. This function removes those alleles and returns a
genclone
or genind
object where
allele frequencies are coded based on the number of alleles observed at a
single locus per individual. See the examples for more details.
recode_polyploids(poly, newploidy = FALSE, addzero = FALSE)
poly |
a |
newploidy |
for genind or genclone objects: if |
addzero |
add zeroes onto genind or genclone objects with uneven ploidy?
if |
The genind object has two caveats that make it difficult to work with polyploid data sets:
ploidy must be constant throughout the data set
missing data is treated as "all-or-none"
In an ideal world, polyploid genotypes would be just as unambiguous as diploid or haploid genotypes. Unfortunately, the world we live in is far from ideal and a genotype of AB in a tetraploid organism could be AAAB, AABB, or ABBB. In order to get polyploid data in to adegenet or poppr, we must code all loci to have the same number of allelic states as the ploidy or largest observed heterozygote (if ploidy is unknown). The way to do this is to insert zeroes to pad the alleles. So, to import two genotypes of:
NA | 20 | 23 | 24 |
20 | 24 | 26 | 43 |
they should be coded as:
0 | 20 | 23 | 24 |
20 | 24 | 26 | 43 |
This zero is treated as an extra allele and is represented in the genind object as so:
0 | 20 | 23 | 24 | 26 | 43 |
1 | 1 | 1 | 1 | 0 | 0 |
0 | 1 | 0 | 1 | 1 | 1 |
This function remedies this problem by removing the zero column. The above table would become:
20 | 23 | 24 | 26 | 43 |
1 | 1 | 1 | 0 | 0 |
1 | 0 | 1 | 1 | 1 |
With this, the user is able to calculate frequency based statistics on the data set.
a genclone
, genind
, or
genpop
object.
This is an approximation, and a bad one at that. Poppr was not originally intended for polyploids, but with the inclusion of Bruvo's distance, it only made sense to attempt something beyond single use.
Zhian N. Kamvar
data(Pinf)
iPinf <- recode_polyploids(Pinf)
# Note that the difference between the number of alleles.
nAll(Pinf)
nAll(iPinf)
## Not run:
library("ape")
# Removing missing data.
setPop(Pinf) <- ~Country
# Calculating Rogers' distance.
rog <- rogers.dist(genind2genpop(Pinf))
irog <- rogers.dist(recode_polyploids(genind2genpop(Pinf)))
# We will now plot neighbor joining trees. Note the decreased distance in the
# original data.
plot(nj(rog), type = "unrooted")
add.scale.bar(lcol = "red", length = 0.02)
plot(nj(irog), type = "unrooted")
add.scale.bar(lcol = "red", length = 0.02)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.