Hypothesis Test"

This vignette will introduce you to find the critical value for comparison of observed and expected obtained last step.

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(mixIndependR)
library(ggplot2)
x <- mixexample

p <- AlleleFreq(x)
h <-Heterozygous(x)
H <- RxpHetero(h,p,HWE=FALSE)
AS<-AlleleShare(x,replacement=FALSE)
e <-RealProAlleleShare(AS)
ObsDist_K<-FreqHetero(h)
ExpDist_K<- DistHetero(H)
ObsDist_X<-FreqAlleleShare(AS)
ExpDist_X<-DistAlleleShare(e)

Simulate_DistK and Simulate_DistX simulate bundles of expected distributions for number of heterozygous loci and number of shared alleles respectively.

Simu_K <- Simulate_DistK(H,100,500)
Simu_X <- Simulate_DistX(e,100,500)

Dist_SimuChisq generates a bundle of chi-square values which can be distributed. ecdf build the cumulative probability functions for the chi-square values.

x2_K<-Dist_SimuChisq(Simu_K,ExpDist_K$Density,200)
x2_X<-Dist_SimuChisq(Simu_X,ExpDist_X$Density,200)
P1<-ecdf(x2_K)
P2<-ecdf(x2_X)
x <- c(0:200)
dfX2 <- data.frame(x=x,y=P1(x))
ggplot(dfX2,aes(x=x,y=P1(x)))+
  geom_line()+
  geom_hline(yintercept = 0.95,color="Red")+
  ggtitle("CPF No. of Heterozygous Loci")+
  xlab("Chi-square")+ylab("1-p-value")

dfX22 <- data.frame(x=x,y=P2(x))
ggplot(dfX22,aes(x=x,y=P2(x)))+
  geom_line()+
  geom_hline(yintercept = 0.95,color="Red")+
  ggtitle("CPF No. of Shared Alleles")+
  xlab("Chi-square")+ylab("1-p-value")


Try the mixIndependR package in your browser

Any scripts or data that you put into this service are public.

mixIndependR documentation built on March 17, 2021, 5:09 p.m.