###################################################
### chunk number 1: R.hide
###################################################
library(fbat)


###################################################
### chunk number 2: 
###################################################
data(CAMP)
ch<-pedHardyWeinberg(CAMP)


###################################################
### chunk number 3: 
###################################################
viewHW(ch, "p79")


###################################################
### chunk number 4: 
###################################################
tmp<-checkMendelian(CAMP, quiet=TRUE)
cat("For each marker, how many families contains mendelian errors?\n")
print(tmp$nMerrMarker)
cat("For each family, how many markers contains mendelian errors?\n")
cat("tmp$nMerrFamily[1:10]>>\n")
print(tmp$nMerrFamily[1:10])
cat("For each family, how many times\n")
cat("'father id = subject id' or 'mother id = subejct id'?\n")
cat("tmp$nErrFamilySample[1:10]>>\n")
print(tmp$nErrFamilySample[1:10])


###################################################
### chunk number 5: 
###################################################
res<-missGFreq(CAMP, founderOnly=FALSE, quiet=TRUE)
cat("The number of missing genotypes for markers>>")
print(res$nMissMarkers)

cat("The number of missing genotypes for the first 10 subjects>>")
print(res$nMissSubjects[1:10,])


###################################################
### chunk number 6: 
###################################################
res<-fbat(CAMP)


###################################################
### chunk number 7: 
###################################################
summaryPvalue(res) 


###################################################
### chunk number 8: 
###################################################
pvals<-res$statPvalue[,3]
p.adjust.M <- p.adjust.methods
p.adj <- sapply(p.adjust.M, function(meth) p.adjust(pvals, meth))
noquote(apply(p.adj, 2, format.pval, digits = 3))


###################################################
### chunk number 9: 
###################################################
viewstat(res, "p79")


###################################################
### chunk number 10: 
###################################################
res.f<-pedFlagHomo(CAMP)


###################################################
### chunk number 11: 
###################################################
  res<-pedGFreq(CAMP)


###################################################
### chunk number 12: 
###################################################
  res<-pedAFreq(CAMP)