%\VignetteIndexEntry{GGtools overview}
%\VignetteDepends{}
%\VignetteKeywords{Genetical genomics,SNP,expression}
%\VignettePackage{GGtools}

%
% NOTE -- ONLY EDIT THE .Rnw FILE!!!  The .tex file is
% likely to be overwritten.
%
\documentclass[12pt]{article}

\usepackage{amsmath,pstricks}
\usepackage[authoryear,round]{natbib}
\usepackage{hyperref}


\textwidth=6.2in
\textheight=8.5in
%\parskip=.3cm
\oddsidemargin=.1in
\evensidemargin=.1in
\headheight=-.3in

\newcommand{\scscst}{\scriptscriptstyle}
\newcommand{\scst}{\scriptstyle}


\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Robject}[1]{{\texttt{#1}}}
\newcommand{\Rpackage}[1]{{\textit{#1}}}
\newcommand{\Rmethod}[1]{{\texttt{#1}}}
\newcommand{\Rfunarg}[1]{{\texttt{#1}}}
\newcommand{\Rclass}[1]{{\textit{#1}}}

\textwidth=6.2in

\bibliographystyle{plainnat} 
 
\begin{document}
%\setkeys{Gin}{width=0.55\textwidth}

\title{Overview of GGtools for genetics \\ of gene expression in Bioconductor
for Bioc 2.2, 2008}
\maketitle

\tableofcontents

\section{Introduction}

The \Rpackage{GGtools} package contains infrastructure and
demonstration data for joint analysis of transcriptome and
genome through combination of DNA expression microarray
and high-density SNP genotyping data.  For Bioconductor
2.2 we adopted a representation of genotypes due to Clayton
(in package \Rpackage{snpMatrix}) allowing reasonably
convenient storage and manipulation of 4 megaSNP phase II
HapMap genotypes on all the CEPH CEU samples.  This contrasts with
the previous version of \Rpackage{GGtools} which was limited
to 550 kiloSNP and 58 CEU founders.

To give an immediate taste of the capabilities, we
attach the package and load some test data.
<<doini>>=
library(GGtools)
data(hmceuB36.2021)
hmceuB36.2021
@
Expression data are recoverable in a familiar way:
<<lkex>>=
exprs(hmceuB36.2021)[1:5,1:5]
@

Genotype data have more complex representation.
<<lksn>>=
smList(hmceuB36.2021)
@
This shows that we use a named list to hold items
of the \Rclass{snp.matrix} class from \Rpackage{snpMatrix}.
We can dig in with a different accessor:
<<lksn2>>=
rawSNP(hmceuB36.2021, 20)[1:5,1:5]
@
and now we see that an unusual
data representation is in use: the leading zeroes
indicate that a raw byte representation is being shown.

We can coerce from this representation to allele tokens:
<<lksn3>>=
as(smList(hmceuB36.2021)[["20"]][1:5,1:5], "character")
@

\section{Chromosome-wide SNP screens}

The demonstration object \Robject{hmceuB36.2021} has only
chromosomes 20 and 21.  An object in the \Rpackage{GGdata}
package called \Robject{hmceuB36} has all 24 chromosomes.
The \Rpackage{GGBase} package has the SNP locations
for hmceuB36 in an external SQLite store that is exported dynamically
upon attaching GGBase, on which GGtools depends.

It is fairly easy to test for eQTL for a given gene
on a specified chromosome:
<<dot>>=
g1 = gwSnpScreen(genesym("CPNE1"), hmceuB36.2021, chrnum(20))
class(g1)
g1
@
We can visualize the results over the chromosome:
<<lkdo,fig=TRUE>>=
plot(g1)
@
and we can get a report on the most highly associated SNPs:
<<lkklk>>=
tt = topSnps(g1)
tt
@
To see the relationship between expression values and
genotype, the \verb+plot_EvG+ method can be used.
<<lks,fig=TRUE>>=
plot_EvG( genesym("CPNE1"), rsNum(rownames(tt)[1]), hmceuB36.2021 )
@

\section{Genome-wide SNP screens}

The \Rpackage{GGdata} package contains a representation of
all chromosomes.
<<getddd>>=
library(GGdata)
if (!exists("hmceuB36")) data(hmceuB36)
@
We can use \verb+gwSnpScreen+ to find eQTL, if we have sufficient
memory.  On windows, we skip this step.
<<dodo>>=
ONWIN = FALSE
ONWIN = (Sys.info()["sysname"] == "Windows") 
if (!ONWIN) {
rr = gwSnpScreen(genesym("RPS26"), hmceuB36)
rrt = topSnps(rr)
rrt[[12]]
}
@
Note that topSnps, when applied to a genome-wide screen
output, will return a list of chromosome-specific results.

The whole-genome plot is automatic but somewhat slow; on 
windows, this is a placeholder.  Please get the genuine vignette
from the web site.
<<dodwg,fig=TRUE>>=
if (ONWIN) { rr = 1 }; plot(rr)
@

\section{Phenotype data available on CEPH samples}
<<lkpd>>=
names(pData(hmceuB36))
@

\section{Session information}

<<doddss>>=
sessionInfo()
@



\end{document}
