\documentclass[11pt,a4paper]{article}
\usepackage{Sweave}
\usepackage{url}
\usepackage{a4wide}
\usepackage{amsmath,epsfig}
\usepackage{graphicx}
\usepackage[authoryear,round]{natbib}
\bibliographystyle{plainnat}

%% \VignetteIndexEntry{An overview of gap}
%% \Vignettekeywords{human genetics, linkage analysis, association analysis}
%% \VignettePackage{gap}

% \newcommand{\keywords}[1]{\addvspace{\baselineskip}\noindent{{\bf Keywords.} #1}}

\parindent 0in

\begin{document}
\SweaveOpts{engine=R,echo=FALSE,pdf=TRUE}
\title{A Genetic Analysis Package with R}
\author{Jing Hua Zhao}
\date{}
\maketitle

\begin{center}
MRC Epidemiology Unit, Cambridge, UK \\
\url{http://www.mrc-epid.cam.ac.uk}
\end{center}

\tableofcontents

% library(tools)
% Rnwfile<- file.path("/gap/inst/doc","gap.Rnw")
% Sweave(Rnwfile,pdf=TRUE,eps=TRUE,stylepath=TRUE,driver=RweaveLatex())

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Introduction}

This package was initiated to integrate some C/Fortran/SAS programs I have written 
or used over the years. As such, it would rather be a long-term project, but an
immediate benefit would be something complementary to other packages currently
available from CRAN, e.g. {\bf genetics}, {\bf hwde}, etc. I hope eventually this will
be part of a bigger effort to fulfill most of the requirements foreseen by many, 
e.g. ~\cite{guo00}, within the portable environment of R for data management, 
analysis, graphics and object-oriented programming. My view has been outlined
more formally in ~\cite{zt06a} and ~\cite{zt06b} in relation to other package
systems. Also reported are ~\cite{zhao05} and ~\cite{zhao06} on package {\bf kinship}.\\

The number of functions are quite limited and experimental, but I already feel
the enormous advantage by shifting to R and would like sooner rather than later
to share my work with others. I will not claim this workas exclusively done by
me, but would like to invite others to join me and enlarge the collections and
improve them.

\section{Implementation}

The following list shows the data and functions currently available.

\begin{verbatim}
BFDP                    Bayesian false-discovery probability
FPRP                    False-positive report probability
SNP                     Functions for single nucleotide polymorphisms (SNPs)
abc                     Test/Power calculation for mediating effect
aldh2                   ALDH2 markers and alcoholism
apoeapoc                APOE/APOC1 markers and schizophrenia
asplot                  Regional association plot
bt                      Bradley-Terry model for contingency table
b2r                     Obtain correlation coefficients and their variance-covariances
ccsize                  Power and sample size for case-cohort design
chow.test               Chow's test for heterogeneity in two regressions
cf                      Cystic Fibrosis data
comp.score              score statistics for testing genetic linkage of quantitative trait
crohn                   Crohn's disease data
ESplot                  Effect-size plot
fa                      Friedreich ataxia data
fbsize                  Sample size for family-based linkage and association design
fsnps                   A case-control data involving four SNPs with missing genotype
gc.em                   Gene counting for haplotype analysis
gcontrol                genomic control
gcontrol2               genomic control based on p values
gcp                     Permutation tests using GENECOUNTING
genecounting            Gene counting for haplotype analysis
gif                     Kinship coefficient and genetic index of familiality
hap                     Haplotype reconstruction
hap.em                  Gene counting for haplotype analysis
hap.score               Score statistics for association of traits with haplotypes
hla                     HLA markers and schizophrenia
htr                     Haplotype trend regression
h2                      Heritability estimation according to twin correlations
hwe                     Hardy-Weinberg equilibrium test for a multiallelic marker
hwe.cc                  A likelihood ratio test of population Hardy-Weinberg equilibrium for case-control studies
hwe.hardy               Hardy-Weinberg equilibrium test using MCMC
kin.morgan              kinship matrix for simple pedigree
klem                    Haplotype frequency estimation based on a genotype table of two multiallelic markers
LD22                    LD statistics for two diallelic markers
LDkl                    LD statistics for two multiallelic markers
makeped                 A function to prepare pedigrees in post-MAKEPED format
mao                     A study of Parkinson's disease and MAO gene
masize                  Sample size calculation for mediation analysis
metap                   Meta-analysis of p values
metareg                 Fixed and random effects model for meta-analysis
mhtplot                 Manhattan plot of p values
mia                     multiple imputation analysis for hap
mtdt                    Transmission/disequilibrium test of a multiallelic marker
mtdt2                   Transmission/disequilibrium test of a multiallelic marker by Bradley-Terry model
muvar                   Means and variances under 1- and 2- locus (diallelic) QTL model
mvmeta                  Multivariate meta-analysis based on generalized least squares
nep499                  A study of Alzheimer's disease with eight SNPs and APOE
pbsize                  Power for population-based association design
pbsize2                 Power for case-control association design
pedtodot                Converting pedigree(s) to dot file(s)
pfc                     Probability of familial clustering of disease
pfc.sim                 Probability of familial clustering of disease
pgc                     Preparing weight for GENECOUNTING
plot.hap.score          Plot haplotype frequencies versus haplotype score statistics
print.hap.score         Print a hap.score object
qqfun                   Quantile-comparison plots
qqunif                  Q-Q plot for uniformly distributed random variable
read.ms.output          A utility function to read ms output
s2k                     Statistics for 2 by K table
snca                    A study of Parkinson's disease and SNCA markers
tscc                    Power calculation for two-stage case-control design
twinan90                Classic twin models
whscore                 Whittemore-Halpern scores for allele-sharing
\end{verbatim}

Assuming proper installation, you will be able to obtain the list by typing
\texttt{library(help=gap)} or view the list within a web browser via 
\texttt{help.start()}. A PDF version of this file can be viewed with command
\texttt{vignette("gap",package="gap")}.\\

You can cut and paste examples at end of each function's documentation.\\

Both \textit{genecounting} and \textit{hap} are able to handle SNPs and multiallelic
markers, with the former be flexible enough to include features such as X-linked data
and the later being able to handle large number of SNPs. But they are unable to
recode allele labels automatically, so functions \textit{gc.em} and \textit{hap.em}
are in \textit{haplo.em} format and used by a modified function \textit{hap.score} in
association testing.\\

It is notable that multilocus data are handled differently from that in {\bf hwde} and
elegant definitions of basic genetic data can be found in {\bf genetics} package.\\

Incidentally, I found my C mixed-radixed sorting routine as in \cite{zhao03} is much
faster than R's internal function.\\

With exceptions such as function \textit{pfc} which is very computer-intensive, most
functions in the package can easily be adapted for analysis of large datasets involving
either SNPs or multiallelic markers. Some are utility functions, e.g. \textit{muvar}
and \textit{whscore}, which will be part of the other analysis routines in the future.\\

For users, all functions have unified format. For developers, it is able to incorporate
their C/C++ programs more easily and avoid repetitive work such as preparing own routines
for matrix algebra and linear models. Further advantage can be taken from packages in
{\bf Bioconductor}, which are designed and written to deal with large number of genes.


\section{Examples}

Examples can be found from most function documentations. You can also try several simple
examples via \textit{demo}:

\begin{Schunk}
\begin{Scode}
library(gap)
demo(gap)
\end{Scode}
\end{Schunk}

\section{Known bugs}

Unaware of any bug. However, better memory management is expected.

\section{Bibliographic note}

The main references are ~\cite{chow60}, ~\cite{guo92}, ~\cite{wcn92}, ~\cite{gholamic94},
~\cite{hartung08}, ~\cite{risch96}, ~\cite{spielman96}, ~\cite{risch97}, ~\cite{miller97},
~\cite{sham97}, ~\cite{elston75},
~\cite{sham98}, ~\cite{devlin99}, ~\cite{zhao99}, ~\cite{guo00}, ~\cite{hirotsu01}, 
~\cite{zhao02}, ~\cite{zaykin02}, ~\cite{zhao04}, ~\cite{wacholder04}, ~\cite{wang05},
~\cite{skol06}, ~\cite{wakefield07}.

\bibliography{gap}
\end{document}

% Date last modified: 26 August 2009
