This vignette will introduce you to how the basic genetic parameters like the allele frequency, the genotype frequency and Hardy-Weinberg Equilibrium results are calculated with mixIndependR
.
The dataset imported should be in a format of the genotype data with individuals in rows and markers in columns. Excel, csv and vcf file format are compatible.
mixexample
is an attached data in this package, which is the genotypes of 2504 individuals on 100 unlined variants including 6 STRs and 94 SNPs.
mixexample x <-
AlleleFreq
calculates the allele frequencies for one dataset.
AlleleFreq(x,sep = "\\|") p <-
GenotypeFreq
calculates the observed or expected genotype frequency. If expect=FALSE
, the observed genotype frequencies from the original dataset will be calculated. If expected=TRUE
, the expected genotype probabilities from allele frequency table under Hardy-Weinberg Equilibrium will be exported.
GenotypeFreq(x,sep = "\\|",expect = FALSE)
G <- GenotypeFreq(x,sep = "\\|",expect = TRUE) G0 <-
Heterozygous
test the heterozygosity of each individuals at each locus and output a table with 0
denoting homozygous and 1
heterozygous.
Heterozygous(x,sep = "\\|") ####or Just use Heterozygous(x) h <-
RxpHetero
calculate Real or Expected Average Heterozygosity at each locus. If HWE=TRUE
, this function will calculate the expected heterozygosities under Hardy-Weinberg Equilibrium; If HWE=FALSE
, this function will calculate the real average heterozygosities.
RxpHetero(h,p,HWE=TRUE) H <-
AlleleShare
calculates the table of number of shared alleles for each pair of individuals at each locus.If replacement=TRUE
, the pairs are formed with replacement; if replacement=FALSE
, the pairs are formed without replacement. When the sample size is large, replacement=F
is much faster.
AlleleShare(x,sep = "\\|",replacement = FALSE) AS<-
RealProAlleleShare
and ExpProAllelShare
calculate the average proportions and the expected probabilities of sharing 0,1 and 2 alleles at each locus.
RealProAlleleShare(AS)
e <-ExpProAlleleShare(p) e0<-
HWE_Chisq
test the Hardy-Weinberg Equilibrium with Pearson’s Chi-square test. B
is an integer specifying the number of replicates used in the Monte Carlo test.
HWE.Chisq(G,G0,rescale.p = T,simulate.p.value = T,B=2000) HWE_pvalue <-