Learn R Programming

polyRAD (version 1.1)

AddPloidyChiSq: Chi-Square Test on Genotype Likelihood Distributions

Description

This function is intended to help identify the correct inheritance mode for each locus in a "RADdata" object. Expected genotype frequencies are taken from object$priorProb. Observed genotype frequencies are estimated from object$genotypeLikelihood, where each taxon has a partial assignment to each genotype, proportional to genotype likelihoods. A \(\chi ^ 2\) statistic is then estimated.

Usage

AddPloidyChiSq(object, ...)
# S3 method for RADdata
AddPloidyChiSq(object, excludeTaxa = GetBlankTaxa(object),
               …)

Arguments

object

A "RADdata" object. Genotype prior probabilities and likelihoods should have been added.

excludeTaxa

A character vector indicating names of taxa to exclude from calculations.

Additional arguments to be passed to other methods (none currently in use).

Value

A "RADdata" object identical to the one passed to the function, but with matrices added to the $ploidyChiSq and $ploidyChiSqP slots. Both matrices have ploidies (matching object$priorProb) in rows and alleles in columns. object$ploidyChiSq contains the \(\chi ^ 2\) values. object$ploidyChiSqP contains p-values, i.e. the probability of genotype distributions deviating that far from expectations if the expectations are correct. These p-values may be relatively low due to genotype uncertainty.

Details

Parents (in mapping populations) and blank taxa are automatically excluded from calculations.

Genotypes with zero prior probability would result in an infinite A \(\chi ^ 2\) statistic and therefore are excluded from the calculation. However, the total number of observations (total number of taxa) remains the same, so that if there are many taxa with high likelihood for a genotype with zero prior probability, \(\chi ^ 2\) will be high.

See Also

AddGenotypeLikelihood, AddPloidyLikelihood

Examples

Run this code
# NOT RUN {
# load dataset and set some parameters
data(exampleRAD_mapping)
exampleRAD_mapping <- SetDonorParent(exampleRAD_mapping, "parent1")
exampleRAD_mapping <- SetRecurrentParent(exampleRAD_mapping, "parent2")
exampleRAD_mapping <- AddAlleleFreqMapping(exampleRAD_mapping,
                                           expectedFreqs = c(0.25, 0.75),
                                           allowedDeviation = 0.08)
exampleRAD_mapping <- AddGenotypeLikelihood(exampleRAD_mapping)
exampleRAD_mapping <- AddGenotypePriorProb_Mapping2Parents(exampleRAD_mapping,
                                                      n.gen.backcrossing = 1)
                                                      
# get chi-squared values
exampleRAD_mapping <- AddPloidyChiSq(exampleRAD_mapping)
# view chi-squared and p-values (diploid only)
exampleRAD_mapping$ploidyChiSq
exampleRAD_mapping$ploidyChiSqP
# }

Run the code above in your browser using DataLab