Internal Functions in polysat

Share:

Description

The internal functions .G, .indexg, .genlist, .ranmul, and .selfmat are used for calculating genotype probabilities under partial selfing. The internal function .unal1loc finds all unique alleles at a single locus. The internal function fixloci converts locus names to a format that will be compatible as column headers for allele frequency tables.

Usage

1
2
3
4
5
6
7
.G(q, n)
.indexg(ag1, na1, m2)
.genlist(ng, na1, m2)
.ranmul(ng, na1, ag, m2)
.selfmat(ng, na1, ag, m2)
.unal1loc(object, samples, locus)
fixloci(loci, warn = TRUE)

Arguments

q

Integer.

n

Integer.

ag1

A vector representing an unambiguous genotype.

na1

Integer. The number of alleles, including a null.

m2

Integer. The ploidy.

ng

Integer. The number of genotypes.

ag

An array of genotypes such as that produced by .genlist.

object

A "genambig" object.

samples

Optional, a numeric or character vector indicating which samples to use.

locus

A character string or number indicating which locus to use.

loci

A character vector of locus names.

warn

Boolean indicating whether a warning should be issued if locus names are changed.

Value

.G returns

(n+q)!/((q+1)! * (n-1)!)

.indexg returns an integer indicating the row containing a particular genotype in the matrix produced by .genlist.

.genlist returns an array with dimensions ng, m2, containing all possible unambiguous genotypes, one in each row. The null allele is the highest-numbered allele.

.ranmul returns a list. The first item is a vector of polynomial coefficients for calculating genotype frequencies under random mating. The second is an array showing how many copies of each allele each genotype has.

.selfmat returns the selfing matrix. Parental genotypes are represented in rows, and offspring genotypes in columns. The numbers indicate relative amounts of offspring genotypes produced when the parental genotypes are self-fertilized.

.unal1loc returns a vector containing all unique alleles, not including Missing(object).

fixloci returns a character vector of corrected locus names.

Author(s)

Lindsay V. Clark

References

De Silva, H. N., Hall, A. J., Rikkerink, E., and Fraser, L. G. (2005) Estimation of allele frequencies in polyploids under certain patterns of inheritance. Heredity 95, 327–334

See Also

deSilvaFreq, meandistance.matrix2, genotypeProbs, genambig.to.genbinary, alleleDiversity

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Calculation of genotype probabilities in a tetraploid with four
# alleles plus a null, and a selfing rate of 0.5.  This is a translation
# of code in the supplementary material of De Silva et al. (2005).
m2 <- 4
m <- m2/2
na1 <- 5
self <- 0.5
ng <- na1
for(j in 2:m2){
    ng <- ng*(na1+j-1)/j
}
ag <- polysat:::.genlist(ng, na1, m2)
temp <- polysat:::.ranmul(ng, na1, ag, m2)
rmul <- temp[[1]]
arep <- temp[[2]]
rm(temp)
smat <- polysat:::.selfmat(ng, na1, ag, m2)
smatdiv <- (polysat:::.G(m-1,m+1))^2
p1 <- c(0.1, 0.4, 0.2, 0.2, 0.1) # allele frequencies

# GPROBS subroutine
rvec <- rep(0,ng)
for(g in 1:ng){
    rvec[g] <- rmul[g]
    for(j in 1:m2){
        rvec[g] <- rvec[g]*p1[ag[g,j]]
    }
}
id <- diag(nrow=ng)
smatt <- smat/smatdiv
s3 <- id - self * smatt
s3inv <- solve(s3)
gprob <- (1-self) * s3inv 
# gprob is a vector of probabilities of the seventy genotypes.

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.