UM.suff: Sufficient statistics for the Unconstrained-Multinomial model

View source: R/UM.suff.R

UM.suffR Documentation

Sufficient statistics for the Unconstrained-Multinomial model

Description

Converts a matrix or data.frame of genotype data into the sufficient statistics required to fit a Dirichlet-Multinomial hierarchical model.

Usage

UM.suff(X, popId)

Arguments

X

Genotype adata. Either a N x 4 matrix with NA's indicating duplicates or a N x 5 column data.frame with the first column being the popId.

popId

grouping variable for X. Must be supplied if X has 4 columns.

Value

A list with elements:

  • A: Vector of unique alleles names. The allele numbers in the following quantities correspond to the indices of A.

  • G: 4-column matrix of unique genotype combinations. The presence of 0's indicates that less than four alleles were amplified indicating that a given genotype either has less than 4 distinct alleles or that some alleles are duplicated.

  • tab: Observed data in a simplified numerical format. This is a contingency table with rows given by the unique elements of popId and columns given by each row of G.

Examples

# sufficient statistics in 3 lakes

X <- fish215[fish215$Lake %in% c("Hogan", "Manitou", "Simcoe"),]
suff <- UM.suff(X)

suff$A # allele names
suff$G # unique genotypes
suff$tab # contingency table

mlysy/MADPop documentation built on Feb. 28, 2024, 12:29 p.m.