chiSqSnpGenos | R Documentation |
Calculate the chi2 statistic to test for Hardy-Weinberg equilibrium. See Graffelman & Camarena (2007) and Shriner (2011).
chiSqSnpGenos(
X,
mafs = NULL,
c = 0.5,
thresh.c = 0.01,
calc.with.D = TRUE,
calc.pval = TRUE
)
X |
matrix of bi-allelic SNP genotypes encoded as allele doses in 0,1,2, with genotypes in rows and SNPs in columns; missing values should be encoded as NA |
mafs |
vector of minor allele frequencies; if NULL, the frequencies will be estimated by feeding |
c |
continuity correction ( |
thresh.c |
threshold on minor allele frequencies below which the continuity correction isn't applied (used when |
calc.with.D |
calculate the chi2 statistic with D, the deviation from independence for the heterozygote, as in equation 1 from Graffelman & Camarena (2007), which only requires the number of heterozygotes; otherwise, use equation 4 |
calc.pval |
calculate the p values associated with the test statistics (Chi-squared distribution with one degree of freedom) |
matrix
Timothee Flutre
estimSnpMaf
, countGenotypicClasses
## Not run: set.seed(1859)
library(scrm)
nb.genos <- 100
Ne <- 10^4
chrom.len <- 10^5
mu <- 10^(-8)
c <- 10^(-8)
genomes <- simulCoalescent(nb.inds=nb.genos,
pop.mut.rate=4 * Ne * mu * chrom.len,
pop.recomb.rate=4 * Ne * c * chrom.len,
chrom.len=chrom.len)
X <- genomes$genos
out <- chiSqSnpGenos(X)
head(out)
sum(p.adjust(out[,"pvalue"], "BH") <= 0.05)
## library(HardyWeinberg) # available on CRAN
## cts <- countGenotypicClasses(X=X)[, -4]
## colnames(cts) <- c("AA","AB","BB")
## out2 <- HWChisqMat(X=cts, cc=0.5, verbose=FALSE)
## lapply(out2, head)
## HWTernaryPlot(X=cts, region=2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.