data(Pram)
head(pgen(Pram, log = FALSE))
# You can get the Pgen values over all loci by summing over the logged results:
exp(rowSums(pgen(Pram, log = TRUE, na.rm = TRUE)))
# You can also take the product of the non-logged results:
apply(pgen(Pram, log = FALSE), 1, prod, na.rm = TRUE)
## Dealing with zero-frequency allele correction
# By default, allele frequencies are calculated with rraf with
# correction = TRUE. This is normally benign when analyzing large populations,
# but it can have a great effect on small populations. Here's a way to supply
# your own correction.
# First, calculate round robin allele frequencies by population with no
# correction. There are many zero values.
(my_rraf <- rraf(Pram, by_pop = TRUE, correction = FALSE))
# When you run pgen with these zero value allele frequencies, the
# probabilities of some genotypes crash to zero.
head(pgen(Pram, log = FALSE, freq = my_rraf))
# One solution: set the allele frequencies to 1/[samples in data]:
my_rraf[my_rraf == 0] <- 1/nInd(Pram)
# Now we don't have genotype probabilites of zero.
head(pgen(Pram, log = FALSE, freq = my_rraf))
Run the code above in your browser using DataLab