data(Pram)
# Round robin allele frequencies.
rraf(Pram)
## Round robin allele frequencies will be different than observed
# Compare to without round robin:
PrLoc <- seploc(Pram, res = "mat") # get locus by matrix
lapply(PrLoc, colMeans, na.rm = TRUE)
# Without round robin, clone corrected:
Pcc <- clonecorrect(Pram, strata = NA) # indiscriminantly clone correct
PccLoc <- seploc(Pcc, res = "mat")
lapply(PccLoc, colMeans, na.rm = TRUE)
## Different methods of obtaining round robin allele frequencies
# Get vector output.
rraf(Pram, res = "vector")
# Get data frame output and plot.
(Prdf <- rraf(Pram, res = "data.frame"))
library("ggplot2")
ggplot(Prdf, aes(y = allele, x = frequency)) +
geom_point() +
facet_grid(locus ~ ., scale = "free_y", space = "free")
## Round Robin allele frequencies by populations (matrix only)
# Get frequencies per population without correction for zero-frequency alleles
(Prbp <- rraf(Pram, by_pop = TRUE, correction = FALSE))
# You can set the zero-frequency alleles to be 1/nInd(Pram)
Prbp[Prbp == 0] <- 1/nInd(Pram)
Prbp
# Get frequencies per population, but set zero-frequency alleles to 1/n
(Prbp <- rraf(Pram, by_pop = TRUE, correction = TRUE))
Run the code above in your browser using DataLab